openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r933376 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: container/InjectionResolver.java context/AbstractContext.java context/creational/CreationalContextImpl.java lifecycle/AbstractLifeCycle.java
Date Mon, 12 Apr 2010 19:33:37 GMT
Author: gerdogdu
Date: Mon Apr 12 19:33:37 2010
New Revision: 933376

URL: http://svn.apache.org/viewvc?rev=933376&view=rev
Log:
more sync issue and some tweaking

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.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/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=933376&r1=933375&r2=933376&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Mon Apr 12 19:33:37 2010
@@ -82,6 +82,15 @@ public class InjectionResolver
         this.manager = manager;
 
     }
+    
+    /**
+     * Clear caches.
+     */
+    public void clearCaches()
+    {
+        this.resolvedBeansByName.clear();
+        this.resolvedBeansByType.clear();
+    }
 
     /**
      * Returns bean manager injection resolver.

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=933376&r1=933375&r2=933376&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
Mon Apr 12 19:33:37 2010
@@ -14,12 +14,12 @@
 package org.apache.webbeans.context;
 
 import java.lang.annotation.Annotation;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
-import java.util.WeakHashMap;
 import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.context.ContextNotActiveException;
@@ -48,7 +48,7 @@ import org.apache.webbeans.util.Asserts;
 public abstract class AbstractContext implements WebBeansContext
 {
     /**Context status, active or not*/
-    protected boolean active;
+    protected volatile boolean active;
 
     /**Context type*/
     protected ContextTypes type;
@@ -60,8 +60,9 @@ public abstract class AbstractContext im
     protected Class<? extends Annotation> scopeType;
     
     /**Contextual to CreationalContext Map*/
-    protected final Map<Contextual<?>, CreationalContext<?>> creationalContextMap
= 
-        Collections.synchronizedMap(new WeakHashMap<Contextual<?>, CreationalContext<?>>());
+    protected final ConcurrentMap<Contextual<?>, CreationalContext<?>>
creationalContextMap = 
+        new ConcurrentHashMap<Contextual<?>, CreationalContext<?>>();
+       
 
     /**
      * Creates a new context instance
@@ -195,8 +196,21 @@ public abstract class AbstractContext im
 
                 if (instance != null)
                 {
-                    this.componentInstanceMap.put(component, instance);
-                    this.creationalContextMap.put(component, creationalContext);
+                    if(this.componentInstanceMap instanceof ConcurrentMap)
+                    {
+                        T exist = (T) ((ConcurrentMap) this.componentInstanceMap).putIfAbsent(component,
instance);
+                        //no instance
+                        if(exist == null)
+                        {
+                            this.componentInstanceMap.put(component, instance);
+                        }
+                    }
+                    else
+                    {
+                        this.componentInstanceMap.put(component, instance);
+                    }
+                                           
+                    this.creationalContextMap.putIfAbsent(component, creationalContext);
                 }
                 
             }            

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=933376&r1=933375&r2=933376&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
Mon Apr 12 19:33:37 2010
@@ -18,6 +18,8 @@ package org.apache.webbeans.context.crea
 
 import java.io.*;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
@@ -35,22 +37,23 @@ public class CreationalContextImpl<T> im
     private static final long serialVersionUID = -3416834742959340960L;
 
     /**Actual bean instance*/
-    private transient Object incompleteInstance = null;
+    private transient volatile Object incompleteInstance = null;
     
     /**Bean proxy*/
-    private Object proxyInstance = null;
+    private volatile Object proxyInstance = null;
     
     /**Contextual bean dependent instances*/
-    private Map<Object, DependentCreationalContext<?>> dependentObjects = new
WeakHashMap<Object, DependentCreationalContext<?>>();
+    private Map<Object, DependentCreationalContext<?>> dependentObjects = 
+        Collections.synchronizedMap(new WeakHashMap<Object, DependentCreationalContext<?>>());
      
     /**Owner bean*/
-    private Contextual<T> contextual = null;
+    private volatile Contextual<T> contextual = null;
     
     /**Owner creational context*/
-    private CreationalContextImpl<?> ownerCreational = null;
+    private volatile CreationalContextImpl<?> ownerCreational = null;
     
     /**Ejb interceptors*/
-    private Map<Class<?>, EjbInterceptorContext> ejbInterceptors = new HashMap<Class<?>,
EjbInterceptorContext>();
+    private ConcurrentMap<Class<?>, EjbInterceptorContext> ejbInterceptors =
new ConcurrentHashMap<Class<?>, EjbInterceptorContext>();
     
     /**
      * Package private
@@ -67,7 +70,7 @@ public class CreationalContextImpl<T> im
      */
     public void addEjbInterceptor(Class<?> clazz, EjbInterceptorContext instance)
     {
-        this.ejbInterceptors.put(clazz, instance);
+        this.ejbInterceptors.putIfAbsent(clazz, instance);
     }
     
     /**
@@ -88,7 +91,10 @@ public class CreationalContextImpl<T> im
      */
     public void push(T incompleteInstance)
     {
-        this.incompleteInstance = incompleteInstance;
+        if(this.incompleteInstance != null)
+        {
+            this.incompleteInstance = incompleteInstance;   
+        }
         
     }
     
@@ -98,7 +104,10 @@ public class CreationalContextImpl<T> im
      */
     public void setProxyInstance(Object proxyInstance)
     {
-        this.proxyInstance = proxyInstance;
+        if(this.proxyInstance != null)
+        {
+            this.proxyInstance = proxyInstance;   
+        }
     }
     
     /**
@@ -283,7 +292,7 @@ public class CreationalContextImpl<T> im
     public void release()
     {
         removeDependents();
-        this.incompleteInstance = null;        
+        this.incompleteInstance = null;
     }
     
     /**
@@ -310,7 +319,10 @@ public class CreationalContextImpl<T> im
      */
     public void setOwnerCreational(CreationalContextImpl<?> ownerCreational)
     {
-        this.ownerCreational = ownerCreational;
+        if(this.ownerCreational != null)
+        {
+            this.ownerCreational = ownerCreational;   
+        }
     }
 
     /**

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=933376&r1=933375&r2=933376&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
Mon Apr 12 19:33:37 2010
@@ -28,6 +28,7 @@ import org.apache.webbeans.config.BeansD
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.plugins.PluginLoader;
 import org.apache.webbeans.portable.events.ExtensionLoader;
@@ -150,12 +151,15 @@ public abstract class AbstractLifeCycle 
             //Clear extensions
             ExtensionLoader.getInstance().clear();
             
+            //Delete Resolutions Cache
+            InjectionResolver.getInstance().clearCaches();
+            
             //Clear singleton list
             WebBeansFinder.clearInstances();
 
             //Delte proxies
             JavassistProxyFactory.clear();
-
+            
             //After Stop
             afterStopApplication(endObject);
                         



Mime
View raw message