KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > deployment > web > JettyWebApplicationContext


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6
7 package org.jfox.deployment.web;
8
9 import java.io.IOException JavaDoc;
10
11 import org.jfox.jndi.enc.EnterpriseContextFactory;
12 import org.mortbay.http.HttpException;
13 import org.mortbay.http.HttpRequest;
14 import org.mortbay.http.HttpResponse;
15 import org.mortbay.j2ee.J2EEWebApplicationContext;
16
17 /**
18  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
19  */

20
21 public class JettyWebApplicationContext extends J2EEWebApplicationContext {
22     private static WebEnterpriseContextContainer encFactory = WebEnterpriseContextContainer.getInstance();
23
24     public JettyWebApplicationContext() {
25     }
26
27     public JettyWebApplicationContext(String JavaDoc s) {
28         super(s);
29     }
30
31     /**
32      * before handle, set the current thread's web-context
33      *
34      * @param s
35      * @param s1
36      * @param httpRequest
37      * @param httpResponse
38      * @throws HttpException
39      * @throws IOException
40      */

41     public void handle(String JavaDoc s, String JavaDoc s1, HttpRequest httpRequest, HttpResponse httpResponse) throws HttpException, IOException JavaDoc {
42
43         // and get the EnterpriseContext
44
String JavaDoc contextPath = getContextPath();
45         if(contextPath.startsWith("/")) {
46             contextPath = contextPath.substring(1);
47         }
48
49         EnterpriseContextFactory.EnterpriseType type = EnterpriseContextFactory.enterWeb();
50         String JavaDoc old = encFactory.setCurrentEnterpriseContextName(contextPath);
51         try {
52             super.handle(s, s1, httpRequest, httpResponse);
53         }
54         finally {
55             encFactory.setCurrentEnterpriseContextName(old);
56             EnterpriseContextFactory.enter(type);
57         }
58     }
59
60     public static void main(String JavaDoc[] args) {
61
62     }
63 }
64
65
Popular Tags