You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ar...@apache.org on 2013/05/09 21:30:06 UTC

svn commit: r1480743 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java container/BeanManagerImpl.java portable/AnnotatedElementFactory.java

Author: arne
Date: Thu May  9 19:30:06 2013
New Revision: 1480743

URL: http://svn.apache.org/r1480743
Log:
OWB-856: Implemented the behavior of the 1.1.x branch

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1480743&r1=1480742&r2=1480743&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Thu May  9 19:30:06 2013
@@ -525,8 +525,6 @@ public class BeansDeployer
         if (classIndex != null)
         {
             AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();
-            Collection<AnnotatedType<?>> additionalAnnotatedTypes = webBeansContext.getBeanManagerImpl()
-                                                                             .getAdditionalAnnotatedTypes();
 
             for(Class<?> implClass : classIndex)
             {
@@ -537,14 +535,10 @@ public class BeansDeployer
                 {
                     deploySingleAnnotatedType(implClass, annotatedType);
 
-                    if (additionalAnnotatedTypes.contains(annotatedType))
-                    {
-                        // if the implClass already gets processed as part of the
-                        // standard BDA scanning, then we don't need to 'additionally'
-                        // deploy it anymore.
-                        additionalAnnotatedTypes.remove(annotatedType);
-                    }
-
+                    // if the implClass already gets processed as part of the
+                    // standard BDA scanning, then we don't need to 'additionally'
+                    // deploy it anymore.
+                    webBeansContext.getBeanManagerImpl().removeAdditionalAnnotatedType(annotatedType);
                 } 
                 else
                 {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1480743&r1=1480742&r2=1480743&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Thu May  9 19:30:06 2013
@@ -31,6 +31,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArraySet;
 
 import javax.annotation.PostConstruct;
@@ -163,8 +164,7 @@ public class BeanManagerImpl extends Abs
      */
     private List<ExternalScope> additionalScopes =  new ArrayList<ExternalScope>();
 
-    private Map<String, AnnotatedType<?>> additionalAnnotatedTypes = new HashMap<String, AnnotatedType<?>>();
-
+    private ConcurrentMap<Class<?>, ConcurrentMap<String, AnnotatedType<?>>> additionalAnnotatedTypes = new ConcurrentHashMap<Class<?>, ConcurrentMap<String, AnnotatedType<?>>>();
 
     private ErrorStack errorStack = new ErrorStack();
     
@@ -172,7 +172,7 @@ public class BeanManagerImpl extends Abs
      * This map stores all beans along with their unique {@link javax.enterprise.inject.spi.PassivationCapable} id.
      * This is used as a reference for serialization.
      */
-    private ConcurrentHashMap<String, Bean<?>> passivationBeans = new ConcurrentHashMap<String, Bean<?>>(); 
+    private ConcurrentMap<String, Bean<?>> passivationBeans = new ConcurrentHashMap<String, Bean<?>>(); 
 
     /**InjectionTargets for Java EE component instances that supports injections*/
     private Map<Class<?>, Producer<?>> producersForJavaEeComponents =
@@ -1000,14 +1000,41 @@ public class BeanManagerImpl extends Abs
 
     public void addAdditionalAnnotatedType(AnnotatedType<?> annotatedType)
     {
-        webBeansContext.getAnnotatedElementFactory().setAnnotatedType(annotatedType);
-        additionalAnnotatedTypes.put(null, annotatedType);
+        addAdditionalAnnotatedType(annotatedType, AnnotatedElementFactory.OWB_DEFAULT_KEY);
     }
 
     public void addAdditionalAnnotatedType(AnnotatedType<?> annotatedType, String id)
     {
-        webBeansContext.getAnnotatedElementFactory().setAnnotatedType(annotatedType);
-        additionalAnnotatedTypes.put(id, annotatedType);
+        webBeansContext.getAnnotatedElementFactory().setAnnotatedType(annotatedType, id);
+        ConcurrentMap<String, AnnotatedType<?>> annotatedTypes = additionalAnnotatedTypes.get(annotatedType.getJavaClass());
+        if (annotatedTypes == null)
+        {
+            annotatedTypes = new ConcurrentHashMap<String, AnnotatedType<?>>();
+            ConcurrentMap<String, AnnotatedType<?>> oldAnnotatedTypes = additionalAnnotatedTypes.putIfAbsent(annotatedType.getJavaClass(), annotatedTypes);
+            if (oldAnnotatedTypes != null)
+            {
+                annotatedTypes = oldAnnotatedTypes;
+            }
+        }
+        annotatedTypes.put(id, annotatedType);
+    }
+
+    public void removeAdditionalAnnotatedType(AnnotatedType<?> annotatedType)
+    {
+        removeAdditionalAnnotatedType(annotatedType, AnnotatedElementFactory.OWB_DEFAULT_KEY);
+    }
+
+    public void removeAdditionalAnnotatedType(AnnotatedType<?> annotatedType, String id)
+    {
+        ConcurrentMap<String, AnnotatedType<?>> annotatedTypes = additionalAnnotatedTypes.get(annotatedType.getJavaClass());
+        if (annotatedTypes == null)
+        {
+            return;
+        }
+        if (annotatedType.equals(annotatedTypes.get(id)))
+        {
+            annotatedTypes.remove(id);
+        }
     }
 
     public List<Class<? extends Annotation>> getAdditionalQualifiers()
@@ -1031,20 +1058,22 @@ public class BeanManagerImpl extends Abs
 
     public Collection<AnnotatedType<?>> getAdditionalAnnotatedTypes()
     {
-        return additionalAnnotatedTypes.values();
+        Collection<AnnotatedType<?>> annotatedTypes = new ArrayList<AnnotatedType<?>>();
+        for (ConcurrentMap<String,AnnotatedType<?>> types: additionalAnnotatedTypes.values())
+        {
+            annotatedTypes.addAll(types.values());
+        }
+        return annotatedTypes;
     }
 
     public <T> AnnotatedType<T> getAdditionalAnnotatedType(Class<T> type, String id)
     {
-        AnnotatedType<?> annotatedType = additionalAnnotatedTypes.get(id);
-        if (annotatedType.getJavaClass().equals(type))
-        {
-            return (AnnotatedType<T>) annotatedType;
-        }
-        else
+        ConcurrentMap<String, AnnotatedType<?>> annotatedTypes = additionalAnnotatedTypes.get(type);
+        if (annotatedTypes == null)
         {
             return null;
         }
+        return (AnnotatedType<T>)annotatedTypes.get(id);
     }
 
     public void clear()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java?rev=1480743&r1=1480742&r2=1480743&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java Thu May  9 19:30:06 2013
@@ -44,7 +44,7 @@ import org.apache.webbeans.util.Asserts;
 public final class AnnotatedElementFactory
 {
     
-    private static final String OWB_DEFAULT_KEY = "OWB_DEFAULT_KEY";
+    public static final String OWB_DEFAULT_KEY = "OWB_DEFAULT_KEY";
 
     // Logger instance
     private final static Logger logger = WebBeansLoggerFacade.getLogger(AnnotatedElementFactory.class);