1 17 package org.apache.geronimo.client; 18 19 import java.util.Iterator ; 20 import java.util.Map ; 21 import java.util.Collections ; 22 import javax.naming.InitialContext ; 23 import javax.naming.Context ; 24 import javax.naming.NamingException ; 25 26 import org.apache.geronimo.naming.java.RootContext; 27 import org.apache.geronimo.naming.reference.KernelAwareReference; 28 import org.apache.geronimo.naming.reference.ClassLoaderAwareReference; 29 import org.apache.geronimo.naming.enc.EnterpriseNamingContext; 30 import org.apache.geronimo.gbean.GBeanInfo; 31 import org.apache.geronimo.gbean.GBeanInfoBuilder; 32 import org.apache.geronimo.gbean.AbstractName; 33 import org.apache.geronimo.kernel.Kernel; 34 import org.apache.xbean.naming.context.ImmutableContext; 35 36 39 public class StaticJndiContextPlugin implements AppClientPlugin { 40 private final Context context; 41 42 public StaticJndiContextPlugin(Map context, Kernel kernel, ClassLoader classLoader) throws NamingException { 43 this.context = EnterpriseNamingContext.createEnterpriseNamingContext(context, null, kernel, classLoader); 44 } 45 46 public void startClient(AbstractName appClientModuleName, Kernel kernel, ClassLoader classLoader) throws Exception { 47 RootContext.setComponentContext(context); 48 new InitialContext ().lookup("java:comp/env"); 49 } 50 51 public void stopClient(AbstractName appClientModuleName) throws Exception { 52 RootContext.setComponentContext(null); 53 } 54 55 public static final GBeanInfo GBEAN_INFO; 56 57 static { 58 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(StaticJndiContextPlugin.class); 59 60 infoFactory.addAttribute("context", Map .class, true); 61 infoFactory.addAttribute("kernel", Kernel.class, false); 62 infoFactory.addAttribute("classLoader", ClassLoader .class, false); 63 infoFactory.addInterface(AppClientPlugin.class); 64 65 infoFactory.setConstructor(new String []{"context", "kernel", "classLoader"}); 66 67 GBEAN_INFO = infoFactory.getBeanInfo(); 68 } 69 70 public static GBeanInfo getGBeanInfo() { 71 return GBEAN_INFO; 72 } 73 } 74 | Popular Tags |