openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1647686 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java container/BeanManagerImpl.java container/InjectionResolver.java portable/events/discovery/BeforeBeanDiscoveryImpl.java
Date Tue, 23 Dec 2014 22:17:42 GMT
Author: rmannibucau
Date: Tue Dec 23 22:17:41 2014
New Revision: 1647686

URL: http://svn.apache.org/r1647686
Log:
supporting addQualifier(AnnotatedType) and trying to skip producer definition only when relevant
- this last part is to clarified a bit

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/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.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=1647686&r1=1647685&r2=1647686&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
Tue Dec 23 22:17:41 2014
@@ -37,7 +37,6 @@ import org.apache.webbeans.component.cre
 import org.apache.webbeans.component.creation.ObserverMethodsBuilder;
 import org.apache.webbeans.component.creation.ProducerFieldBeansBuilder;
 import org.apache.webbeans.component.creation.ProducerMethodBeansBuilder;
-import org.apache.webbeans.container.AnnotatedTypeWrapper;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.InjectableBeanManager;
 import org.apache.webbeans.container.InjectionResolver;
@@ -1059,7 +1058,7 @@ public class BeansDeployer
         {
             try
             {
-                deploySingleAnnotatedType(annotatedType.getKey(), annotatedType.getValue());
+                deploySingleAnnotatedType(annotatedType.getKey(), annotatedType.getValue(),
annotatedTypes);
             }
             catch (NoClassDefFoundError ncdfe)
             {
@@ -1084,7 +1083,7 @@ public class BeansDeployer
      * 
      * @param annotatedTypeData the AnnotatedType representing the bean to be deployed with
their already computed data
      */
-    private void deploySingleAnnotatedType(AnnotatedType annotatedType, AnnotatedTypeData
annotatedTypeData)
+    private void deploySingleAnnotatedType(AnnotatedType annotatedType, AnnotatedTypeData
annotatedTypeData, Map<AnnotatedType<?>, AnnotatedTypeData<?>> annotatedTypes)
     {
 
         Class beanClass = annotatedType.getJavaClass();
@@ -1102,7 +1101,7 @@ public class BeansDeployer
                 if((ClassUtil.isConcrete(beanClass) || WebBeansUtil.isDecorator(annotatedType))
                         && isValidManagedBean(annotatedType))
                 {
-                    defineManagedBean(annotatedType, annotatedTypeData.beanAttributes);
+                    defineManagedBean(annotatedType, annotatedTypeData.beanAttributes, annotatedTypes);
                 }
             }
             catch (NoClassDefFoundError ncdfe)
@@ -1425,7 +1424,7 @@ public class BeansDeployer
      * Defines and configures managed bean.
      * @param <T> type info
      */
-    protected <T> void defineManagedBean(AnnotatedType<T> annotatedType, BeanAttributes<T>
attributes)
+    protected <T> void defineManagedBean(AnnotatedType<T> annotatedType, BeanAttributes<T>
attributes, Map<AnnotatedType<?>, AnnotatedTypeData<?>> annotatedTypes)
     {   
         //Fires ProcessInjectionTarget event for Java EE components instances
         //That supports injections but not managed beans
@@ -1491,7 +1490,8 @@ public class BeansDeployer
 
                 final Set<ObserverMethod<?>> observerMethods;
                 final AnnotatedType<T> beanAnnotatedType = bean.getAnnotatedType();
-                final boolean ignoreProducer = AnnotatedTypeWrapper.class.isInstance(beanAnnotatedType);
+                final AnnotatedType<T> defaultAt = webBeansContext.getAnnotatedElementFactory().getAnnotatedType(beanAnnotatedType.getJavaClass());
+                final boolean ignoreProducer = defaultAt != beanAnnotatedType &&
annotatedTypes.containsKey(defaultAt);
                 if(bean.isEnabled())
                 {
                     observerMethods = new ObserverMethodsBuilder<T>(webBeansContext,
beanAnnotatedType).defineObserverMethods(bean);

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=1647686&r1=1647685&r2=1647686&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
Tue Dec 23 22:17:41 2014
@@ -150,6 +150,7 @@ public class BeanManagerImpl implements
      * event function.
      */
     private List<Class<? extends Annotation>> additionalQualifiers = new ArrayList<Class<?
extends Annotation>>();
+    private Map<Class<?>, AnnotatedType<? extends Annotation>> additionalAnnotatedTypeQualifiers
= new HashMap<Class<?>, AnnotatedType<? extends Annotation>>();
 
     /**
      * This list contains additional interceptor bindings which got set via the
@@ -1225,6 +1226,14 @@ public class BeanManagerImpl implements
             additionalQualifiers.add(qualifier);
         }
     }
+    public void addAdditionalQualifier(AnnotatedType<? extends Annotation> qualifier)
+    {
+        if (!additionalQualifiers.contains(qualifier))
+        {
+            additionalAnnotatedTypeQualifiers.put(qualifier.getJavaClass(), qualifier);
+            additionalQualifiers.add(qualifier.getJavaClass());
+        }
+    }
 
     public void addAdditionalInterceptorBindings(Class<? extends Annotation> interceptorBinding)
     {
@@ -1285,6 +1294,11 @@ public class BeanManagerImpl implements
         return additionalQualifiers;
     }
 
+    public Map<Class<?>, AnnotatedType<? extends Annotation>> getAdditionalAnnotatedTypeQualifiers()
+    {
+        return additionalAnnotatedTypeQualifiers;
+    }
+
     public void addAdditionalScope(ExternalScope additionalScope)
     {
         if (!additionalScopes.contains(additionalScope))

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=1647686&r1=1647685&r2=1647686&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
Tue Dec 23 22:17:41 2014
@@ -43,6 +43,7 @@ import javax.enterprise.event.Event;
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.New;
 import javax.enterprise.inject.UnproxyableResolutionException;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.DefinitionException;
 import javax.enterprise.inject.spi.DeploymentException;
@@ -655,9 +656,20 @@ public class InjectionResolver
                     Annotation qualifier = itQualifiers.next();
                     if (annot.annotationType().equals(qualifier.annotationType()))
                     {
-                        if (AnnotationUtil.isCdiAnnotationEqual(qualifier, annot))
+                        AnnotatedType<?> at = webBeansContext.getBeanManagerImpl().getAdditionalAnnotatedTypeQualifiers().get(qualifier.annotationType());
+                        if (at == null)
                         {
-                            i++;
+                            if (AnnotationUtil.isCdiAnnotationEqual(qualifier, annot))
+                            {
+                                i++;
+                            }
+                        }
+                        else
+                        {
+                            if (AnnotationUtil.isCdiAnnotationEqual(at, qualifier, annot))
+                            {
+                                i++;
+                            }
                         }
                     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java?rev=1647686&r1=1647685&r2=1647686&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
Tue Dec 23 22:17:41 2014
@@ -158,7 +158,7 @@ public class BeforeBeanDiscoveryImpl imp
         {
             throw new IllegalStateException("Only call container eevnt methods in their lifecycle");
         }
-        beanManager.addAdditionalQualifier(annotatedType.getJavaClass());
+        beanManager.addAdditionalQualifier(annotatedType);
     }
 
     public void setExtension(final Object extension)



Mime
View raw message