Looks like either this commit or 1135940 is causing test failures -- http://ci.apache.org/builders/openejb-trunk-ubuntu/builds/719
--kevan On Jun 15, 2011, at 3:09 AM, [email protected] wrote: > Author: genspring > Date: Wed Jun 15 07:09:46 2011 > New Revision: 1135942 > > URL: http://svn.apache.org/viewvc?rev=1135942&view=rev > Log: > OPENEJB-1596 To add global jndi name to remote jndi system. > > see GERONIMO-6008 to see how geronimo uses it. > > Modified: > > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java > > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java > > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java > > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmJndiFactory.java > > openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java > > Modified: > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java > URL: > http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java?rev=1135942&r1=1135941&r2=1135942&view=diff > ============================================================================== > --- > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java > (original) > +++ > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java > Wed Jun 15 07:09:46 2011 > @@ -352,7 +352,7 @@ public class JndiBuilder { > > String name = strategy.getName(beanClass, > JndiNameStrategy.Interface.LOCALBEAN); > bind("openejb/local/" + name, ref, bindings, beanInfo, > beanClass); > - bindJava(bean, beanClass.getName(), ref); > + bindJava(bean, beanClass, ref, bindings, beanInfo); > > simpleNameRef = ref; > } > @@ -377,7 +377,7 @@ public class JndiBuilder { > > String externalName = "openejb/local/" + > strategy.getName(interfce, JndiNameStrategy.Interface.BUSINESS_LOCAL); > bind(externalName, ref, bindings, beanInfo, interfce); > - bindJava(bean, interfce.getName(), ref); > + bindJava(bean, interfce, ref, bindings, beanInfo); > > if (simpleNameRef == null) simpleNameRef = ref; > } > @@ -404,7 +404,7 @@ public class JndiBuilder { > String name = strategy.getName(interfce, > JndiNameStrategy.Interface.BUSINESS_REMOTE); > bind("openejb/local/" + name, ref, bindings, beanInfo, > interfce); > bind("openejb/remote/" + name, ref, bindings, beanInfo, > interfce); > - bindJava(bean, interfce.getName(), ref); > + bindJava(bean, interfce, ref, bindings, beanInfo); > > if (simpleNameRef == null) simpleNameRef = ref; > } > @@ -428,7 +428,7 @@ public class JndiBuilder { > > name = "openejb/Deployment/" + format(bean.getDeploymentID(), > bean.getLocalInterface().getName(), InterfaceType.EJB_LOCAL); > bind(name, ref, bindings, beanInfo, localHomeInterface); > - bindJava(bean, localHomeInterface.getName(), ref); > + bindJava(bean, localHomeInterface, ref, bindings, beanInfo); > > if (simpleNameRef == null) simpleNameRef = ref; > } > @@ -453,7 +453,7 @@ public class JndiBuilder { > > name = "openejb/Deployment/" + format(bean.getDeploymentID(), > bean.getRemoteInterface().getName(), InterfaceType.EJB_OBJECT); > bind(name, ref, bindings, beanInfo, homeInterface); > - bindJava(bean, homeInterface.getName(), ref); > + bindJava(bean, homeInterface, ref, bindings, beanInfo); > > if (simpleNameRef == null) simpleNameRef = ref; > } > @@ -463,7 +463,7 @@ public class JndiBuilder { > > try { > if (simpleNameRef != null) { > - bindJava(bean, null, simpleNameRef); > + bindJava(bean, null, simpleNameRef, bindings, beanInfo); > } > } catch (NamingException e) { > throw new RuntimeException("Unable to bind simple java:global > name in jndi", e); > @@ -509,7 +509,7 @@ public class JndiBuilder { > > private void bind(String name, Reference ref, Bindings bindings, > EnterpriseBeanInfo beanInfo, Class intrface) throws NamingException { > > - if (name.startsWith("openejb/local/") || > name.startsWith("openejb/remote/") || name.startsWith("openejb/localbean/")) { > + if (name.startsWith("openejb/local/") || > name.startsWith("openejb/remote/") || name.startsWith("openejb/localbean/") > || name.startsWith("openejb/global/")) { > > String externalName = name.replaceFirst("openejb/[^/]+/", ""); > > @@ -529,7 +529,7 @@ public class JndiBuilder { > beanInfo.jndiNames.add(externalName); > > JndiNameInfo nameInfo = new JndiNameInfo(); > - nameInfo.intrface = intrface.getName(); > + nameInfo.intrface = intrface == null ? null : > intrface.getName(); > nameInfo.name = externalName; > beanInfo.jndiNamess.add(nameInfo); > > @@ -565,7 +565,7 @@ public class JndiBuilder { > > //ee6 specified ejb bindings in module, app, and global contexts > > - private void bindJava(BeanContext cdi, String interfaceName, Reference > ref) throws NamingException { > + private void bindJava(BeanContext cdi, Class intrface, Reference ref, > Bindings bindings, EnterpriseBeanInfo beanInfo) throws NamingException { > Context moduleContext = cdi.getModuleContext().getModuleJndiContext(); > Context appContext = > cdi.getModuleContext().getAppContext().getAppJndiContext(); > Context globalContext = > cdi.getModuleContext().getAppContext().getGlobalJndiContext(); > @@ -573,8 +573,8 @@ public class JndiBuilder { > String appName = > cdi.getModuleContext().getAppContext().isStandaloneModule() ? "" : > cdi.getModuleContext().getAppContext().getId() + "/"; > String moduleName = cdi.getModuleID() + "/"; > String beanName = cdi.getEjbName(); > - if (interfaceName != null) { > - beanName = beanName + "!" + interfaceName; > + if (intrface != null) { > + beanName = beanName + "!" + intrface.getName(); > } > try { > String globalName = "global/" + appName + moduleName + beanName; > @@ -583,13 +583,21 @@ public class JndiBuilder { > logger.info(String.format("Jndi(name=\"java:%s\")", > globalName)); > } > globalContext.bind(globalName, ref); > + bind("openejb/global/" + globalName, ref, bindings, beanInfo, > intrface); > } catch (NameAlreadyBoundException e) { > //one interface in more than one role (e.g. both Local and Remote > return; > } > - appContext.bind("app/" + moduleName + beanName, ref); > + > + String globalAppName = "app/" + moduleName + beanName; > + > + appContext.bind(globalAppName, ref); > + bind("openejb/global/" + globalAppName, ref, bindings, beanInfo, > intrface); > + > moduleContext.bind("module/" + beanName, ref); > } > + > + > > /** > * This may not be that performant, but it's certain to be faster than the > > Modified: > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java > URL: > http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java?rev=1135942&r1=1135941&r2=1135942&view=diff > ============================================================================== > --- > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java > (original) > +++ > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppModule.java > Wed Jun 15 07:09:46 2011 > @@ -186,6 +186,11 @@ public class AppModule implements Deploy > public String getJarLocation() { > return (id.getLocation() != null) ? > id.getLocation().getAbsolutePath() : null; > } > + > + public void setModuleId(String moduleId) { > + > + this.id = new ID(null, application, moduleId, id.getLocation(), > id.getUri(), this); > + } > > public String getModuleId() { > return id.getName(); > > Modified: > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java > URL: > http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java?rev=1135942&r1=1135941&r2=1135942&view=diff > ============================================================================== > --- > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java > (original) > +++ > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java > Wed Jun 15 07:09:46 2011 > @@ -60,7 +60,8 @@ public class CoreContainerSystem impleme > if (!(jndiContext.lookup("openejb/local") instanceof Context) > || !(jndiContext.lookup("openejb/remote") instanceof Context) > || !(jndiContext.lookup("openejb/client") instanceof Context) > - || !(jndiContext.lookup("openejb/Deployment") instanceof > Context)) { > + || !(jndiContext.lookup("openejb/Deployment") instanceof Context) > + || !(jndiContext.lookup("openejb/global") instanceof Context)) { > throw new RuntimeException("core openejb naming context not > properly initialized. It must have subcontexts for openejb/local, > openejb/remote, openejb/client, and openejb/Deployment already present"); > } > } > > Modified: > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmJndiFactory.java > URL: > http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmJndiFactory.java?rev=1135942&r1=1135941&r2=1135942&view=diff > ============================================================================== > --- > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmJndiFactory.java > (original) > +++ > openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmJndiFactory.java > Wed Jun 15 07:09:46 2011 > @@ -41,6 +41,7 @@ public class IvmJndiFactory implements J > jndiRootContext.bind("openejb/remote/.", ""); > jndiRootContext.bind("openejb/client/.", ""); > jndiRootContext.bind("openejb/Deployment/.", ""); > + jndiRootContext.bind("openejb/global/.", ""); > } catch (javax.naming.NamingException e) { > throw new RuntimeException("this should not happen", e); > } > > Modified: > openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java > URL: > http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java?rev=1135942&r1=1135941&r2=1135942&view=diff > ============================================================================== > --- > openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java > (original) > +++ > openejb/trunk/openejb3/server/openejb-ejbd/src/main/java/org/apache/openejb/server/ejbd/JndiRequestHandler.java > Wed Jun 15 07:09:46 2011 > @@ -76,7 +76,9 @@ class JndiRequestHandler { > private final Context ejbJndiTree; > private Context clientJndiTree; > private final Context deploymentsJndiTree; > -// private final Context globalTree; > + > + private Context globalJndiTree; > + > private final ClusterableRequestHandler clusterableRequestHandler; > private Context rootContext; > > @@ -84,8 +86,9 @@ class JndiRequestHandler { > ContainerSystem containerSystem = > SystemInstance.get().getComponent(ContainerSystem.class); > ejbJndiTree = (Context) > containerSystem.getJNDIContext().lookup("openejb/remote"); > deploymentsJndiTree = (Context) > containerSystem.getJNDIContext().lookup("openejb/Deployment"); > - // TODO if we had an actual global context, we'd look it up like this > -// globalTree = (Context) > containerSystem.getJNDIContext().lookup("openejb/global"); > + > + globalJndiTree = (Context) > containerSystem.getJNDIContext().lookup("openejb/global"); > + > rootContext = containerSystem.getJNDIContext(); > try { > clientJndiTree = (Context) > containerSystem.getJNDIContext().lookup("openejb/client"); > @@ -165,6 +168,8 @@ class JndiRequestHandler { > context = getGlobalTree(); > } else if (req.getModuleId() != null && > req.getModuleId().equals("openejb/Deployment")){ > context = deploymentsJndiTree; > + } else if (req.getModuleId() != null && > req.getModuleId().equals("openejb/global")){ > + context = globalJndiTree; > } else if (req.getModuleId() != null && clientJndiTree != null) { > context = (Context) clientJndiTree.lookup(req.getModuleId()); > } else { > >
