geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1071863 - /geronimo/server/branches/3.0-M2/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
Date Fri, 18 Feb 2011 02:13:30 GMT
Author: xuhaihong
Date: Fri Feb 18 02:13:30 2011
New Revision: 1071863

URL: http://svn.apache.org/viewvc?rev=1071863&view=rev
Log:
Refract codes a little to avoid creating a unused WebBeansContext, as this class really takes
a lot of time even for a new instance

Modified:
    geronimo/server/branches/3.0-M2/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java

Modified: geronimo/server/branches/3.0-M2/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-M2/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java?rev=1071863&r1=1071862&r2=1071863&view=diff
==============================================================================
--- geronimo/server/branches/3.0-M2/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
(original)
+++ geronimo/server/branches/3.0-M2/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/ThreadSingletonServiceAdapter.java
Fri Feb 18 02:13:30 2011
@@ -48,28 +48,31 @@ public class ThreadSingletonServiceAdapt
     public void initialize(StartupObject startupObject) {
         //share owb singletons
         WebBeansContext webBeansContext = startupObject.getAppContext().get(WebBeansContext.class);
-        if (webBeansContext == null) {
-            webBeansContext = new WebBeansContext();
-            Object old = contextEntered(webBeansContext);
-            try {
-                if (old == null) {
+        if (webBeansContext != null) {
+            return;
+        }
+        Object old = contextEntered(null);
+        try {
+            if (old == null) {
+                webBeansContext = new WebBeansContext();
+                contextEntered(webBeansContext);
+                try {
                     //not embedded. Are we the first ejb module to try this?
                     startupObject.getAppContext().set(WebBeansContext.class, webBeansContext);
                     setConfiguration(webBeansContext.getOpenWebBeansConfiguration());
-                    try {
-                        webBeansContext.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 {
-                    startupObject.getAppContext().set(WebBeansContext.class, (WebBeansContext)
old);
+                    webBeansContext.getService(ContainerLifecycle.class).startApplication(startupObject);
+                } catch (Exception e) {
+                    throw new RuntimeException("couldn't start owb context", e);
+                } finally {
+                    contextExited(null);
                 }
-            } finally {
-                contextExited(old);
+                // an existing OWBConfiguration will have already been initialized
+            } else {
+                startupObject.getAppContext().set(WebBeansContext.class, (WebBeansContext)
old);
             }
+        } finally {
+            contextExited(old);
         }
-
     }
 
     private void setConfiguration(OpenWebBeansConfiguration configuration) {



Mime
View raw message