KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.naming.Context JavaDoc;
10
11 import org.jfox.ioc.Registry;
12 import org.jfox.ioc.exception.ComponentException;
13 import org.jfox.jndi.enc.AbstractEnterpriseContextContainer;
14 import org.jfox.jndi.enc.EnterpriseContext;
15 import org.jfox.jndi.enc.EnterpriseContextInvocationHandler;
16
17 /**
18  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
19  */

20
21 public class WebEnterpriseContextContainer extends AbstractEnterpriseContextContainer {
22     private static WebEnterpriseContextContainer instance = new WebEnterpriseContextContainer();
23
24     private WebDeployer webDeployer = null;
25
26     public WebEnterpriseContextContainer() {
27         try {
28             webDeployer = (WebDeployer)(Registry.getInstance().getComponentInstance(WebDeployer.class));
29         }
30         catch(ComponentException e) {
31             e.printStackTrace();
32             throw new RuntimeException JavaDoc("Web container instance error");
33         }
34     }
35
36     public static WebEnterpriseContextContainer getInstance() {
37         return instance;
38     }
39
40
41     public Context JavaDoc getCurrentEnterpriseContext() {
42         String JavaDoc webContext = (String JavaDoc) currName.get();
43         if(webContext == null) {
44             return new EnterpriseContext();
45         }
46         return ((NestedWebModule) webDeployer.getWebModule(webContext)).getEnterpriseContext();
47     }
48
49     public EnterpriseContextInvocationHandler getEnterpriseContextInvocationHandler() {
50         return new EnterpriseContextInvocationHandler(getCurrentEnterpriseContext());
51     }
52
53     public static void main(String JavaDoc[] args) {
54
55     }
56 }
57
Popular Tags