1 45 package org.openejb.core.ivm.naming; 46 47 import java.util.Hashtable ; 48 import java.util.Properties ; 49 50 import javax.naming.Context ; 51 52 import org.openejb.EnvProps; 53 54 68 public class InitContextFactory implements javax.naming.spi.InitialContextFactory { 69 70 public Context getInitialContext(Hashtable env) throws javax.naming.NamingException { 71 if (!org.openejb.OpenEJB.isInitialized()) { 72 initializeOpenEJB(env); 73 } 74 75 Context context = org.openejb.OpenEJB.getJNDIContext(); 76 context = (Context )context.lookup("java:openejb/ejb"); 77 return context; 78 79 } 80 81 private void initializeOpenEJB(Hashtable env) throws javax.naming.NamingException { 82 try{ 83 Properties props = new Properties (); 84 85 91 props.put(EnvProps.ASSEMBLER, "org.openejb.alt.assembler.classic.Assembler"); 92 props.put(EnvProps.CONFIGURATION_FACTORY, "org.openejb.alt.config.ConfigurationFactory"); 93 props.put(EnvProps.CONFIGURATION, "conf/default.openejb.conf"); 94 95 props.putAll(System.getProperties()); 97 98 props.putAll( env ); 100 101 org.openejb.OpenEJB.init( props ); 102 103 } 104 catch( org.openejb.OpenEJBException e){ 105 throw new NamingException("Cannot initailize OpenEJB", e); 106 } 107 catch( Exception e){ 108 throw new NamingException("Cannot initailize OpenEJB", e); 109 } 110 } 111 112 } 113 114 115 | Popular Tags |