openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r984584 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: context/AbstractContext.java corespi/se/DefaultContextsService.java
Date Wed, 11 Aug 2010 21:14:17 GMT
Author: struberg
Date: Wed Aug 11 21:14:17 2010
New Revision: 984584

URL: http://svn.apache.org/viewvc?rev=984584&view=rev
Log:
OWB-436 quick fix for our thread safety problem.

This is just intended as safe solution and can be improved heavily!

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

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java?rev=984584&r1=984583&r2=984584&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java
Wed Aug 11 21:14:17 2010
@@ -195,7 +195,7 @@ public abstract class AbstractContext im
      * {@inheritDoc} 
      */
     @SuppressWarnings("unchecked")
-    protected <T> T getInstance(Contextual<T> contextual, CreationalContext<T>
creationalContext)
+    protected synchronized <T> T getInstance(Contextual<T> contextual, CreationalContext<T>
creationalContext)
     {
         T instance = null;
         

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=984584&r1=984583&r2=984584&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
Wed Aug 11 21:14:17 2010
@@ -43,7 +43,7 @@ public class DefaultContextsService exte
 
     private static ThreadLocal<SessionContext> sessionContext = null;
 
-    private static ThreadLocal<ApplicationContext> applicationContext = null;
+    private ApplicationContext applicationContext = null;
 
     private static ThreadLocal<ConversationContext> conversationContext = null;
     
@@ -56,7 +56,6 @@ public class DefaultContextsService exte
     {
         requestContext = new ThreadLocal<RequestContext>();
         sessionContext = new ThreadLocal<SessionContext>();
-        applicationContext = new ThreadLocal<ApplicationContext>();
         conversationContext = new ThreadLocal<ConversationContext>();
         dependentContext = new ThreadLocal<DependentContext>();
         singletonContext = new ThreadLocal<SingletonContext>();
@@ -209,14 +208,12 @@ public class DefaultContextsService exte
     {
         requestContext.set(null);
         sessionContext.set(null);
-        applicationContext.set(null);
         conversationContext.set(null);
         dependentContext.set(null);
         singletonContext.set(null);
         
         requestContext.remove();
         sessionContext.remove();
-        applicationContext.remove();
         conversationContext.remove();
         dependentContext.remove();
         singletonContext.remove();
@@ -226,7 +223,7 @@ public class DefaultContextsService exte
     
     private Context getCurrentApplicationContext()
     {        
-        return applicationContext.get();
+        return applicationContext;
     }
 
     
@@ -270,7 +267,7 @@ public class DefaultContextsService exte
         ApplicationContext ctx = new ApplicationContext();
         ctx.setActive(true);
         
-        applicationContext.set(ctx);
+        applicationContext = ctx;
     }
 
     
@@ -315,11 +312,8 @@ public class DefaultContextsService exte
     
     private void stopApplicationContext(Object object)
     {
-        if(applicationContext.get() != null)
-        {
-            applicationContext.get().destroy();   
-        }
-        
+        applicationContext.destroy();
+        applicationContext = null;
     }
 
     



Mime
View raw message