openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsandt...@apache.org
Subject svn commit: r1676604 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: corespi/se/DefaultContextsService.java lifecycle/AbstractLifeCycle.java
Date Tue, 28 Apr 2015 20:03:17 GMT
Author: rsandtner
Date: Tue Apr 28 20:03:17 2015
New Revision: 1676604

URL: http://svn.apache.org/r1676604
Log:
OWB-1061 start applicationContext only once, don't start applicationContext on shutdown

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java?rev=1676604&r1=1676603&r2=1676604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultContextsService.java
Tue Apr 28 20:03:17 2015
@@ -209,20 +209,43 @@ public class DefaultContextsService exte
     @Override
     public void destroy(Object destroyObject)
     {
-        requestContext.set(null);
-        sessionContext.set(null);
-        conversationContext.set(null);
+        RequestContext requestCtx = requestContext.get();
+        if (requestCtx != null)
+        {
+            requestCtx.destroy();
+            requestContext.set(null);
+            requestContext.remove();
+        }
+
+        SessionContext sessionCtx = sessionContext.get();
+        if (sessionCtx != null)
+        {
+            sessionCtx.destroy();
+            sessionContext.set(null);
+            sessionContext.remove();
+        }
+
+        ConversationContext conversationCtx = conversationContext.get();
+        if (conversationCtx != null)
+        {
+            conversationCtx.destroy();
+            conversationContext.set(null);
+            conversationContext.remove();
+        }
+
+        SingletonContext singletonCtx = singletonContext.get();
+        if (singletonCtx != null)
+        {
+            singletonCtx.destroy();
+            singletonContext.set(null);
+            singletonContext.remove();
+        }
+
         dependentContext.set(null);
-        singletonContext.set(null);
-        
-        requestContext.remove();
-        sessionContext.remove();
-        conversationContext.remove();
         dependentContext.remove();
-        singletonContext.remove();
     }
-    
-    
+
+
     private Context getCurrentApplicationContext()
     {        
         return applicationContext;
@@ -266,9 +289,15 @@ public class DefaultContextsService exte
     
     private void startApplicationContext(Object instance)
     {
+        if (applicationContext != null)
+        {
+            // applicationContext is already started
+            return;
+        }
+
         ApplicationContext ctx = new ApplicationContext();
         ctx.setActive(true);
-        
+
         applicationContext = ctx;
 
         // We do ALSO send the @Initialized(ApplicationScoped.class) at this location but
this is WAY to early for userland apps

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=1676604&r1=1676603&r2=1676604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
Tue Apr 28 20:03:17 2015
@@ -23,7 +23,6 @@ import java.util.concurrent.atomic.Atomi
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.inject.spi.BeanManager;
 
 import org.apache.webbeans.config.BeansDeployer;
@@ -158,9 +157,6 @@ public abstract class AbstractLifeCycle
             //Sub-classes operations            
             beforeStopApplication(endObject);
 
-            //Set up the thread local for Application scoped as listeners will be App scoped.
-            contextsService.startContext(ApplicationScoped.class, endObject);
-            
             //Fire shut down
             beanManager.fireLifecycleEvent(new BeforeShutdownImpl());
             



Mime
View raw message