geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1146934 - in /geronimo/server/trunk/plugins: axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/ corba/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/ j2ee/geronimo-j2ee-builder/src/main/ja...
Date Fri, 15 Jul 2011 00:52:47 GMT
Author: djencks
Date: Fri Jul 15 00:52:45 2011
New Revision: 1146934

URL: http://svn.apache.org/viewvc?rev=1146934&view=rev
Log:
GERONIMO-5050 really use only one owb context for the whole ear, and combine all the module info into it

Added:
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/AppInfoGBean.java   (with props)
Removed:
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbModuleStarter.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/GeronimoEjbInfo.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/MEJBGBean.java
Modified:
    geronimo/server/trunk/plugins/axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java
    geronimo/server/trunk/plugins/corba/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaModuleBuilderExtension.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbModuleImpl.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/OpenWebBeansWebInitializer.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/ThreadSingletonServiceAdapter.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java

Modified: geronimo/server/trunk/plugins/axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/plugins/axis/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisModuleBuilderExtension.java Fri Jul 15 00:52:45 2011
@@ -129,7 +129,7 @@ public class AxisModuleBuilderExtension 
 
         Map<String, WebServiceBinding> wsBindingMap = createWebServiceBindingMap(ejbModule);
 
-        for (EnterpriseBeanInfo bean : ejbModule.getEjbInfo().getEjbJarInfo().enterpriseBeans) {
+        for (EnterpriseBeanInfo bean : ejbModule.getEjbJarInfo().enterpriseBeans) {
 
             String j2eeType = null;
             if (bean.type == EnterpriseBeanInfo.STATELESS) {
@@ -192,7 +192,7 @@ public class AxisModuleBuilderExtension 
 
         Map<String, WebServiceBinding> wsBindingMap = createWebServiceBindingMap(ejbModule);
 
-        for (EnterpriseBeanInfo bean : ejbModule.getEjbInfo().getEjbJarInfo().enterpriseBeans) {
+        for (EnterpriseBeanInfo bean : ejbModule.getEjbJarInfo().enterpriseBeans) {
 
             String j2eeType = null;
             if (bean.type == EnterpriseBeanInfo.STATELESS) {

Modified: geronimo/server/trunk/plugins/corba/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/corba/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaModuleBuilderExtension.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/corba/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/plugins/corba/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/CorbaModuleBuilderExtension.java Fri Jul 15 00:52:45 2011
@@ -238,7 +238,7 @@ public class CorbaModuleBuilderExtension
      *                   module.
      */
     private AbstractName resolveEjb(EARContext earContext, EjbModule ejbModule, String name) throws DeploymentException {
-        for (EnterpriseBeanInfo bean : ejbModule.getEjbInfo().getEjbJarInfo().enterpriseBeans) {
+        for (EnterpriseBeanInfo bean : ejbModule.getEjbJarInfo().enterpriseBeans) {
             // search for the target ejb 
             if (name.equals(bean.ejbName)) {
                 switch (bean.type) {

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java Fri Jul 15 00:52:45 2011
@@ -245,4 +245,13 @@ public class EARContext extends Deployme
             return (AbstractName) context.get(this);
         }
     };
+
+    public static final EARContext.Key<AbstractName> APPINFO_GBEAN_NAME_KEY = new Key<AbstractName>() {
+
+        @Override
+        public AbstractName get(Map<Key, Object> context) {
+            return (AbstractName) context.get(this);
+        }
+    };
+
 }

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java Fri Jul 15 00:52:45 2011
@@ -48,7 +48,7 @@ public class EJBWebServiceFinder impleme
         throws DeploymentException {
         Bundle bundle = ejbModule.getEarContext().getDeploymentBundle();
         Set<String> ejbWebServiceClassNames = new HashSet<String>();
-        for (EnterpriseBeanInfo bean : ejbModule.getEjbInfo().getEjbJarInfo().enterpriseBeans) {
+        for (EnterpriseBeanInfo bean : ejbModule.getEjbJarInfo().enterpriseBeans) {
             if (bean.type != EnterpriseBeanInfo.STATELESS && bean.type != EnterpriseBeanInfo.SINGLETON) {
                 continue;
             }

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java Fri Jul 15 00:52:45 2011
@@ -127,7 +127,7 @@ public class JAXWSEJBModuleBuilderExtens
 
         jaxwsBuilder.findWebServices(module, true, correctedPortLocations, environment, ejbModule.getSharedContext());
 
-        for (EnterpriseBeanInfo bean : ejbModule.getEjbInfo().getEjbJarInfo().enterpriseBeans) {
+        for (EnterpriseBeanInfo bean : ejbModule.getEjbJarInfo().enterpriseBeans) {
 
             String j2eeType = null;
             if (bean.type == EnterpriseBeanInfo.STATELESS) {
@@ -192,7 +192,7 @@ public class JAXWSEJBModuleBuilderExtens
 
         Map<String, WebServiceBinding> wsBindingMap = createWebServiceBindingMap(ejbModule);
 
-        for (EnterpriseBeanInfo bean : ejbModule.getEjbInfo().getEjbJarInfo().enterpriseBeans) {
+        for (EnterpriseBeanInfo bean : ejbModule.getEjbJarInfo().enterpriseBeans) {
             String j2eeType = null;
             if (bean.type == EnterpriseBeanInfo.STATELESS) {
                 j2eeType = NameFactory.STATELESS_SESSION_BEAN;

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java Fri Jul 15 00:52:45 2011
@@ -17,6 +17,8 @@
 
 package org.apache.geronimo.jetty8;
 
+import java.beans.beancontext.BeanContext;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -301,19 +303,21 @@ public class WebAppContextWrapper implem
         }
         //supply web.xml to jasper
         webAppContext.setAttribute(JASPER_WEB_XML_NAME, originalSpecDD);
+        WebBeansContext webBeansContext;
         if (sharedOwbContext == null) {
-            //we have to initialize the owb context
-            Thread thread = Thread.currentThread();
-            ClassLoader cl = thread.getContextClassLoader();
-            thread.setContextClassLoader(classLoader);
-            try {
-                integrationContext.setOwbContext(OpenWebBeansWebInitializer.newWebBeansContext(webAppContext.getServletContext()));
-            } finally {
-                thread.setContextClassLoader(cl);
-            }
+            webBeansContext = OpenWebBeansWebInitializer.newWebBeansContext(null);
         } else {
-            integrationContext.setOwbContext(sharedOwbContext.getOWBContext());
+            webBeansContext= sharedOwbContext.getOWBContext();
+        }
+        Thread thread = Thread.currentThread();
+        ClassLoader cl = thread.getContextClassLoader();
+        thread.setContextClassLoader(classLoader);
+        try {
+            OpenWebBeansWebInitializer.initializeServletContext(webBeansContext, webAppContext.getServletContext());
+        } finally {
+            thread.setContextClassLoader(cl);
         }
+        integrationContext.setOwbContext(webBeansContext);
     }
 
 

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java Fri Jul 15 00:52:45 2011
@@ -19,7 +19,6 @@ package org.apache.geronimo.openejb.depl
 
 import java.security.Permission;
 import java.security.PermissionCollection;
-import java.security.Permissions;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -42,7 +41,6 @@ import org.apache.geronimo.j2ee.deployme
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
-import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.jndi.JndiKey;
 import org.apache.geronimo.j2ee.jndi.JndiScope;
@@ -403,7 +401,7 @@ public class EjbDeploymentBuilder {
             parentModule = parentModule.getParentModule();
         }
         
-        EjbJarInfo ejbJarInfo = ejbModule.getEjbInfo().getEjbJarInfo();
+        EjbJarInfo ejbJarInfo = ejbModule.getEjbJarInfo();
         for (EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
             String ejbName = bean.getEjbName();
             String deploymentId = getDeploymentId(ejbName, ejbJarInfo);

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java Fri Jul 15 00:52:45 2011
@@ -26,9 +26,9 @@ import org.apache.geronimo.j2ee.deployme
 import org.apache.geronimo.j2ee.jndi.JndiKey;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.openejb.GeronimoEjbInfo;
 import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
 import org.apache.openejb.ClassLoaderUtil;
+import org.apache.openejb.assembler.classic.EjbJarInfo;
 import org.apache.openejb.config.ConfigurationFactory;
 import org.apache.openejb.core.TempClassLoader;
 import org.apache.openejb.jee.EjbJar;
@@ -41,7 +41,7 @@ import org.apache.xmlbeans.XmlObject;
  * @version $Rev$ $Date$
  */
 public class EjbModule extends EJBModule<OpenejbGeronimoEjbJarType> {
-    private GeronimoEjbInfo ejbInfo;
+    private EjbJarInfo ejbJarInfo;
     private EjbDeploymentBuilder ejbDeploymentBuilder;
     private final org.apache.openejb.config.EjbModule ejbModule;
     private final ConfigurationFactory.Chain preAutoConfigDeployer;
@@ -78,12 +78,12 @@ public class EjbModule extends EJBModule
         return ejbModule;
     }
 
-    public GeronimoEjbInfo getEjbInfo() {
-        return ejbInfo;
+    public EjbJarInfo getEjbJarInfo() {
+        return ejbJarInfo;
     }
 
-    public void setEjbInfo(GeronimoEjbInfo ejbInfo) {
-        this.ejbInfo = ejbInfo;
+    public void setEjbJarInfo(EjbJarInfo ejbInfo) {
+        this.ejbJarInfo = ejbInfo;
     }
 
     public EjbDeploymentBuilder getEjbBuilder() {

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java Fri Jul 15 00:52:45 2011
@@ -84,11 +84,10 @@ import org.apache.geronimo.kernel.reposi
 import org.apache.geronimo.kernel.util.FileUtils;
 import org.apache.geronimo.kernel.util.JarUtils;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
+import org.apache.geronimo.openejb.AppInfoGBean;
 import org.apache.geronimo.openejb.EjbContainer;
 import org.apache.geronimo.openejb.EjbDeployment;
 import org.apache.geronimo.openejb.EjbModuleImpl;
-import org.apache.geronimo.openejb.EjbModuleStarter;
-import org.apache.geronimo.openejb.GeronimoEjbInfo;
 import org.apache.geronimo.openejb.OpenEjbSystem;
 import org.apache.geronimo.openejb.cdi.SharedOwbContext;
 import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
@@ -772,9 +771,9 @@ public class EjbModuleBuilder implements
         
 
 
-        GeronimoEjbInfo ejbInfo = getEjbInfo(earContext, ejbModule, bundle);
+        AppInfo appInfo = getAppInfo(earContext, ejbModule, bundle);
 
-        ejbModule.setEjbInfo(ejbInfo);
+        ejbModule.setEjbJarInfo(AppInfoGBean.getEjbJarInfo(appInfo, ejbModule.getModuleURI()));
 
         // update the original spec dd with the metadata complete dd
         EjbJar ejbJar = ejbModule.getEjbJar();
@@ -815,30 +814,16 @@ public class EjbModuleBuilder implements
 
        
         GBeanData ejbModuleGBeanData = new GBeanData(ejbModule.getModuleName(), EjbModuleImpl.class);
-        AbstractName starterName = earContext.getNaming().createChildName(ejbModule.getModuleName(), "EjbModuleStarter", "EjbModuleStarter");
-        GBeanData ejbModuleStarterGBeanData = new GBeanData(starterName, EjbModuleStarter.class);
-        ejbModuleStarterGBeanData.setReferencePattern("EjbModule", ejbModule.getModuleName());
-        ejbModuleStarterGBeanData.setReferencePattern("OpenEjbSystem", new AbstractNameQuery(null, Collections.EMPTY_MAP, OpenEjbSystem.class.getName()));
         try {
 
-            //sets up the openejb infrastructure; happens before web modules start
-            earContext.addGBean(ejbModuleGBeanData);
             //starts the ejbs; happens in module order (which may be before or after web modules)
-            ejbModule.addGBean(ejbModuleStarterGBeanData);
-            
+            ejbModule.addGBean(ejbModuleGBeanData);
+
         } catch (GBeanAlreadyExistsException e) {
             throw new DeploymentException("Could not add ejb module gbean", e);
         }
         //commented out code is for sharing owb context of an ejb module in a war with the war
 //        module.getSharedContext().put(SharedOwbContext.class, ejbModuleGBeanData);
-        //this shares the OWB context over the whole ear
-        Module<?,?> m = module;
-        while (m.getParentModule() != null) {
-            m = m.getParentModule();
-        }
-        if (m.getSharedContext().get(SharedOwbContext.class) == null) {
-            m.getSharedContext().put(SharedOwbContext.class, ejbModuleGBeanData);
-        }
 
         for (ModuleBuilderExtension builder : moduleBuilderExtensions) {
             try {
@@ -850,9 +835,9 @@ public class EjbModuleBuilder implements
         }
     }
 
-    private GeronimoEjbInfo getEjbInfo(EARContext earContext, EjbModule ejbModule, Bundle bundle) throws DeploymentException {
+    private AppInfo getAppInfo(EARContext earContext, EjbModule ejbModule, Bundle bundle) throws DeploymentException {
         EarData earData = EarData.KEY.get(earContext.getGeneralData());
-        if (earData.getEjbInfos().isEmpty()) {
+        if (earData.getAppInfo() == null) {
 
             ClassLoader bundleLoader = new BundleClassLoader(bundle);
 
@@ -894,12 +879,7 @@ public class EjbModuleBuilder implements
                 throw new DeploymentException(e);
             }
 
-            // add all of the modules to the ear data
-            for (EjbJarInfo ejbJar : appInfo.ejbJars) {
-                GeronimoEjbInfo ejbInfo = new GeronimoEjbInfo(ejbJar, appInfo.globalJndiEnc, appInfo.appJndiEnc, appInfo.appId);
-                earData.addEjbInfo(ejbInfo);
-            }
-
+            earData.setAppInfo(appInfo);
             // add the cmp jar
             CmpJarBuilder cmp2Builder = new CmpJarBuilder(appInfo, bundleLoader);
             try {
@@ -920,11 +900,23 @@ public class EjbModuleBuilder implements
             if (appInfo.cmpMappingsXml != null) {
                 addGeronimmoOpenEJBPersistenceUnit(ejbModule);
             }
+            Module m = ejbModule;
+            while (m.getParentModule() != null) {
+                m = m.getParentModule();
+            }
+            AbstractName appInfoName = earContext.getNaming().createChildName(m.getModuleName(), "appInfoGBean", "appInfoGBean");
+            earContext.getGeneralData().put(EARContext.APPINFO_GBEAN_NAME_KEY, appInfoName);
+            GBeanData appInfoData = new GBeanData(appInfoName, AppInfoGBean.class);
+            appInfoData.setAttribute("appInfo", appInfo);
+            appInfoData.setReferencePattern("OpenEjbSystem", new AbstractNameQuery(null, Collections.EMPTY_MAP, OpenEjbSystem.class.getName()));
+            try {
+                earContext.addGBean(appInfoData);
+            } catch (GBeanAlreadyExistsException e) {
+                throw new DeploymentException("Duplicate app info gbean", e);
+            }
         }
 
-        // find our module
-        GeronimoEjbInfo ejbInfo = earData.getEjbInfo(ejbModule.getEjbModule().getModuleUri().toString());
-        return ejbInfo;
+        return earData.getAppInfo();
     }
 
     private AppInfo configureApplication(AppModule appModule, EjbModule ejbModule, Configuration configuration)
@@ -1197,7 +1189,7 @@ public class EjbModuleBuilder implements
             linkResolver.add(rootUrl, name, id);
         }
 
-        EjbJarInfo ejbJarInfo = ejbModule.getEjbInfo().getEjbJarInfo();
+        EjbJarInfo ejbJarInfo = ejbModule.getEjbJarInfo();
         for (EnterpriseBeanInfo beanInfo : ejbJarInfo.enterpriseBeans) {
             if (beanInfo instanceof StatefulBeanInfo) {
                 StatefulBeanInfo statefulBeanInfo = (StatefulBeanInfo) beanInfo;
@@ -1227,8 +1219,8 @@ public class EjbModuleBuilder implements
                             EjbDeployment.class.getName())));
 
             ejbModuleGBeanData.setReferencePattern("OpenEjbSystem", new AbstractNameQuery(null, Collections.EMPTY_MAP, OpenEjbSystem.class.getName()));
-            ejbModuleGBeanData.setAttribute("ejbInfo", ejbModule.getEjbInfo());
-            ejbModuleGBeanData.setAttribute("modulePath", ejbModule.getTargetPath());
+            ejbModuleGBeanData.setReferencePattern("AppInfo", EARContext.APPINFO_GBEAN_NAME_KEY.get(earContext.getGeneralData()));
+            ejbModuleGBeanData.setAttribute("moduleURI", ejbModule.getEjbModule().getModuleUri());
             ejbModuleGBeanData.setAttribute("moduleContext", module.getJndiScope(JndiScope.module));
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize EJBModule GBean " + ejbModule.getModuleName(), e);
@@ -1238,7 +1230,7 @@ public class EjbModuleBuilder implements
         ejbDeploymentBuilder.addEjbModuleDependency(ejbModuleGBeanData);
 
         // add the Jacc permissions to the ear
-        String policyContextId = ejbModule.getEjbInfo().getEjbJarInfo().moduleUri.toString();
+        String policyContextId = ejbModule.getEjbJarInfo().moduleUri.toString();
         ComponentPermissions componentPermissions = (ComponentPermissions) earContext.getContextIDToPermissionsMap().get(policyContextId);
         if (componentPermissions == null) {
             componentPermissions = new ComponentPermissions(new Permissions(), new Permissions(), new HashMap<String, PermissionCollection>());
@@ -1264,7 +1256,7 @@ public class EjbModuleBuilder implements
             return;
         }
         OpenejbJarType openejbJarType = (OpenejbJarType) altDD;
-        EjbJarInfo ejbJarInfo = ejbModule.getEjbInfo().getEjbJarInfo();
+        EjbJarInfo ejbJarInfo = ejbModule.getEjbJarInfo();
 
         Map<String, MessageDrivenBeanInfo> mdbs = new TreeMap<String, MessageDrivenBeanInfo>();
         for (EnterpriseBeanInfo enterpriseBean : ejbJarInfo.enterpriseBeans) {
@@ -1427,7 +1419,7 @@ public class EjbModuleBuilder implements
         };
 
         private final Map<String, EjbModule> ejbModules = new TreeMap<String, EjbModule>();
-        private final Map<String, GeronimoEjbInfo> ejbJars = new TreeMap<String, GeronimoEjbInfo>();
+        private AppInfo appInfo;
 
         public void addEjbModule(EjbModule ejbModule) {
             ejbModules.put(ejbModule.getEjbModule().getModuleUri().toString(), ejbModule);
@@ -1445,21 +1437,12 @@ public class EjbModuleBuilder implements
             return ejbModules.values();
         }
 
-        public void addEjbInfo(GeronimoEjbInfo ejbInfo) {
-            ejbJars.put(ejbInfo.getEjbJarInfo().moduleUri.toString(), ejbInfo);
-        }
-
-        public GeronimoEjbInfo getEjbInfo(String moduleURI) throws DeploymentException {
-            GeronimoEjbInfo ejbInfo = ejbJars.get(moduleURI);
-            if (ejbInfo == null) {
-                throw new DeploymentException("Ejb jar configuration passed but expected module " +
-                        moduleURI + " was not found in configured module list " + ejbJars.keySet());
-            }
-            return ejbInfo;
+        public void setAppInfo(AppInfo appInfo) {
+            this.appInfo = appInfo;
         }
 
-        public Collection<GeronimoEjbInfo> getEjbInfos() {
-            return ejbJars.values();
+        public AppInfo getAppInfo() throws DeploymentException {
+            return appInfo;
         }
     }
     

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java Fri Jul 15 00:52:45 2011
@@ -44,7 +44,6 @@ import org.apache.geronimo.j2ee.jndi.Jnd
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.deployment.AbstractNamingBuilder;
 import org.apache.geronimo.openejb.ClientEjbReference;
-import org.apache.geronimo.openejb.GeronimoEjbInfo;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefDocument;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEjbRefDocument;
@@ -137,15 +136,12 @@ public class EjbRefBuilder extends Abstr
         Set<String> ejbLocalRefNames = new HashSet<String>();
         try {
             EjbModuleBuilder.EarData earData = EjbModuleBuilder.EarData.KEY.get(module.getRootEarContext().getGeneralData());
-            Collection<GeronimoEjbInfo> ejbInfos = Collections.emptySet();
-            if (earData != null) {
-                ejbInfos = earData.getEjbInfos();
+            if (earData == null) {
+                //no ejbs anywhere?
+                return;
             }
 
-            AppInfo appInfo = new AppInfo();
-            for (GeronimoEjbInfo ejbInfo : ejbInfos) {
-                appInfo.ejbJars.add(ejbInfo.getEjbJarInfo());
-            }
+            AppInfo appInfo = earData.getAppInfo();
 
             JndiEncInfoBuilder jndiEncInfoBuilder = new JndiEncInfoBuilder(appInfo);
             JndiEncInfo moduleJndi = new JndiEncInfo();

Added: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/AppInfoGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/AppInfoGBean.java?rev=1146934&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/AppInfoGBean.java (added)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/AppInfoGBean.java Fri Jul 15 00:52:45 2011
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.openejb;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NamingException;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.openejb.cdi.SharedOwbContext;
+import org.apache.openejb.AppContext;
+import org.apache.openejb.BeanContext;
+import org.apache.openejb.NoSuchApplicationException;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.UndeployException;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.webbeans.config.WebBeansContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+
+@GBean
+public class AppInfoGBean implements SharedOwbContext, GBeanLifecycle {
+    private static final Logger log = LoggerFactory.getLogger(AppInfoGBean.class);
+
+    private final AppInfo appInfo;
+    private final ClassLoader classLoader;
+    private final OpenEjbSystem openEjbSystem;
+    private final AppContext appContext;
+
+    public AppInfoGBean(@ParamAttribute(name = "appInfo")AppInfo appInfo,
+                        @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader,
+                        @ParamReference(name = "OpenEjbSystem") OpenEjbSystem openEjbSystem) throws NamingException, IOException, OpenEJBException {
+        this.appInfo = appInfo;
+        this.classLoader = classLoader;
+        this.openEjbSystem = openEjbSystem;
+        this.appContext = openEjbSystem.createApplication(appInfo, classLoader, false);
+
+    }
+
+    @Override
+    public void doStart() throws Exception {
+    }
+
+    @Override
+    public void doStop() {
+        try {
+            openEjbSystem.removeApplication(appInfo, classLoader);
+        } catch (NoSuchApplicationException e) {
+            log.error("Module does not exist.", e);
+        } catch (UndeployException e) {
+            List<Throwable> causes = e.getCauses();
+            log.error(e.getMessage() + ": Encountered " + causes.size() + " failures.");
+            for (Throwable throwable : causes) {
+                log.info(throwable.toString(), throwable);
+            }
+        }
+    }
+
+    @Override
+    public void doFail() {
+        doStop();
+    }
+
+    @Override
+    public WebBeansContext getOWBContext() {
+        return appContext.getWebBeansContext();
+    }
+
+    public List<BeanContext> getModuleBeanContexts(URI moduleURI) {
+        List<BeanContext> beanContexts = new ArrayList<BeanContext>();
+        for (BeanContext beanContext: appContext.getDeployments()) {
+            if (moduleURI.toString().equals(beanContext.getModuleID())) {
+                beanContexts.add(beanContext);
+            }
+        }
+        return beanContexts;
+    }
+
+    public EjbJarInfo getEjbJarInfo(URI moduleURI) {
+        return getEjbJarInfo(appInfo, moduleURI);
+    }
+
+    public static EjbJarInfo getEjbJarInfo(AppInfo appInfo, URI moduleURI) {
+        for (EjbJarInfo info: appInfo.ejbJars) {
+            if (moduleURI.equals(info.moduleUri)) {
+                return info;
+            }
+        }
+        //differing interpretation of standalone modules.  Openejb uses the module file name as moduleURI and geronimo uses an empty string.
+        if (appInfo.ejbJars.size() == 1 && moduleURI.toString().isEmpty()) {
+            return appInfo.ejbJars.get(0);
+        }
+        throw new IllegalStateException("No module named '" + moduleURI + "' found in appInfo " + appInfo);
+    }
+}

Propchange: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/AppInfoGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/AppInfoGBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/AppInfoGBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbModuleImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbModuleImpl.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbModuleImpl.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbModuleImpl.java Fri Jul 15 00:52:45 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.geronimo.openejb;
 
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -23,7 +24,6 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import javax.management.ObjectName;
 import javax.naming.NamingException;
@@ -43,13 +43,11 @@ import org.apache.geronimo.management.EJ
 import org.apache.geronimo.management.EJBModule;
 import org.apache.geronimo.management.J2EEApplication;
 import org.apache.geronimo.management.J2EEServer;
-import org.apache.geronimo.openejb.cdi.SharedOwbContext;
-import org.apache.openejb.AppContext;
 import org.apache.openejb.BeanContext;
-import org.apache.openejb.NoSuchApplicationException;
-import org.apache.openejb.UndeployException;
-import org.apache.openejb.assembler.classic.AppInfo;
-import org.apache.webbeans.config.WebBeansContext;
+import org.apache.openejb.Container;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.assembler.classic.EjbResolver;
+import org.apache.openejb.loader.SystemInstance;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,29 +56,31 @@ import org.slf4j.LoggerFactory;
  */
 
 @GBean(j2eeType = NameFactory.EJB_MODULE)
-public class EjbModuleImpl implements EJBModule, GBeanLifecycle, SharedOwbContext {
+public class EjbModuleImpl implements EJBModule, GBeanLifecycle {
     private static final Logger log = LoggerFactory.getLogger(EjbModuleImpl.class);
     private final J2EEServer server;
     private final J2EEApplication application;
     private final String deploymentDescriptor;
     private final String objectName;
+    private URI moduleURI;
     private final Map<String, EjbDeployment> ejbs = new HashMap<String, EjbDeployment>();
     private final ClassLoader classLoader;
 
     private final OpenEjbSystem openEjbSystem;
-    private final AppInfo appInfo;
-    private AppContext appContext;
+    private final AppInfoGBean appInfoGBean;
 
     public EjbModuleImpl(@ParamSpecial(type = SpecialAttributeType.objectName) String objectName,
                          @ParamReference(name = "J2EEServer", namingType = NameFactory.J2EE_SERVER) J2EEServer server,
                          @ParamReference(name = "J2EEApplication", namingType = NameFactory.J2EE_APPLICATION) J2EEApplication application,
+                         @ParamAttribute(name = "moduleURI") URI moduleURI,
                          @ParamAttribute(name = "deploymentDescriptor") String deploymentDescriptor,
                          @ParamAttribute(name = "isStandalone") boolean isStandalone,
                          @ParamReference(name = "EJBCollection") Collection<? extends EjbDeployment> ejbs,
                          @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader,
                          @ParamReference(name = "OpenEjbSystem") OpenEjbSystem openEjbSystem,
-                         @ParamAttribute(name = "ejbInfo") GeronimoEjbInfo ejbInfo) throws NamingException {
+                         @ParamReference(name = "AppInfo") AppInfoGBean appInfoGBean) throws NamingException {
         this.objectName = objectName;
+        this.moduleURI = moduleURI;
         ObjectName myObjectName = ObjectNameUtil.getObjectName(objectName);
         verifyObjectName(myObjectName);
 
@@ -106,10 +106,7 @@ public class EjbModuleImpl implements EJ
         this.classLoader = classLoader;
 
         this.openEjbSystem = openEjbSystem;
-        
-        this.appInfo = ejbInfo.createAppInfo();
-        
-        this.appInfo.standaloneModule = isStandalone;
+        this.appInfoGBean = appInfoGBean;
     }
     
     private void removeEjb(EjbDeployment ejb) {
@@ -174,38 +171,48 @@ public class EjbModuleImpl implements EJ
         return result;
     }
 
-    @Override
-    public WebBeansContext getOWBContext() {
-        if (appContext == null) {
-            throw new IllegalStateException("Not started");
-        }
-        return appContext.getWebBeansContext();
-    }
-
-    public Map<String, EjbDeployment> getEjbDeploymentMap() {
-        return ejbs;
-    }
-
-    public AppInfo getAppInfo() {
-        return appInfo;
-    }
-
-    public AppContext getAppContext() {
-        return appContext;
-    }
-
     public void doStart() throws Exception {
-        appContext = openEjbSystem.createApplication(appInfo, classLoader, false);
-//        for (String deploymentId: ejbs.keySet()) {
-//            BeanContext beanContext = openEjbSystem.getDeploymentInfo(deploymentId);
-//            GeronimoThreadContextListener.get().getEjbDeployment((BeanContext) beanContext);
-//        }
+        List<BeanContext> allDeployments = appInfoGBean.getModuleBeanContexts(moduleURI);
+        //start code from openejb assembler
+
+                // deploy
+                for (BeanContext deployment : allDeployments) {
+                    try {
+                        Container container = deployment.getContainer();
+                        container.deploy(deployment);
+                        log.info("createApplication.createdEjb" + deployment.getDeploymentID() + deployment.getEjbName() + container.getContainerID());
+                        if (log.isDebugEnabled()) {
+                            for (Map.Entry<Object, Object> entry : deployment.getProperties().entrySet()) {
+                                log.info("createApplication.createdEjb.property" + deployment.getEjbName() + entry.getKey() + entry.getValue());
+                            }
+                        }
+                    } catch (OpenEJBException e) {
+                        log.warn("Apparent double start of ejb?? ", e);
+                    } catch (Throwable t) {
+                        throw new OpenEJBException("Error deploying '"+deployment.getEjbName()+"'.  Exception: "+t.getClass()+": "+t.getMessage(), t);
+                    }
+                }
+
+                // start
+                for (BeanContext deployment : allDeployments) {
+                    try {
+                        Container container = deployment.getContainer();
+                        container.start(deployment);
+                        log.info("createApplication.startedEjb" + deployment.getDeploymentID() + deployment.getEjbName() + container.getContainerID());
+                    } catch (Throwable t) {
+                        throw new OpenEJBException("Error starting '"+deployment.getEjbName()+"'.  Exception: "+t.getClass()+": "+t.getMessage(), t);
+                    }
+                }
+        EjbResolver globalEjbResolver = SystemInstance.get().getComponent(EjbResolver.class);
+        globalEjbResolver.add(appInfoGBean.getEjbJarInfo(moduleURI));
+
+        for (String deploymentId: ejbs.keySet()) {
+            BeanContext beanContext = openEjbSystem.getDeploymentInfo(deploymentId);
+            GeronimoThreadContextListener.get().getEjbDeployment(beanContext);
+        }
     }
 
     public void doStop() {
-        try {
-            openEjbSystem.removeApplication(appInfo, classLoader);
-            
             Iterator<EjbDeployment> it= ejbs.values().iterator();
             while(it.hasNext())
             {
@@ -213,15 +220,6 @@ public class EjbModuleImpl implements EJ
                 it.remove();
             }
 
-        } catch (NoSuchApplicationException e) {
-            log.error("Module does not exist.", e);
-        } catch (UndeployException e) {
-            List<Throwable> causes = e.getCauses();
-            log.error(e.getMessage() + ": Encountered " + causes.size() + " failures.");
-            for (Throwable throwable : causes) {
-                log.info(throwable.toString(), throwable);
-            }
-        }
     }
 
     public void doFail() {

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/OpenWebBeansWebInitializer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/OpenWebBeansWebInitializer.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/OpenWebBeansWebInitializer.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/OpenWebBeansWebInitializer.java Fri Jul 15 00:52:45 2011
@@ -80,32 +80,42 @@ public class OpenWebBeansWebInitializer 
         //must be last since it idiotically copies stuff
         OpenEJBLifecycle lifecycle = new OpenEJBLifecycle(webBeansContext);
         webBeansContext.registerService(ContainerLifecycle.class, lifecycle);
-        if (startup != null) {
-            GeronimoSingletonService.contextEntered(webBeansContext);
-            try {
-                //from OWB's WebBeansConfigurationListener
 
-                try {
-                    if (startup instanceof ServletContext) {
-                        StartupObject startupObject = new StartupObject(new AppContext("none", SystemInstance.get(), Thread.currentThread().getContextClassLoader(), null, null, true), new AppInfo(), Collections.<BeanContext>emptyList());
-                        lifecycle.startApplication(startupObject);
-                        lifecycle.startServletContext((ServletContext)startup);
-                    } else if (startup instanceof StartupObject) {
-                        lifecycle.startApplication(startup);
+        WebBeansContext oldContext = GeronimoSingletonService.contextEntered(webBeansContext);
+        try {
+            //from OWB's WebBeansConfigurationListener
+
+            try {
+                if (startup == null) {
+                    //this should only be used for servlet tests
+                    StartupObject startupObject = new StartupObject(new AppContext("none", SystemInstance.get(), Thread.currentThread().getContextClassLoader(), null, null, true), new AppInfo(), Collections.<BeanContext>emptyList());
+                    lifecycle.startApplication(startupObject);
+//                        lifecycle.startServletContext((ServletContext)startup);
+                } else if (startup instanceof StartupObject) {
+                    lifecycle.startApplication(startup);
 //                        ((StartupObject)startup).getAppContext().setWebBeansContext(webBeansContext);
-                    }
-                } catch (Exception e) {
-                    //             logger.error(OWBLogConst.ERROR_0018, event.getServletContext().getContextPath());
-                    WebBeansUtil.throwRuntimeExceptions(e);
                 }
-
-            } finally {
-                GeronimoSingletonService.contextExited(null);
+            } catch (Exception e) {
+                //             logger.error(OWBLogConst.ERROR_0018, event.getServletContext().getContextPath());
+                WebBeansUtil.throwRuntimeExceptions(e);
             }
+
+        } finally {
+            GeronimoSingletonService.contextExited(oldContext);
         }
         return webBeansContext;
     }
 
+    public static void initializeServletContext(WebBeansContext webBeansContext, ServletContext servletContext) {
+        WebBeansContext oldContext = GeronimoSingletonService.contextEntered(webBeansContext);
+        try {
+            OpenEJBLifecycle lifecycle = (OpenEJBLifecycle) webBeansContext.getService(ContainerLifecycle.class);
+            lifecycle.startServletContext(servletContext);
+        } finally {
+            GeronimoSingletonService.contextExited(oldContext);
+        }
+    }
+
 //    public OpenWebBeansWebInitializer(WebBeansContext webBeansContext, ServletContext servletContext) {
 //        GeronimoSingletonService.contextEntered(webBeansContext);
 //

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/ThreadSingletonServiceAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/ThreadSingletonServiceAdapter.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/ThreadSingletonServiceAdapter.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/ThreadSingletonServiceAdapter.java Fri Jul 15 00:52:45 2011
@@ -75,6 +75,7 @@ public class ThreadSingletonServiceAdapt
             contextExited(old);
         }
     }
+
     @Override
     public Object contextEntered(WebBeansContext owbContext) {
         return GeronimoSingletonService.contextEntered(owbContext);

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Fri Jul 15 00:52:45 2011
@@ -30,11 +30,8 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.jar.JarFile;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import javax.servlet.Servlet;
-import javax.xml.bind.JAXBException;
 
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.Deployable;
@@ -73,10 +70,6 @@ import org.apache.geronimo.kernel.util.J
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
-import org.apache.geronimo.openejb.cdi.SharedOwbContext;
-import org.apache.geronimo.schema.ElementConverter;
-import org.apache.geronimo.schema.NamespaceElementConverter;
-import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl;
 import org.apache.geronimo.security.jaas.ConfigurationFactory;
 import org.apache.geronimo.tomcat.LifecycleListenerGBean;
@@ -714,13 +707,8 @@ public class TomcatModuleBuilder extends
 //                }
 //            }
             //This shares a single OWB context for the whole ear
-            Module<?,?> m = module;
-            while (m.getParentModule() != null) {
-                m = m.getParentModule();
-            }
-            if (m.getSharedContext().get(SharedOwbContext.class) != null) {
-                GBeanData data = (GBeanData) m.getSharedContext().get(SharedOwbContext.class);
-                AbstractName name = data.getAbstractName();
+            AbstractName name = EARContext.APPINFO_GBEAN_NAME_KEY.get(earContext.getGeneralData());
+            if (name != null) {
                 webModuleData.setReferencePattern("SharedOwbContext", name);
             }
 

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=1146934&r1=1146933&r2=1146934&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java Fri Jul 15 00:52:45 2011
@@ -245,8 +245,10 @@ public class GeronimoStandardContext ext
 
         WebBeansContext owbContext = ctx.getOWBContext();
         if (owbContext == null) {
-            owbContext = OpenWebBeansWebInitializer.newWebBeansContext(servletContext);
+            //hopefully for tests only
+            owbContext = OpenWebBeansWebInitializer.newWebBeansContext(null);
         }
+        OpenWebBeansWebInitializer.initializeServletContext(owbContext, servletContext);
         if (getInstanceManager() instanceof TomcatInstanceManager) {
             ((TomcatInstanceManager) getInstanceManager()).setOWBContext(owbContext);
         }



Mime
View raw message