openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1672505 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java container/InjectionResolver.java
Date Thu, 09 Apr 2015 22:01:16 GMT
Author: rmannibucau
Date: Thu Apr  9 22:01:15 2015
New Revision: 1672505

URL: http://svn.apache.org/r1672505
Log:
better matching for producer alternatives - works for fields too

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/InjectionResolver.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=1672505&r1=1672504&r2=1672505&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 Apr  9 22:01:15 2015
@@ -1541,7 +1541,15 @@ public class BeansDeployer
                 Map<ProducerMethodBean<?>,AnnotatedMethod<?>> annotatedMethods
=
                         new HashMap<ProducerMethodBean<?>, AnnotatedMethod<?>>();
 
-                final Priority priority = annotatedType.getAnnotation(Priority.class);
+                if (!producerFields.isEmpty() || !producerMethods.isEmpty())
+                {
+                    final Priority priority = annotatedType.getAnnotation(Priority.class);
+                    if (priority != null && !webBeansContext.getAlternativesManager()
+                            .isAlternative(annotatedType.getJavaClass(), Collections.<Class<?
extends Annotation>>emptySet()))
+                    {
+                        webBeansContext.getAlternativesManager().addPriorityClazzAlternative(annotatedType.getJavaClass(),
priority);
+                    }
+                }
 
                 for(ProducerMethodBean<?> producerMethod : producerMethods)
                 {
@@ -1550,10 +1558,6 @@ public class BeansDeployer
                             + "ProducerMethods. Look at logs for further details");
 
                     annotatedMethods.put(producerMethod, method);
-                    if (priority != null)
-                    {
-                        webBeansContext.getAlternativesManager().addPriorityClazzAlternative(method.getJavaMember().getReturnType(),
priority);
-                    }
                 }
 
                 Map<ProducerFieldBean<?>,AnnotatedField<?>> annotatedFields
=
@@ -1568,10 +1572,6 @@ public class BeansDeployer
                             webBeansContext.getAnnotatedElementFactory().newAnnotatedField(
                                     producerField.getCreatorField(),
                                     webBeansContext.getAnnotatedElementFactory().newAnnotatedType(producerField.getBeanClass())));
-                    if (priority != null)
-                    {
-                        webBeansContext.getAlternativesManager().addPriorityClazzAlternative(producerField.getCreatorField().getType(),
priority);
-                    }
                 }
 
                 Map<ObserverMethod<?>,AnnotatedMethod<?>> observerMethodsMap
=

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=1672505&r1=1672504&r2=1672505&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
Thu Apr  9 22:01:15 2015
@@ -568,8 +568,7 @@ public class InjectionResolver
         {
             for (Bean<? extends X> bean: beans)
             {
-                final Class<?> type = OwbBean.class.isInstance(bean) ? OwbBean.class.cast(bean)
.getReturnType() : bean.getBeanClass();
-                if (alternativeClazz.equals(type))
+                if (alternativeClazz.equals(bean.getBeanClass()))
                 {
                     return new SingleItemSet<Bean<? extends X>>(bean);
                 }



Mime
View raw message