geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1027746 - in /geronimo/server/trunk/plugins: openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/
Date Tue, 26 Oct 2010 21:00:58 GMT
Author: djencks
Date: Tue Oct 26 21:00:58 2010
New Revision: 1027746

URL: http://svn.apache.org/viewvc?rev=1027746&view=rev
Log:
Adapt to openejb changes(OPENEJB-1382)

Modified:
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
    geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OsgiMetaDataScannerService.java

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java?rev=1027746&r1=1027745&r2=1027746&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
(original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
Tue Oct 26 21:00:58 2010
@@ -25,11 +25,17 @@ import java.util.Map;
 import org.apache.geronimo.openwebbeans.GeronimoSingletonService;
 import org.apache.geronimo.openwebbeans.OpenWebBeansWebInitializer;
 import org.apache.geronimo.openwebbeans.OsgiMetaDataScannerService;
+import org.apache.openejb.AppContext;
 import org.apache.openejb.cdi.CdiAppContextsService;
 import org.apache.openejb.cdi.CdiResourceInjectionService;
+import org.apache.openejb.cdi.OWBContext;
+import org.apache.openejb.cdi.OpenEJBLifecycle;
+import org.apache.openejb.cdi.StartupObject;
 import org.apache.openejb.cdi.ThreadSingletonService;
 import org.apache.webbeans.config.OpenWebBeansConfiguration;
+import org.apache.webbeans.corespi.ServiceLoader;
 import org.apache.webbeans.lifecycle.StandaloneLifeCycle;
+import org.apache.webbeans.spi.ContainerLifecycle;
 import org.apache.webbeans.spi.ResourceInjectionService;
 
 /**
@@ -41,10 +47,27 @@ public class ThreadSingletonServiceAdapt
     }
 
     @Override
-    public void initialize(org.apache.openejb.cdi.OWBContext owbContext) {
+    public void initialize(StartupObject startupObject) {
+        //share owb singletons
+        OWBContext owbContext = new OWBContext();
         Object old = contextEntered(owbContext);
         try {
-            setConfiguration(OpenWebBeansConfiguration.getInstance());
+            if (old == null) {
+                //not embedded. Are we the first ejb module to try this?
+                if (startupObject.getAppContext().get(OWBContext.class) == null) {
+                    startupObject.getAppContext().set(OWBContext.class, owbContext);
+                    setConfiguration(OpenWebBeansConfiguration.getInstance());
+                    try {
+                        ServiceLoader.getService(ContainerLifecycle.class).startApplication(startupObject);
+                    } catch (Exception e) {
+                        throw new RuntimeException("couldn't start owb context", e);
+                    }
+                }
+                // an existing OWBConfiguration will have already been initialized
+            } else {
+                owbContext = new OWBContext((Map<String, Object>) old);
+                startupObject.getAppContext().set(OWBContext.class, owbContext);
+            }
         } finally {
             contextExited(old);
         }
@@ -52,8 +75,10 @@ public class ThreadSingletonServiceAdapt
 
     private void setConfiguration(OpenWebBeansConfiguration configuration) {
         configuration.setProperty(OpenWebBeansConfiguration.USE_EJB_DISCOVERY, "true");
-
-        configuration.setProperty(OpenWebBeansConfiguration.CONTAINER_LIFECYCLE, StandaloneLifeCycle.class.getName());
+        //from CDI builder
+        configuration.setProperty(OpenWebBeansConfiguration.INTERCEPTOR_FORCE_NO_CHECKED_EXCEPTIONS,
"false");
+  
+        configuration.setProperty(OpenWebBeansConfiguration.CONTAINER_LIFECYCLE, OpenEJBLifecycle.class.getName());
         configuration.setProperty(OpenWebBeansConfiguration.JNDI_SERVICE, OpenWebBeansWebInitializer.NoopJndiService.class.getName());
         configuration.setProperty(OpenWebBeansConfiguration.SCANNER_SERVICE, OsgiMetaDataScannerService.class.getName());
         configuration.setProperty(OpenWebBeansConfiguration.CONTEXTS_SERVICE, CdiAppContextsService.class.getName());
@@ -69,6 +94,6 @@ public class ThreadSingletonServiceAdapt
     @Override
     public void contextExited(Object oldContext) {
         if (oldContext != null && !(oldContext instanceof Map)) throw new IllegalArgumentException("Expecting
a Map<String, Object> not " + oldContext.getClass().getName());
-        GeronimoSingletonService.contextExited((Map<String, Object>)oldContext);
+        GeronimoSingletonService.contextExited((Map<String, Object>) oldContext);
     }
 }

Modified: geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OsgiMetaDataScannerService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OsgiMetaDataScannerService.java?rev=1027746&r1=1027745&r2=1027746&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OsgiMetaDataScannerService.java
(original)
+++ geronimo/server/trunk/plugins/openwebbeans/geronimo-openwebbeans/src/main/java/org/apache/geronimo/openwebbeans/OsgiMetaDataScannerService.java
Tue Oct 26 21:00:58 2010
@@ -52,7 +52,7 @@ public class OsgiMetaDataScannerService 
 
     private boolean configured = false;
 
-    protected ServletContext servletContext = null;
+//    protected ServletContext servletContext = null;
     private static final String META_INF_BEANS_XML = "META-INF/beans.xml";
     private static final String WEB_INF_BEANS_XML = "WEB-INF/beans.xml";
 
@@ -68,10 +68,10 @@ public class OsgiMetaDataScannerService 
     @Override
     public void init(Object object)
     {
-        if (object instanceof ServletContext)
-        {
-            servletContext = (ServletContext) object;
-        }
+//        if (object instanceof ServletContext)
+//        {
+//            servletContext = (ServletContext) object;
+//        }
     }
 
     @Override
@@ -101,6 +101,7 @@ public class OsgiMetaDataScannerService 
             {
                 mainBundle.getBundleContext().ungetService(reference);
             }
+            configured = true;
         }
 
     }



Mime
View raw message