openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1601023 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java container/AbstractBeanManager.java intercept/InterceptorsManager.java portable/AnnotatedElementFactory.java
Date Fri, 06 Jun 2014 22:00:00 GMT
Author: struberg
Date: Fri Jun  6 22:00:00 2014
New Revision: 1601023

URL: http://svn.apache.org/r1601023
Log:
OWB-969 BeanManager#createAnnotatedType must not reflect Extension changes

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/AbstractBeanManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.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=1601023&r1=1601022&r2=1601023&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
Fri Jun  6 22:00:00 2014
@@ -932,7 +932,11 @@ public class BeansDeployer
             else
             {
                 Annotation[] classAnnotations;
-                AnnotatedType<?> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(clazz);
+                AnnotatedType<?> annotatedType = webBeansContext.getAnnotatedElementFactory().getAnnotatedType(clazz);
+                if (annotatedType == null)
+                {
+                    annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(clazz);
+                }
 
                 ProcessAnnotatedTypeImpl<?> processAnnotatedEvent =
                         webBeansContext.getWebBeansUtil().fireProcessAnnotatedTypeEvent(annotatedType);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AbstractBeanManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AbstractBeanManager.java?rev=1601023&r1=1601022&r2=1601023&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AbstractBeanManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AbstractBeanManager.java
Fri Jun  6 22:00:00 2014
@@ -120,10 +120,15 @@ public abstract class AbstractBeanManage
 
     public <T> Bean<T> createBean(BeanAttributes<T> attributes, Class<T>
type, InjectionTargetFactory<T> factory)
     {
+        AnnotatedType<T> annotatedType = getWebBeansContext().getAnnotatedElementFactory().getAnnotatedType(type);
+        if (annotatedType == null)
+        {
+            annotatedType = getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(type);
+        }
         return new InjectionTargetBean<T>(
                 getWebBeansContext(),
                 WebBeansType.THIRDPARTY,
-                getWebBeansContext().getAnnotatedElementFactory().newAnnotatedType(type),
+                annotatedType,
                 attributes,
                 type,
                 factory);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java?rev=1601023&r1=1601022&r2=1601023&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
Fri Jun  6 22:00:00 2014
@@ -123,7 +123,12 @@ public class InterceptorsManager
         Interceptor<T> interceptor = (Interceptor<T>) ejbInterceptors.get(interceptorClass);
         if (interceptor == null)
         {
-            AnnotatedType<T> annotatedType = webBeansContext.getBeanManagerImpl().createAnnotatedType(interceptorClass);
+            AnnotatedType<T> annotatedType = webBeansContext.getAnnotatedElementFactory().getAnnotatedType(interceptorClass);
+            if (annotatedType == null)
+            {
+                annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(interceptorClass);
+            }
+
             BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build();
             EjbInterceptorBeanBuilder<T> buildr = new EjbInterceptorBeanBuilder<T>(webBeansContext,
annotatedType, beanAttributes);
             buildr.defineEjbInterceptorRules();

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=1601023&r1=1601022&r2=1601023&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
Fri Jun  6 22:00:00 2014
@@ -49,10 +49,18 @@ public final class AnnotatedElementFacto
     // Logger instance
     private final static Logger logger = WebBeansLoggerFacade.getLogger(AnnotatedElementFactory.class);
 
-    //Cache of the AnnotatedType
+    /**
+     * Cache of the initial AnnotatedTypes
+     */
     private ConcurrentMap<Class<?>, ConcurrentMap<String, AnnotatedType<?>>>
annotatedTypeCache =
         new ConcurrentHashMap<Class<?>, ConcurrentMap<String, AnnotatedType<?>>>();
-    
+
+    /**
+     * Cache of modified AnnotatedTypes.
+     */
+    private ConcurrentMap<Class<?>, ConcurrentMap<String, AnnotatedType<?>>>
modifiedAnnotatedTypeCache =
+        new ConcurrentHashMap<Class<?>, ConcurrentMap<String, AnnotatedType<?>>>();
+
     //Cache of AnnotatedConstructor
     private ConcurrentMap<Constructor<?>, AnnotatedConstructor<?>> annotatedConstructorCache
=
         new ConcurrentHashMap<Constructor<?>, AnnotatedConstructor<?>>();
@@ -77,12 +85,22 @@ public final class AnnotatedElementFacto
 
     /**
      * Get an already registered AnnotatedType. This will NOT create a new one!
-     * @param annotatedClass
-     * @param <X>
-     * @return AnnotatedType
+     * The returned AnnotatedType will reflect all the changes made during the
+     * boot process so far.
+     * If there was no AnnotatedType created yet for the given Class,
+     * <code>null</code> will be returned.
      */
     public <X> AnnotatedType<X> getAnnotatedType(Class<X> annotatedClass)
     {
+        ConcurrentMap<String, AnnotatedType<?>> modifiedAnnotatedClasses = modifiedAnnotatedTypeCache.get(annotatedClass);
+        if (modifiedAnnotatedClasses != null)
+        {
+            AnnotatedType<X> annotatedType = (AnnotatedType<X>) modifiedAnnotatedClasses.get(OWB_DEFAULT_KEY);
+            if (annotatedType != null)
+            {
+                return annotatedType;
+            }
+        }
         return getAnnotatedTypeCache(annotatedClass).get(OWB_DEFAULT_KEY);
     }
 
@@ -114,12 +132,27 @@ public final class AnnotatedElementFacto
 
     public <X> AnnotatedType<X> setAnnotatedType(AnnotatedType<X> annotatedType,
String id)
     {
-        ConcurrentMap<String, AnnotatedType<X>> annotatedTypes = getAnnotatedTypeCache(annotatedType.getJavaClass());
+        Class<X> type = annotatedType.getJavaClass();
+        ConcurrentMap<String, AnnotatedType<?>> annotatedTypes = modifiedAnnotatedTypeCache.get(type);
+        if (annotatedTypes == null)
+        {
+            annotatedTypes = new ConcurrentHashMap<String, AnnotatedType<?>>();
+        }
+        ConcurrentMap<String, AnnotatedType<?>> oldAnnotatedTypes = modifiedAnnotatedTypeCache.putIfAbsent(type,
annotatedTypes);
+        if (oldAnnotatedTypes != null)
+        {
+            annotatedTypes = oldAnnotatedTypes;
+        }
         return (AnnotatedType<X>) annotatedTypes.put(id, annotatedType);
     }
 
     /**
-     * Creates and configures new annotated type.
+     * Creates and configures a new annotated type.
+     * This always returns the fresh AnnotatedTypes <b>without</b> any modifications
+     * applied by Extensions!.
+     *
+     * To get any AnnotatedTypes which are modified during the boot process you shall use
+     * {@link #getAnnotatedType(Class)}.
      * 
      * @param <X> class info
      * @param annotatedClass annotated class



Mime
View raw message