geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1196032 [1/2] - in /geronimo/server/trunk: ./ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/ plugins/j2ee/geronimo-j2ee/ plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/ plugin...
Date Tue, 01 Nov 2011 14:49:31 GMT
Author: xuhaihong
Date: Tue Nov  1 14:49:29 2011
New Revision: 1196032

URL: http://svn.apache.org/viewvc?rev=1196032&view=rev
Log:
GERONIMO-6204 Decouple OpenWebBeans from web container

Added:
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationName.java
      - copied, changed from r1195653, geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleEvent.java
      - copied, changed from r1195653, geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleListener.java
      - copied, changed from r1195653, geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansHolderInterceptor.java
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansSystemInitializer.java
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebAppContext.java
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebModuleListener.java
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/WebApplicationNameBasedSingletonService.java
      - copied, changed from r1195653, geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/WebBeansConfigurationListener.java
      - copied, changed from r1195653, geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/WebBeansConfigurationListener.java
Removed:
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/WebBeansConfigurationListener.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/interceptor/OWBBeforeAfter.java
Modified:
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/pom.xml
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationConstants.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
    geronimo/server/trunk/plugins/jetty8/jetty8-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoFactoryFinderProvider.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/GeronimoSingletonService.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/openwebbeans/geronimo-openwebbeans-builder/pom.xml
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/main/java/org/apache/geronimo/openwebbeans/deployment/OpenWebBeansModuleBuilderExtension.java
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/test/java/org/apache/geronimo/openwebbeans/deployment/BasicTest.java
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml
    geronimo/server/trunk/plugins/openwebbeans/openwebbeans-deployer/pom.xml
    geronimo/server/trunk/plugins/openwebbeans/openwebbeans-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/openwebbeans/openwebbeans/pom.xml
    geronimo/server/trunk/plugins/openwebbeans/openwebbeans/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/openwebbeans/pom.xml
    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/pom.xml
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatEJBWebServiceContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/interceptor/WebApplicationIdentityBeforeAfter.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
    geronimo/server/trunk/plugins/tomcat/tomcat7/pom.xml
    geronimo/server/trunk/plugins/wink/geronimo-wink-builder/src/main/java/org/apache/geronimo/wink/deployment/WinkModuleBuilderExtension.java
    geronimo/server/trunk/pom.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java Tue Nov  1 14:49:29 2011
@@ -59,7 +59,7 @@ public final class JarUtils {
     private static final boolean jarUrlRewrite;
     static {
         //Why not always set this with true ? Online deployer also lock the jar files
-        jarUrlRewrite = new Boolean(System.getProperty("org.apache.geronimo.kernel.util.JarUtils.jarUrlRewrite", "true"));
+        jarUrlRewrite = Boolean.valueOf(System.getProperty("org.apache.geronimo.kernel.util.JarUtils.jarUrlRewrite", "true"));
         try {
             DUMMY_JAR_FILE = FileUtils.createTempFile(false);
             new JarOutputStream(new FileOutputStream(JarUtils.DUMMY_JAR_FILE), new Manifest()).close();

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/pom.xml?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/pom.xml (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/pom.xml Tue Nov  1 14:49:29 2011
@@ -68,21 +68,6 @@
             <groupId>org.apache.geronimo.components</groupId>
             <artifactId>geronimo-transaction</artifactId>
         </dependency>
-
-        <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-impl</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-spi</artifactId>
-        </dependency>
-        <!--TODO can this be optional? -->
-        <dependency>
-            <groupId>org.apache.geronimo.bundles</groupId>
-            <artifactId>scannotation</artifactId>
-        </dependency>
         
         <dependency>
             <groupId>org.apache.servicemix.bundles</groupId>

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java Tue Nov  1 14:49:29 2011
@@ -17,7 +17,6 @@
  * under the License.
  */
 
-
 package org.apache.geronimo.j2ee.annotation;
 
 import java.io.Serializable;
@@ -29,11 +28,11 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
 
-import org.apache.webbeans.inject.OWBInjector;
 import org.apache.xbean.recipe.ConstructionException;
 import org.apache.xbean.recipe.ObjectRecipe;
 import org.apache.xbean.recipe.Option;
@@ -44,14 +43,19 @@ import org.slf4j.LoggerFactory;
  * @version $Rev$ $Date$
  */
 public class Holder implements Serializable {
+
     private static final Logger log = LoggerFactory.getLogger(Holder.class);
+
     public static final Holder EMPTY = new Holder() {
     };
 
     private Map<String, Set<Injection>> injectionMap;
+
     private Map<String, LifecycleMethod> postConstruct;
+
     private Map<String, LifecycleMethod> preDestroy;
 
+    private List<Interceptor> interceptors = new CopyOnWriteArrayList<Interceptor>();
 
     public Holder() {
     }
@@ -150,9 +154,7 @@ public class Holder implements Serializa
     }
 
     public boolean isEmpty() {
-        return (injectionMap == null || injectionMap.isEmpty())
-                && (postConstruct == null || postConstruct.isEmpty())
-                && (preDestroy == null || preDestroy.isEmpty());
+        return (injectionMap == null || injectionMap.isEmpty()) && (postConstruct == null || postConstruct.isEmpty()) && (preDestroy == null || preDestroy.isEmpty());
     }
 
     public Object newInstance(String className, ClassLoader classLoader, Context context) throws IllegalAccessException, InstantiationException {
@@ -163,7 +165,7 @@ public class Holder implements Serializa
         try {
             clazz = classLoader.loadClass(className);
         } catch (ClassNotFoundException e) {
-            throw (InstantiationException)new InstantiationException("Can't load class " + className + " in classloader: " + classLoader).initCause(e);
+            throw (InstantiationException) new InstantiationException("Can't load class " + className + " in classloader: " + classLoader).initCause(e);
         }
         List<NamingException> problems = new ArrayList<NamingException>();
         while (clazz != Object.class) {
@@ -177,14 +179,15 @@ public class Holder implements Serializa
         try {
             result = objectRecipe.create(classLoader);
         } catch (ConstructionException e) {
-            throw (InstantiationException)new InstantiationException("Could not construct object").initCause(e);
+            throw (InstantiationException) new InstantiationException("Could not construct object").initCause(e);
         }
-        // TODO we likely don't want to create a new one each time -- investigate the destroy() method
-        OWBInjector beanInjector = new OWBInjector();
+        InvocationContext invocationContext = new InvocationContext(context, result);
         try {
-            beanInjector.inject(result);
-        } catch (Exception e) {
-            throw (InstantiationException)new InstantiationException("web beans injection problem").initCause(e);
+            for (Interceptor interceptor : interceptors) {
+                interceptor.instancerCreated(invocationContext);
+            }
+        } catch (InterceptorException e) {
+            throw (InstantiationException) new InstantiationException("Interceptor invocation failed").initCause(e);
         }
 
         if (getPostConstruct() != null) {
@@ -245,4 +248,57 @@ public class Holder implements Serializa
         }
     }
 
+    public boolean addInterceptor(Interceptor interceptor) {
+        return interceptors.add(interceptor);
+    }
+
+    public boolean removeInterceptor(Interceptor interceptor) {
+        return interceptors.remove(interceptor);
+    }
+
+    public static interface Interceptor {
+
+        public void instancerCreated(InvocationContext context) throws InterceptorException;
+
+        public void instanceDestoryed(InvocationContext context) throws InterceptorException;
+
+        public void postConstructInvoked(InvocationContext context) throws InterceptorException;
+    }
+
+    public static class InterceptorException extends Exception {
+
+        public InterceptorException(Throwable cause) {
+            super(cause);
+        }
+
+        public InterceptorException(String message) {
+            super(message);
+        }
+
+        public InterceptorException(String message, Throwable cause) {
+            super(message, cause);
+        }
+
+    }
+
+    public static class InvocationContext {
+
+        private final Context context;
+
+        private final Object instance;
+
+        public InvocationContext(Context context, Object instance) {
+            this.context = context;
+            this.instance = instance;
+        }
+
+        public Context getContext() {
+            return context;
+
+        }
+
+        public Object getInstance() {
+            return instance;
+        }
+    }
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationConstants.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationConstants.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationConstants.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationConstants.java Tue Nov  1 14:49:29 2011
@@ -33,12 +33,14 @@ public class WebApplicationConstants {
     public static final String WEB_APP_INFO = "WEB_APP_INFO";
 
     public static final String WEB_APP_NAME = "WEB_APP_NAME";
-    
+
     public static final String WEB_APPLICATION_STAGE = "org.apache.geronimo.webapplication.stage";
-    
+
     public static final String WEB_APPLICATION_PRODUCTION_STAGE = "PRODUCTION";
-    
+
     public static final String WEB_APPLICATION_DEVELOPMENT_STAGE = "DEVELOPMENT";
-    
+
     public static final String WEB_APPLICATION_GET_REAL_PATH_SUPPORT = "org.apache.geronimo.webapplication.getrealpath.support";
+
+    public static final String WEB_MODULE_LISTENERS = "org.apache.geronimo.webapplication.web_modue_listeners";
 }

Copied: geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationName.java (from r1195653, geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationName.java?p2=geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationName.java&p1=geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java&r1=1195653&r2=1196032&rev=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationName.java Tue Nov  1 14:49:29 2011
@@ -20,15 +20,15 @@ package org.apache.geronimo.web;
 /**
  * @version $Rev$ $Date$
  */
-public class WebApplicationIdentity {
+public class WebApplicationName {
 
-    private static ThreadLocal<String> IDENTITY = new ThreadLocal<String>();
+    private static ThreadLocal<String> NAME = new ThreadLocal<String>();
 
-    public static void setIdentity(String identity) {
-        IDENTITY.set(identity);
+    public static void setName(String name) {
+        NAME.set(name);
     }
 
-    public static String getIdentity() {
-        return IDENTITY.get();
+    public static String getName() {
+        return NAME.get();
     }
 }

Copied: geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleEvent.java (from r1195653, geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleEvent.java?p2=geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleEvent.java&p1=geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java&r1=1195653&r2=1196032&rev=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleEvent.java Tue Nov  1 14:49:29 2011
@@ -17,18 +17,23 @@
 
 package org.apache.geronimo.web;
 
+import javax.servlet.ServletContext;
+
+import org.apache.geronimo.management.geronimo.WebModule;
+
 /**
  * @version $Rev$ $Date$
  */
-public class WebApplicationIdentity {
+public class WebModuleEvent extends java.util.EventObject {
 
-    private static ThreadLocal<String> IDENTITY = new ThreadLocal<String>();
+    private final ServletContext servletContext;
 
-    public static void setIdentity(String identity) {
-        IDENTITY.set(identity);
+    public WebModuleEvent(WebModule module, ServletContext servletContext) {
+        super(module);
+        this.servletContext = servletContext;
     }
 
-    public static String getIdentity() {
-        return IDENTITY.get();
+    public ServletContext getServletContext() {
+        return servletContext;
     }
 }

Copied: geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleListener.java (from r1195653, geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleListener.java?p2=geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleListener.java&p1=geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java&r1=1195653&r2=1196032&rev=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebApplicationIdentity.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web/src/main/java/org/apache/geronimo/web/WebModuleListener.java Tue Nov  1 14:49:29 2011
@@ -17,18 +17,28 @@
 
 package org.apache.geronimo.web;
 
+import javax.servlet.ServletContext;
+
 /**
+ * ServletContextListener is good choice for those components, which are required to be initialized in the starting process of
+ * the target applications. While it sometimes brings issues, e.g. those codes in other ServletContextListener hopes to do
+ * something, and order of the listeners may be undefined.
+ *
  * @version $Rev$ $Date$
  */
-public class WebApplicationIdentity {
+public interface WebModuleListener {
 
-    private static ThreadLocal<String> IDENTITY = new ThreadLocal<String>();
+    /**
+     * This method will be invoked before all Java EE supported components are initialized
+     * @param module
+     * @param context
+     */
+    public void moduleInitialized(ServletContext servletContext);
 
-    public static void setIdentity(String identity) {
-        IDENTITY.set(identity);
-    }
+    /**
+     * This method will be invoked after all Java EE supported components are destroyed
+     * @param event
+     */
+    public void moduleDestoryed(ServletContext servletContext);
 
-    public static String getIdentity() {
-        return IDENTITY.get();
-    }
 }

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java Tue Nov  1 14:49:29 2011
@@ -25,7 +25,6 @@ import java.net.URL;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.jar.JarFile;
 
@@ -73,7 +72,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;
@@ -517,14 +515,14 @@ public class JettyModuleBuilder extends 
                 webModuleData.setAttribute("compactPath", Boolean.TRUE);
             }
 
-            LinkedHashSet<Module<?, ?>> submodules = module.getModules();
+            /*LinkedHashSet<Module<?, ?>> submodules = module.getModules();
             for (Module<?, ?> subModule: submodules) {
                 if (subModule.getSharedContext().get(SharedOwbContext.class) != null) {
                     GBeanData data = (GBeanData) subModule.getSharedContext().get(SharedOwbContext.class);
                     AbstractName name = data.getAbstractName();
                     webModuleData.setReferencePattern("SharedOwbContext", name);
                 }
-            }
+            }*/
             //Save Deployment Attributes
             Map<String, Object> deploymentAttributes = new HashMap<String, Object>();
             deploymentAttributes.put(WebApplicationConstants.META_COMPLETE, webApp.isMetadataComplete());

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/pom.xml Tue Nov  1 14:49:29 2011
@@ -61,12 +61,6 @@
             <artifactId>geronimo-web</artifactId>
             <version>${project.version}</version>
         </dependency>
-        
-        <dependency>
-            <groupId>org.apache.geronimo.modules</groupId>
-            <artifactId>geronimo-openejb</artifactId>
-            <version>${project.version}</version>
-        </dependency>
 
         <dependency>
             <groupId>org.apache.openwebbeans</groupId>

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=1196032&r1=1196031&r2=1196032&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 Tue Nov  1 14:49:29 2011
@@ -17,10 +17,12 @@
 
 package org.apache.geronimo.jetty8;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -54,15 +56,12 @@ import org.apache.geronimo.management.J2
 import org.apache.geronimo.management.J2EEServer;
 import org.apache.geronimo.management.geronimo.WebContainer;
 import org.apache.geronimo.management.geronimo.WebModule;
-import org.apache.geronimo.openejb.cdi.OpenWebBeansWebInitializer;
-import org.apache.geronimo.openejb.cdi.SharedOwbContext;
 import org.apache.geronimo.security.jacc.ApplicationPolicyConfigurationManager;
 import org.apache.geronimo.security.jacc.RunAsSource;
 import org.apache.geronimo.transaction.GeronimoUserTransaction;
 import org.apache.geronimo.web.WebApplicationConstants;
 import org.apache.geronimo.web.info.ErrorPageInfo;
 import org.apache.geronimo.web.info.WebAppInfo;
-import org.apache.webbeans.config.WebBeansContext;
 import org.eclipse.jetty.http.MimeTypes;
 import org.eclipse.jetty.security.SecurityHandler;
 import org.eclipse.jetty.server.SessionManager;
@@ -136,7 +135,6 @@ public class WebAppContextWrapper implem
                                 @ParamReference(name = "J2EEApplication") J2EEApplication application,
                                 @ParamReference(name = "ContextSource") ContextSource contextSource,
                                 @ParamReference(name = "TransactionManager") TransactionManager transactionManager,
-                                @ParamReference(name = "SharedOwbContext") SharedOwbContext sharedOwbContext,
 
                                 @ParamAttribute(name = "deploymentAttributes") Map<String, Object> deploymentAttributes
     ) throws Exception {
@@ -222,8 +220,9 @@ public class WebAppContextWrapper implem
             }
         }
 
-        IntegrationContext integrationContext = new IntegrationContext(componentContext, unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction, bundle, holder, servletContainerInitializerMap, abName.toString());
-        webAppContext = new GeronimoWebAppContext(securityHandler, sessionHandler, servletHandler, null, integrationContext, classLoader, modulePath, webAppInfo, policyContextID, applicationPolicyConfigurationManager);
+        IntegrationContext integrationContext = new IntegrationContext(componentContext, unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction, bundle, holder, servletContainerInitializerMap, abName.getNameProperty(NameFactory.J2EE_NAME));
+        List<String> webModuleListenerClassNames = (List<String>) deploymentAttributes.get(WebApplicationConstants.WEB_MODULE_LISTENERS);
+        webAppContext = new GeronimoWebAppContext(securityHandler, sessionHandler, servletHandler, null, integrationContext, classLoader, modulePath, webAppInfo, policyContextID, applicationPolicyConfigurationManager,  webModuleListenerClassNames == null ? Collections.<String>emptyList() : webModuleListenerClassNames);
         webAppContext.setContextPath(contextPath);
         //See Jetty-386.  Setting this to true can expose secured content.
         webAppContext.setCompactPath(compactPath);
@@ -303,24 +302,8 @@ public class WebAppContextWrapper implem
         }
         //supply web.xml to jasper
         webAppContext.setAttribute(JASPER_WEB_XML_NAME, originalSpecDD);
-        WebBeansContext webBeansContext;
-        if (sharedOwbContext == null) {
-            webBeansContext = OpenWebBeansWebInitializer.newWebBeansContext(null);
-        } else {
-            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);
     }
 
-
     public String getObjectName() {
         return objectName;
     }

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java Tue Nov  1 14:49:29 2011
@@ -23,11 +23,13 @@ package org.apache.geronimo.jetty8.handl
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.EventListener;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -50,12 +52,12 @@ import org.apache.geronimo.osgi.web.WebA
 import org.apache.geronimo.security.jacc.ApplicationPolicyConfigurationManager;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
 import org.apache.geronimo.web.WebApplicationConstants;
-import org.apache.geronimo.web.WebApplicationIdentity;
+import org.apache.geronimo.web.WebApplicationName;
+import org.apache.geronimo.web.WebModuleListener;
 import org.apache.geronimo.web.assembler.Assembler;
 import org.apache.geronimo.web.info.WebAppInfo;
 import org.apache.geronimo.web.security.SpecSecurityBuilder;
 import org.apache.geronimo.web.security.WebSecurityConstraintStore;
-import org.apache.webbeans.config.WebBeansContext;
 import org.apache.xbean.osgi.bundle.util.BundleUtils;
 import org.eclipse.jetty.security.SecurityHandler;
 import org.eclipse.jetty.server.Request;
@@ -71,12 +73,16 @@ import org.eclipse.jetty.webapp.WebAppCo
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @version $Rev$ $Date$
  */
 public class GeronimoWebAppContext extends WebAppContext {
 
+    private static final Logger logger = LoggerFactory.getLogger(GeronimoWebAppContext.class);
+
     private final IntegrationContext integrationContext;
     private final String modulePath;
     private final ClassLoader classLoader;
@@ -87,6 +93,7 @@ public class GeronimoWebAppContext exten
     private ServiceRegistration serviceRegistration;
     boolean fullyStarted = false;
     private String webModuleName;
+    private final List webModuleListeners;
 
     public GeronimoWebAppContext(SecurityHandler securityHandler,
                                  SessionHandler sessionHandler,
@@ -95,7 +102,10 @@ public class GeronimoWebAppContext exten
                                  IntegrationContext integrationContext,
                                  ClassLoader classLoader,
                                  String modulePath,
-                                 WebAppInfo webAppInfo, String policyContextId, ApplicationPolicyConfigurationManager applicationPolicyConfigurationManager) {
+                                 WebAppInfo webAppInfo,
+                                 String policyContextId,
+                                 ApplicationPolicyConfigurationManager applicationPolicyConfigurationManager,
+                                 List<String> webModuleListenerClassNames) {
         super(sessionHandler, securityHandler, servletHandler, errorHandler);
         _scontext = new Context();
         this.integrationContext = integrationContext;
@@ -130,6 +140,24 @@ public class GeronimoWebAppContext exten
         boolean annotationScanRequired = true;
         webSecurityConstraintStore = new WebSecurityConstraintStore(webAppInfo, integrationContext.getBundle(), annotationScanRequired, _scontext);
 
+        if (webModuleListenerClassNames != null && webModuleListenerClassNames.size() > 0) {
+            webModuleListeners = new ArrayList(webModuleListenerClassNames.size());
+            for (String webModuleListenerClassName : webModuleListenerClassNames) {
+                try {
+                    Class<?> cls = classLoader.loadClass(webModuleListenerClassName);
+                    Object webModuleListener = cls.newInstance();
+                    webModuleListeners.add(webModuleListener);
+                } catch (ClassNotFoundException e) {
+                    logger.warn("Unable to load the listener class" + webModuleListenerClassName, e);
+                } catch (InstantiationException e) {
+                    logger.warn("Unable to create the listener instance " + webModuleListenerClassName, e);
+                } catch (IllegalAccessException e) {
+                    logger.warn("Unable to create the listener instance " + webModuleListenerClassName, e);
+                }
+            }
+        } else {
+            webModuleListeners = Collections.emptyList();
+        }
     }
 
     public void setWebModuleName(String webModuleName) {
@@ -156,9 +184,17 @@ public class GeronimoWebAppContext exten
         boolean txActive = integrationContext.isTxActive();
         SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);
         ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(null, newContext);
-        WebBeansContext oldOwbContext = integrationContext.contextEntered();
+        String oldApplicationName = WebApplicationName.getName();
+        WebApplicationName.setName(integrationContext.getWebApplicationIdentity());
         try {
             setRestrictListeners(false);
+            for (Object webModuleListener : webModuleListeners) {
+                if (webModuleListener instanceof WebModuleListener) {
+                    ((WebModuleListener) webModuleListener).moduleInitialized(getServletContext());
+                } else {
+                    logger.warn("Invalid WebModuleListener " + webModuleListener.getClass().getName());
+                }
+            }
             try {
                 Assembler assembler = new Assembler();
                 assembler.assemble(getServletContext(), webAppInfo);
@@ -202,9 +238,9 @@ public class GeronimoWebAppContext exten
                 integrationContext.restoreConnectorContext(connectorContext, null, newContext);
             }
         } finally {
-            integrationContext.contextExited(oldOwbContext);
             integrationContext.restoreContext(context);
             integrationContext.completeTx(txActive, null);
+            WebApplicationName.setName(oldApplicationName);
         }
     }
 
@@ -214,15 +250,25 @@ public class GeronimoWebAppContext exten
         boolean txActive = integrationContext.isTxActive();
         SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);
         ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(null, newContext);
+        String oldApplicationName = WebApplicationName.getName();
+        WebApplicationName.setName(integrationContext.getWebApplicationIdentity());
         try {
             try {
                 super.doStop();
             } finally {
                 integrationContext.restoreConnectorContext(connectorContext, null, newContext);
             }
+            for (Object webModuleListener : webModuleListeners) {
+                if (webModuleListener instanceof WebModuleListener) {
+                    ((WebModuleListener) webModuleListener).moduleDestoryed(getServletContext());
+                } else {
+                    logger.warn("Invalid WebModuleListener " + webModuleListener.getClass().getName());
+                }
+            }
         } finally {
             integrationContext.restoreContext(context);
             integrationContext.completeTx(txActive, null);
+            WebApplicationName.setName(oldApplicationName);
         }
     }
 
@@ -232,9 +278,8 @@ public class GeronimoWebAppContext exten
         boolean txActive = integrationContext.isTxActive();
         SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(baseRequest);
         ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(baseRequest, newContext);
-        WebBeansContext owbContext = integrationContext.contextEntered();
-        String oldApplicationIdentity = WebApplicationIdentity.getIdentity();
-        WebApplicationIdentity.setIdentity(integrationContext.getWebApplicationIdentity());
+        String oldApplicationName = WebApplicationName.getName();
+        WebApplicationName.setName(integrationContext.getWebApplicationIdentity());
         try {
             try {
                 super.doScope(target, baseRequest, request, response);
@@ -242,10 +287,9 @@ public class GeronimoWebAppContext exten
                 integrationContext.restoreConnectorContext(connectorContext, baseRequest, newContext);
             }
         } finally {
-            integrationContext.contextExited(owbContext);
             integrationContext.restoreContext(context);
             integrationContext.completeTx(txActive, baseRequest);
-            WebApplicationIdentity.setIdentity(oldApplicationIdentity);
+            WebApplicationName.setName(oldApplicationName);
         }
     }
 

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java Tue Nov  1 14:49:29 2011
@@ -37,8 +37,6 @@ import org.apache.geronimo.connector.out
 import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.naming.java.RootContext;
-import org.apache.geronimo.openejb.cdi.GeronimoSingletonService;
-import org.apache.webbeans.config.WebBeansContext;
 import org.eclipse.jetty.server.Request;
 import org.osgi.framework.Bundle;
 
@@ -56,7 +54,6 @@ public class IntegrationContext {
     private final Holder holder;
     private final Map<ServletContainerInitializer, Set<Class<?>>> servletContainerInitializerMap;
     private final String webApplicationIdentity;
-    private WebBeansContext owbContext;
 
     public IntegrationContext(Context componentContext, Set<String> unshareableResources, Set<String> applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator, UserTransaction userTransaction, Bundle bundle, Holder holder, Map<ServletContainerInitializer, Set<Class<?>>> servletContainerInitializerMap, String webApplicationIdentity) {
         this.componentContext = componentContext;
@@ -180,21 +177,4 @@ public class IntegrationContext {
     public Map<ServletContainerInitializer, Set<Class<?>>> getServletContainerInitializerMap() {
         return servletContainerInitializerMap;
     }
-
-
-    public WebBeansContext contextEntered() {
-        return GeronimoSingletonService.contextEntered(owbContext);
-    }
-
-    public void contextExited(WebBeansContext oldOWBContext) {
-        GeronimoSingletonService.contextExited(oldOWBContext);
-    }
-
-    public void setOwbContext(WebBeansContext owbContext) {
-        this.owbContext = owbContext;
-    }
-
-    public WebBeansContext getOWBContext() {
-        return owbContext;
-    }
 }

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java Tue Nov  1 14:49:29 2011
@@ -70,7 +70,6 @@ import org.apache.geronimo.transaction.m
 import org.apache.geronimo.web.WebApplicationConstants;
 import org.apache.geronimo.web.info.ServletInfo;
 import org.apache.geronimo.web.info.WebAppInfo;
-import org.apache.webbeans.config.WebBeansFinder;
 import org.eclipse.jetty.security.Authenticator;
 import org.eclipse.jetty.security.IdentityService;
 import org.eclipse.jetty.security.LoginService;
@@ -117,7 +116,6 @@ public class AbstractWebModuleTest exten
     }
 
     protected WebAppContextWrapper setUpAppContext(String securityRealmName, SecurityHandlerFactory securityHandlerFactory, String policyContextId, RunAsSource runAsSource, String uriString, WebAppInfo webAppInfo) throws Exception {
-        WebBeansFinder.clearInstances(getClass().getClassLoader());
         ApplicationPolicyConfigurationManager applicationPolicyConfigurationManager = null;
         //Setup default JSP Factory
         Class.forName("org.apache.jasper.compiler.JspRuntimeContext");
@@ -187,7 +185,6 @@ public class AbstractWebModuleTest exten
                 null,
                 contextSource,
                 transactionManager,
-                null,
                 deploymentAttributes
         );
         app.doStart();

Modified: geronimo/server/trunk/plugins/jetty8/jetty8-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/jetty8-deployer/src/main/plan/plan.xml?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/jetty8-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/jetty8/jetty8-deployer/src/main/plan/plan.xml Tue Nov  1 14:49:29 2011
@@ -922,7 +922,6 @@
                         <type>car</type>
                     </dependency>
                 </dependencies>
-                <import-package>org.apache.webbeans.config</import-package>                
             </environment>
         </xml-attribute>
     </gbean>

Modified: geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml (original)
+++ geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml Tue Nov  1 14:49:29 2011
@@ -71,12 +71,12 @@
             <version>${project.version}</version>
         </dependency>
 
-        <dependency>
+        <!--dependency>
             <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>openejb</artifactId>
             <version>${project.version}</version>
             <type>car</type>
-        </dependency>
+        </dependency-->
 
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoFactoryFinderProvider.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoFactoryFinderProvider.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoFactoryFinderProvider.java (original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoFactoryFinderProvider.java Tue Nov  1 14:49:29 2011
@@ -41,7 +41,7 @@ import javax.faces.render.RenderKitFacto
 import javax.faces.view.ViewDeclarationLanguageFactory;
 import javax.faces.view.facelets.TagHandlerDelegateFactory;
 
-import org.apache.geronimo.web.WebApplicationIdentity;
+import org.apache.geronimo.web.WebApplicationName;
 import org.apache.myfaces.spi.FactoryFinderProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -54,7 +54,7 @@ import org.slf4j.LoggerFactory;
  */
 
 public class GeronimoFactoryFinderProvider implements FactoryFinderProvider {
-    
+
     private static final Logger logger = LoggerFactory.getLogger(GeronimoFactoryFinderProvider.class);
 
     public static final String APPLICATION_FACTORY = "javax.faces.application.ApplicationFactory";
@@ -148,13 +148,13 @@ public class GeronimoFactoryFinderProvid
         Map<String, List<String>> factoryClassNames = null;
         Map<String, Object> factoryMap = null;
 
-        String webApplicationIdentity = WebApplicationIdentity.getIdentity();
-        if(webApplicationIdentity == null) {
+        String webApplicationName = WebApplicationName.getName();
+        if(webApplicationName == null) {
             throw new IllegalStateException("No web identity is attached to current request thread " + Thread.currentThread().getName());
         }
 
         synchronized (_registeredFactoryNames) {
-            factoryClassNames = _registeredFactoryNames.get(webApplicationIdentity);
+            factoryClassNames = _registeredFactoryNames.get(webApplicationName);
 
             if (factoryClassNames == null) {
                 String message = "No Factories configured for this Application. This happens if the faces-initialization "
@@ -170,11 +170,11 @@ public class GeronimoFactoryFinderProvid
                 throw new IllegalArgumentException("no factory " + factoryName + " configured for this application.");
             }
 
-            factoryMap = _factories.get(webApplicationIdentity);
+            factoryMap = _factories.get(webApplicationName);
 
             if (factoryMap == null) {
                 factoryMap = new HashMap<String, Object>();
-                _factories.put(webApplicationIdentity, factoryMap);
+                _factories.put(webApplicationName, factoryMap);
             }
         }
 
@@ -260,7 +260,7 @@ public class GeronimoFactoryFinderProvid
         }
         checkFactoryName(factoryName);
 
-        String webApplicationIdentity = WebApplicationIdentity.getIdentity();
+        String webApplicationIdentity = WebApplicationName.getName();
         if(webApplicationIdentity == null) {
             throw new IllegalStateException("No web identity is attached to current request thread " + Thread.currentThread().getName());
         }
@@ -286,14 +286,14 @@ public class GeronimoFactoryFinderProvid
                 factoryClassNames.put(factoryName, classNameList);
             }
             classNameList.add(implName);
-            if (logger.isDebugEnabled()) {                
+            if (logger.isDebugEnabled()) {
                 logger.debug("Factory map of web application [" + webApplicationIdentity + "] is " + factoryClassNames);
             }
         }
     }
 
     public void releaseFactories() throws FacesException {
-        String webApplicationIdentity = WebApplicationIdentity.getIdentity();
+        String webApplicationIdentity = WebApplicationName.getName();
         if(webApplicationIdentity == null) {
             throw new IllegalStateException("No web identity is attached to current request thread " + Thread.currentThread().getName());
         }
@@ -310,7 +310,7 @@ public class GeronimoFactoryFinderProvid
             if (factoryClassNames != null) {
                 factoryClassNames.clear();
             }
-            _registeredFactoryNames.remove(webApplicationIdentity);            
+            _registeredFactoryNames.remove(webApplicationIdentity);
         }
     }
 

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/GeronimoSingletonService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/GeronimoSingletonService.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/GeronimoSingletonService.java (original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/cdi/GeronimoSingletonService.java Tue Nov  1 14:49:29 2011
@@ -30,17 +30,25 @@ import org.osgi.framework.Bundle;
  */
 public class GeronimoSingletonService implements SingletonService<WebBeansContext> {
 
+    private static final GeronimoSingletonService INSTANCE = new GeronimoSingletonService();
+
     private static final ThreadLocal<WebBeansContext> contexts = new ThreadLocal<WebBeansContext>();
     private static Bundle bundle;
-    
+
     private static final WebBeansContext noContext = new WebBeansContext();
 
+    private SingletonService<WebBeansContext> webApplicationSingletonService;
+
     public static void init(Bundle owbBundle) {
         bundle = owbBundle;
-        WebBeansFinder.setSingletonService(new GeronimoSingletonService());
+        WebBeansFinder.setSingletonService(INSTANCE);
     }
 
-    public GeronimoSingletonService() {
+    private GeronimoSingletonService() {
+    }
+
+    public static GeronimoSingletonService getInstance() {
+        return INSTANCE;
     }
 
     public static WebBeansContext contextEntered(WebBeansContext newContext) {
@@ -55,20 +63,29 @@ public class GeronimoSingletonService im
 
     @Override
     public WebBeansContext get(Object key) {
-        return getContext();
-    }
-
-    private WebBeansContext getContext() {
         WebBeansContext context = contexts.get();
+        if (context == null && webApplicationSingletonService != null) {
+            context = webApplicationSingletonService.get(key);
+            if (context != null) {
+                return context;
+            }
+        }
         if (context == null) {
             contexts.set(noContext);
         }
         return context;
     }
 
+    public SingletonService<WebBeansContext> getWebApplicationSingletonService() {
+        return webApplicationSingletonService;
+    }
+
+    public void setWebApplicationSingletonService(SingletonService<WebBeansContext> webApplicationSingletonService) {
+        this.webApplicationSingletonService = webApplicationSingletonService;
+    }
+
     @Override
     public void clear(Object key) {
-        getContext().clear();
+        get(key).clear();
     }
-
 }

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=1196032&r1=1196031&r2=1196032&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 Tue Nov  1 14:49:29 2011
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.ScheduledExecutorService;
 
 import javax.servlet.ServletContext;
 
@@ -99,35 +100,35 @@ public class OpenWebBeansWebInitializer 
         webBeansContext.registerService(ContainerLifecycle.class, lifecycle);
 
         WebBeansContext oldContext = GeronimoSingletonService.contextEntered(webBeansContext);
+        //from OWB's WebBeansConfigurationListener
         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);
+            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(oldContext);
         }
         return webBeansContext;
     }
 
-    public static void initializeServletContext(WebBeansContext webBeansContext, ServletContext servletContext) {
+    public static ScheduledExecutorService initializeServletContext(WebBeansContext webBeansContext, ServletContext servletContext) {
         WebBeansContext oldContext = GeronimoSingletonService.contextEntered(webBeansContext);
         try {
             OpenEJBLifecycle lifecycle = (OpenEJBLifecycle) webBeansContext.getService(ContainerLifecycle.class);
-            lifecycle.startServletContext(servletContext);
+            //lifecycle.startServletContext(servletContext);
+            //startServletContext will eventually call the static method  initializeServletContext, which will return a ThreadPool reference
+            //We do need to keep that reference to prevent the thread leak
+            return OpenEJBLifecycle.initializeServletContext(servletContext, webBeansContext);
         } finally {
             GeronimoSingletonService.contextExited(oldContext);
         }

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=1196032&r1=1196031&r2=1196032&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 Tue Nov  1 14:49:29 2011
@@ -29,7 +29,7 @@ import org.apache.webbeans.config.WebBea
  */
 public class ThreadSingletonServiceAdapter implements ThreadSingletonService {
 
-    private final GeronimoSingletonService geronimoSingletonService = new GeronimoSingletonService();
+    private final GeronimoSingletonService geronimoSingletonService = GeronimoSingletonService.getInstance();
 
     public ThreadSingletonServiceAdapter() {
         super();
@@ -75,4 +75,8 @@ public class ThreadSingletonServiceAdapt
     public void clear(Object key) {
         geronimoSingletonService.clear(key);
     }
+
+    public GeronimoSingletonService getGeronimoSingletonService() {
+        return geronimoSingletonService;
+    }
 }

Modified: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/pom.xml?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/pom.xml (original)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/pom.xml Tue Nov  1 14:49:29 2011
@@ -51,7 +51,13 @@
             <artifactId>geronimo-openejb</artifactId>
             <version>${project.version}</version>
         </dependency>
-        
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-openwebbeans</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-naming-builder</artifactId>

Modified: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/main/java/org/apache/geronimo/openwebbeans/deployment/OpenWebBeansModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/main/java/org/apache/geronimo/openwebbeans/deployment/OpenWebBeansModuleBuilderExtension.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/main/java/org/apache/geronimo/openwebbeans/deployment/OpenWebBeansModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/main/java/org/apache/geronimo/openwebbeans/deployment/OpenWebBeansModuleBuilderExtension.java Tue Nov  1 14:49:29 2011
@@ -23,7 +23,6 @@ import java.lang.reflect.Member;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -53,10 +52,14 @@ import org.apache.geronimo.j2ee.deployme
 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.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.openejb.cdi.WebBeansConfigurationListener;
+import org.apache.geronimo.openwebbeans.OpenWebBeansWebAppContext;
+import org.apache.geronimo.openwebbeans.OpenWebBeansWebModuleListener;
+import org.apache.geronimo.openwebbeans.WebBeansConfigurationListener;
+import org.apache.geronimo.web.WebApplicationConstants;
 import org.apache.geronimo.web.info.WebAppInfo;
 import org.apache.openejb.jee.WebApp;
 import org.apache.xbean.finder.AbstractFinder;
@@ -89,6 +92,8 @@ public class OpenWebBeansModuleBuilderEx
     //this is the geronimo copy
     private static final String CONTEXT_LISTENER_NAME = WebBeansConfigurationListener.class.getName();
 
+    private static final String WEB_MODULE_LISTENER_NAME = OpenWebBeansWebModuleListener.class.getName();
+
     public OpenWebBeansModuleBuilderExtension(
             @ParamAttribute(name = "defaultEnvironment") Environment defaultEnvironment,
             @ParamAttribute(name = "jsfPluginEnvironment") Environment jsfPluginEnvironment,
@@ -100,13 +105,12 @@ public class OpenWebBeansModuleBuilderEx
 
     public void createModule(Module module, Bundle bundle, Naming naming, ModuleIDBuilder idBuilder)
             throws DeploymentException {
-        if (!(module instanceof WebModule) /*|| !hasBeanXml(module)*/) {
+        if (!(module instanceof WebModule)) {
             // not a web module, nothing to do
             return;
         }
-
-        EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), defaultEnvironment);
         if(hasBeanXml(module)){
+            EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), defaultEnvironment);
             EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), jsfPluginEnvironment);
         }
     }
@@ -114,13 +118,12 @@ public class OpenWebBeansModuleBuilderEx
     public void createModule(Module module, Object plan, JarFile moduleFile, String targetPath, URL specDDUrl,
             Environment environment, Object moduleContextInfo, AbstractName earName, Naming naming,
             ModuleIDBuilder idBuilder) throws DeploymentException {
-        if (!(module instanceof WebModule) /*|| !hasBeanXml(module)*/) {
+        if (!(module instanceof WebModule)) {
             // not a web module, nothing to do
             return;
-        }       
-        
-        EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), defaultEnvironment);
+        }
         if(hasBeanXml(module)){
+            EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), defaultEnvironment);
             EnvironmentBuilder.mergeEnvironments(module.getEnvironment(), jsfPluginEnvironment);
         }
     }
@@ -138,23 +141,30 @@ public class OpenWebBeansModuleBuilderEx
             // not a web module, nothing to do
             return;
         }
+        if (!hasBeansXml(bundle)) {
+            return;
+        }
 
         WebModule webModule = (WebModule) module;
-
-//        if (!hasBeansXml(bundle)) {
-//            return;
-//        }
-
         EARContext moduleContext = module.getEarContext();
         Map sharedContext = module.getSharedContext();
-        //add the ServletContextListener to the web app context
+
         GBeanData webAppData = (GBeanData) sharedContext.get(WebModule.WEB_APP_DATA);
-        // add myfaces listener
+        Map<String, Object> deploymentAttributes = (Map<String, Object>)webAppData.getAttribute("deploymentAttributes");
+        List<String> webModuleListenerClassNames = (List<String>) deploymentAttributes.get(WebApplicationConstants.WEB_MODULE_LISTENERS);
+        if (webModuleListenerClassNames == null) {
+            webModuleListenerClassNames = new ArrayList<String>();
+            deploymentAttributes.put(WebApplicationConstants.WEB_MODULE_LISTENERS, webModuleListenerClassNames);
+        }
+        webModuleListenerClassNames.add(WEB_MODULE_LISTENER_NAME);
+
+
+        // add OpenWebBeans Lifcycle listener
         WebAppInfo webAppInfo = (WebAppInfo) webAppData.getAttribute("webAppInfo");
         if (webAppInfo != null && !webAppInfo.listeners.contains(CONTEXT_LISTENER_NAME)) {
             webAppInfo.listeners.add(0, CONTEXT_LISTENER_NAME);
         }
-        AbstractName moduleName = moduleContext.getModuleName();
+        AbstractName moduleName = module.getModuleName();
         Map<EARContext.Key, Object> buildingContext = new HashMap<EARContext.Key, Object>();
         buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleName);
 
@@ -170,18 +180,20 @@ public class OpenWebBeansModuleBuilderEx
         webModule.setClassFinder(classFinder);
         namingBuilders.buildNaming(webApp, geronimoWebApp, webModule, buildingContext);
         webModule.setClassFinder(originalFinder);
-        
 
-//        AbstractName webBeansGBeanName = moduleContext.getNaming().createChildName(moduleName, "webbeans-lifecycle", "webbeans");
-//        GBeanData providerData = new GBeanData(webBeansGBeanName, OpenWebBeansGBean.class);
-//        try {
-//            moduleContext.addGBean(providerData);
-//        } catch (GBeanAlreadyExistsException e) {
-//            throw new DeploymentException("Duplicate webbean config gbean in web module", e);
-//        }
-
-        //make the web app start second after the webbeans machinery
-//        webAppData.addDependency(webBeansGBeanName);
+        AbstractName openWebBeansWebAppContextGBeanName = moduleContext.getNaming().createChildName(moduleName, "OpenWebBeansWebAppContext", "OpenWebBeansWebAppContext");
+        GBeanData openWebBeansWebAppContextGBean = new GBeanData(openWebBeansWebAppContextGBeanName, OpenWebBeansWebAppContext.class);
+        try {
+            openWebBeansWebAppContextGBean.setAttribute("holder", holder);
+            AbstractName sharedOwbContextName = EARContext.APPINFO_GBEAN_NAME_KEY.get(earContext.getGeneralData());
+            if (sharedOwbContextName != null) {
+                openWebBeansWebAppContextGBean.setReferencePattern("SharedOwbContext", sharedOwbContextName);
+            }
+            moduleContext.addGBean(openWebBeansWebAppContextGBean);
+            webAppData.addDependency(openWebBeansWebAppContextGBeanName);
+        } catch (GBeanAlreadyExistsException e) {
+            throw new DeploymentException("Duplicate webbean config gbean in web module", e);
+        }
     }
 
     private boolean hasBeansXml(Bundle bundle) {
@@ -214,7 +226,7 @@ public class OpenWebBeansModuleBuilderEx
         ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
         try {
             PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
-            
+
             //1. Generated the jar file list, which contains META-INF/beans.xml file
             final Set<String> annotationScanRequiredJarFiles = new HashSet<String>();
             String moduleNamePrefix = webModule.isStandAlone() ? "" : webModule.getTargetPath() + "/";
@@ -252,7 +264,7 @@ public class OpenWebBeansModuleBuilderEx
                     return true;
                 }
             });
-            
+
             final String webInfClassesFolder = moduleNamePrefix + "WEB-INF/classes/";
             final boolean webInfClassesScanRequired = bundle.getEntry(moduleNamePrefix + "WEB-INF/beans.xml") != null;
 
@@ -260,7 +272,7 @@ public class OpenWebBeansModuleBuilderEx
             BundleAnnotationFinder bundleAnnotationFinder = new BundleAnnotationFinder(packageAdmin, bundle, new ResourceDiscoveryFilter() {
 
                 @Override
-                public boolean directoryDiscoveryRequired(String directory) {                    
+                public boolean directoryDiscoveryRequired(String directory) {
                     return directory.equals(webInfClassesFolder) && webInfClassesScanRequired;
                 }
 
@@ -305,5 +317,5 @@ public class OpenWebBeansModuleBuilderEx
             bundle.getBundleContext().ungetService(reference);
         }
     }
-    
+
 }

Modified: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/test/java/org/apache/geronimo/openwebbeans/deployment/BasicTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/test/java/org/apache/geronimo/openwebbeans/deployment/BasicTest.java?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/test/java/org/apache/geronimo/openwebbeans/deployment/BasicTest.java (original)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans-builder/src/test/java/org/apache/geronimo/openwebbeans/deployment/BasicTest.java Tue Nov  1 14:49:29 2011
@@ -20,11 +20,7 @@
 
 package org.apache.geronimo.openwebbeans.deployment;
 
-import java.util.Collections;
-
 import junit.framework.TestCase;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.j2ee.deployment.NamingBuilderCollection;
 
 /**
  * @version $Rev: 741679 $ $Date: 2009-02-06 11:07:17 -0800 (Fri, 06 Feb 2009) $

Modified: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml?rev=1196032&r1=1196031&r2=1196032&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml (original)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/pom.xml Tue Nov  1 14:49:29 2011
@@ -34,122 +34,31 @@
     <name>Geronimo Plugins, OpenWebBeans :: Core</name>
     
     <dependencies>
-    
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
-            <artifactId>geronimo-j2ee</artifactId>
+            <artifactId>geronimo-web</artifactId>
             <version>${project.version}</version>
         </dependency>
         
         <dependency>
-            <groupId>org.apache.geronimo.framework</groupId>
-            <artifactId>geronimo-naming</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo.framework</groupId>
-            <artifactId>geronimo-security</artifactId>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-openejb</artifactId>
             <version>${project.version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-annotation_1.1_spec</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-atinject_1.0_spec</artifactId>
         </dependency>
-        
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-el_2.2_spec</artifactId>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-interceptor_1.1_spec</artifactId>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jaxws_2.2_spec</artifactId>
-        </dependency>
 
         <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jcdi_1.0_spec</artifactId>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jpa_2.0_spec</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jsp_2.2_spec</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jta_1.1_spec</artifactId>
+            <groupId>org.apache.openejb</groupId>
+            <artifactId>openejb-core</artifactId>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-servlet_3.0_spec</artifactId>
-        </dependency>        
-        
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-validation_1.0_spec</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.bundles</groupId>
-            <artifactId>myfaces-bundle</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.bundles</groupId>
-            <artifactId>jstl</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>commons-beanutils</groupId>
-            <artifactId>commons-beanutils</artifactId>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.apache.servicemix.bundles</groupId>
-            <artifactId>org.apache.servicemix.bundles.commons-codec</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.bundles</groupId>
-            <artifactId>commons-digester</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.bundles</groupId>
-            <artifactId>commons-discovery</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.servicemix.bundles</groupId>
-            <artifactId>org.apache.servicemix.bundles.dom4j</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.servicemix.bundles</groupId>
-            <artifactId>org.apache.servicemix.bundles.javassist</artifactId>
-        </dependency>
-        
-        <dependency>
-            <groupId>org.apache.geronimo.bundles</groupId>
-            <artifactId>scannotation</artifactId>
         </dependency>
 
         <dependency>
@@ -171,15 +80,16 @@
             <groupId>org.apache.openwebbeans</groupId>
             <artifactId>openwebbeans-impl</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.openwebbeans</groupId>
-            <artifactId>openwebbeans-jsf</artifactId>
-        </dependency>
+
         <dependency>
             <groupId>org.apache.openwebbeans</groupId>
             <artifactId>openwebbeans-ee</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.openejb</groupId>
+            <artifactId>openejb-loader</artifactId>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
@@ -188,7 +98,7 @@
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>
-                        <Export-SPI-Provider>org.apache.geronimo.openejb.cdi.WebBeansConfigurationListener</Export-SPI-Provider>
+                        <Export-SPI-Provider>org.apache.geronimo.openwebbeans.WebBeansConfigurationListener</Export-SPI-Provider>
                     </instructions>
                 </configuration>
             </plugin>

Added: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansHolderInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansHolderInterceptor.java?rev=1196032&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansHolderInterceptor.java (added)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansHolderInterceptor.java Tue Nov  1 14:49:29 2011
@@ -0,0 +1,55 @@
+/**
+ *  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.openwebbeans;
+
+import org.apache.geronimo.j2ee.annotation.Holder;
+import org.apache.geronimo.j2ee.annotation.Holder.InterceptorException;
+import org.apache.geronimo.j2ee.annotation.Holder.InvocationContext;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.inject.OWBInjector;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OpenWebBeansHolderInterceptor implements Holder.Interceptor {
+
+    private final WebBeansContext webBeansContext;
+
+    public OpenWebBeansHolderInterceptor(WebBeansContext webBeansContext) {
+        this.webBeansContext = webBeansContext;
+    }
+
+    @Override
+    public void instancerCreated(InvocationContext context) throws InterceptorException {
+        OWBInjector beanInjector = new OWBInjector(webBeansContext);
+        try {
+            beanInjector.inject(context.getInstance());
+        } catch (Exception e) {
+            throw new InterceptorException("web beans injection problem", e);
+        }
+    }
+
+    @Override
+    public void instanceDestoryed(InvocationContext context) throws InterceptorException {
+    }
+
+    @Override
+    public void postConstructInvoked(InvocationContext context) throws InterceptorException {
+    }
+
+}

Added: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansSystemInitializer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansSystemInitializer.java?rev=1196032&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansSystemInitializer.java (added)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansSystemInitializer.java Tue Nov  1 14:49:29 2011
@@ -0,0 +1,60 @@
+/**
+ *  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.openwebbeans;
+
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.openejb.cdi.ThreadSingletonServiceAdapter;
+import org.apache.openejb.cdi.ThreadSingletonService;
+import org.apache.openejb.loader.SystemInstance;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@GBean(name = "OpenWebBeansSystemInitializer")
+public class OpenWebBeansSystemInitializer implements GBeanLifecycle {
+
+    @Override
+    public void doFail() {
+        try {
+            doStop();
+        } catch (Exception e) {
+        }
+    }
+
+    @Override
+    public void doStart() throws Exception {
+        ThreadSingletonServiceAdapter adapter = getThreadSingletonServiceAdapter();
+        if (adapter != null) {
+            adapter.getGeronimoSingletonService().setWebApplicationSingletonService(new WebApplicationNameBasedSingletonService());
+        }
+    }
+
+    @Override
+    public void doStop() throws Exception {
+        ThreadSingletonServiceAdapter adapter = getThreadSingletonServiceAdapter();
+        if (adapter != null) {
+            adapter.getGeronimoSingletonService().setWebApplicationSingletonService(null);
+        }
+    }
+
+    private ThreadSingletonServiceAdapter getThreadSingletonServiceAdapter() {
+        ThreadSingletonService threadSingletonService = SystemInstance.get().getComponent(ThreadSingletonService.class);
+        return (threadSingletonService instanceof ThreadSingletonServiceAdapter) ? (ThreadSingletonServiceAdapter) threadSingletonService : null;
+    }
+}

Added: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebAppContext.java?rev=1196032&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebAppContext.java (added)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OpenWebBeansWebAppContext.java Tue Nov  1 14:49:29 2011
@@ -0,0 +1,121 @@
+/**
+ *  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.openwebbeans;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.geronimo.gbean.AbstractName;
+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.j2ee.annotation.Holder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.openejb.cdi.OpenWebBeansWebInitializer;
+import org.apache.geronimo.openejb.cdi.SharedOwbContext;
+import org.apache.webbeans.config.WebBeansContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@GBean(name = "OpenWebBeansContext")
+public class OpenWebBeansWebAppContext implements GBeanLifecycle {
+
+    private static final Logger logger = LoggerFactory.getLogger(OpenWebBeansWebAppContext.class);
+
+    private static final Map<String, OpenWebBeansWebAppContext> OPENWEBBEANS_WEBAPP_CONTEXTS = new ConcurrentHashMap<String, OpenWebBeansWebAppContext>();
+
+    private final Holder holder;
+
+    private final SharedOwbContext sharedOwbContext;
+
+    private final AbstractName abName;
+
+    private WebBeansContext webBeansContext;
+
+    private final boolean shareableWebBeansContext;
+
+    public OpenWebBeansWebAppContext(@ParamAttribute(name = "holder") Holder holder,
+            @ParamReference(name = "SharedOwbContext") SharedOwbContext sharedOwbContext,
+            @ParamSpecial(type = SpecialAttributeType.abstractName) AbstractName abName) {
+        this.holder = holder;
+        this.sharedOwbContext = sharedOwbContext;
+        webBeansContext = sharedOwbContext == null ? null : sharedOwbContext.getOWBContext();
+        if (webBeansContext == null) {
+            if (logger.isDebugEnabled()) {
+                if (sharedOwbContext == null) {
+                    logger.debug("SharedOwbContext is null, web application {} will create its own WebBeansContext", abName.toString());
+                } else {
+                    logger.debug("No WebBeansContext is configured in SharedOwbContext, web application {} will create its own WebBeansContext", abName.toString());
+                }
+            }
+            shareableWebBeansContext = false;
+            webBeansContext = OpenWebBeansWebInitializer.newWebBeansContext(null);
+        } else {
+            shareableWebBeansContext = true;
+        }
+        this.abName = abName;
+    }
+
+    @Override
+    public void doFail() {
+        try {
+            doStop();
+        } catch (Exception e) {
+        }
+    }
+
+    @Override
+    public void doStart() throws Exception {
+        OPENWEBBEANS_WEBAPP_CONTEXTS.put(getWebModuleName(), this);
+    }
+
+    @Override
+    public void doStop() throws Exception {
+        OPENWEBBEANS_WEBAPP_CONTEXTS.remove(getWebModuleName());
+    }
+
+    public Holder getHolder() {
+        return holder;
+    }
+
+    public SharedOwbContext getSharedOwbContext() {
+        return sharedOwbContext;
+    }
+
+    public String getWebModuleName() {
+        return abName.getNameProperty(NameFactory.WEB_MODULE);
+    }
+
+    public WebBeansContext getWebBeansContext() {
+        return webBeansContext;
+    }
+
+    public boolean isShareableWebBeansContext() {
+        return shareableWebBeansContext;
+    }
+
+    public static OpenWebBeansWebAppContext getOpenWebBeansWebAppContext(String moduleName) {
+        return OPENWEBBEANS_WEBAPP_CONTEXTS.get(moduleName);
+    }
+}



Mime
View raw message