openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r882652 - in /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: context/ContextFactory.java lifecycle/EnterpriseLifeCycle.java lifecycle/StandaloneLifeCycle.java
Date Fri, 20 Nov 2009 17:45:30 GMT
Author: gerdogdu
Date: Fri Nov 20 17:45:29 2009
New Revision: 882652

URL: http://svn.apache.org/viewvc?rev=882652&view=rev
Log:
[OWB-173,OWB-175] Singleton context updating.

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java?rev=882652&r1=882651&r2=882652&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
Fri Nov 20 17:45:29 2009
@@ -54,6 +54,8 @@
     private static ThreadLocal<DependentContext> dependentContext = null;
 
     private static Map<ServletContext, ApplicationContext> currentApplicationContexts
= new ConcurrentHashMap<ServletContext, ApplicationContext>();
+    
+    private static Map<ServletContext, SingletonContext> currentSingletonContexts =
new ConcurrentHashMap<ServletContext, SingletonContext>();
 
     private static SessionContextManager sessionCtxManager = SessionContextManager.getInstance();
 
@@ -108,8 +110,8 @@
                     initSessionContext(session);    
                 }
                             
-                //Re-initialize thread local for application
-                initApplicationContext(event.getServletContext());
+                initApplicationContext(event.getServletContext());                
+                initSingletonContext(event.getServletContext());
             }            
         }
     }
@@ -245,15 +247,31 @@
         conversationManager.destroyAllConversations();
     }
     
-    public static void initSingletonContext()
+    public static void initSingletonContext(ServletContext servletContext)
     {
-        SingletonContext context = new SingletonContext();
-        context.setActive(true);
+        if(servletContext != null && currentSingletonContexts.containsKey(servletContext))
+        {
+            singletonContext.set(currentSingletonContexts.get(servletContext));
+        }
         
-        singletonContext.set(context);
+        else
+        {
+            SingletonContext context = new SingletonContext();
+            context.setActive(true);
+            
+            if(servletContext != null)
+            {
+                currentSingletonContexts.put(servletContext, context);
+                
+            }
+            
+            singletonContext.set(context);
+   
+        }
+                        
     }
     
-    public static void destroySingletonContext()
+    public static void destroySingletonContext(ServletContext servletContext)
     {
         if (singletonContext != null)
         {
@@ -265,8 +283,13 @@
             }
             
             singletonContext.remove();            
+
         }
         
+        if(servletContext != null)
+        {
+            currentSingletonContexts.remove(servletContext);   
+        }                
     }
 
     public static void initConversationContext(ConversationContext context)

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java?rev=882652&r1=882651&r2=882652&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java
Fri Nov 20 17:45:29 2009
@@ -167,7 +167,7 @@
         ContextFactory.initApplicationContext(event.getServletContext());
         
         //Singleton context
-        ContextFactory.initSingletonContext();
+        ContextFactory.initSingletonContext(event.getServletContext());
 
         this.discovery = ServiceLoader.getService(MetaDataDiscoveryService.class);
         this.discovery.init(event.getServletContext());
@@ -223,7 +223,7 @@
 
         ContextFactory.destroyApplicationContext(event.getServletContext());
         
-        ContextFactory.destroySingletonContext();
+        ContextFactory.destroySingletonContext(event.getServletContext());
 
         jndiService.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java?rev=882652&r1=882651&r2=882652&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java
Fri Nov 20 17:45:29 2009
@@ -99,7 +99,7 @@
             long begin = System.currentTimeMillis();
             
             //Singleton context
-            ContextFactory.initSingletonContext();
+            ContextFactory.initSingletonContext(null);
 
             // load all optional plugins
             PluginLoader.getInstance().startUp();
@@ -139,7 +139,7 @@
             
             jndiService.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
                     
-            ContextFactory.destroySingletonContext();
+            ContextFactory.destroySingletonContext(null);
 
             // finally free all plugin resources
             PluginLoader.getInstance().shutDown();



Mime
View raw message