openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1606593 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Date Sun, 29 Jun 2014 19:57:55 GMT
Author: struberg
Date: Sun Jun 29 19:57:55 2014
New Revision: 1606593

URL: http://svn.apache.org/r1606593
Log:
stereotypes directly on a producer might also activate it as Alternative

Before that you could not enable an @Alternative producer field or method
via enabling the @Stereotype directly on the producer but it needed to be 
enabled on the parent class.

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1606593&r1=1606592&r2=1606593&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Sun Jun 29 19:57:55 2014
@@ -1107,17 +1107,12 @@ public final class WebBeansUtil
 
     public boolean isBeanEnabled(AnnotatedType<?> at, Set<Class<? extends Annotation>>
stereotypes)
     {
-        boolean isAlternative = hasInjectionTargetBeanAnnotatedWithAlternative(at, stereotypes);
+        boolean isAlternative = isAlternative(at, stereotypes);
 
         return !isAlternative || webBeansContext.getAlternativesManager().isAlternative(at.getJavaClass(),
stereotypes);
     }
 
-    public static boolean hasInjectionTargetBeanAnnotatedWithAlternative(InjectionTargetBean<?>
bean)
-    {
-        return hasInjectionTargetBeanAnnotatedWithAlternative(bean.getAnnotatedType(), bean.getStereotypes());
-    }
-    
-    public static boolean hasInjectionTargetBeanAnnotatedWithAlternative(AnnotatedType<?>
beanType, Set<Class<? extends Annotation>> stereotypes)
+    public static boolean isAlternative(AnnotatedType<?> beanType, Set<Class<?
extends Annotation>> stereotypes)
     {
         Asserts.assertNotNull(beanType, "bean type can not be null");
         Asserts.assertNotNull(stereotypes, "stereotypes can not be null");
@@ -1150,11 +1145,7 @@ public final class WebBeansUtil
     {
         Asserts.assertNotNull(parent, "parent can not be null");
         Asserts.assertNotNull(producer, "producer can not be null");
-        producer.setEnabled(isProducerBeanEnabled(parent, producer.getStereotypes(), annotations));
-    }
-    
-    public boolean isProducerBeanEnabled(InjectionTargetBean<?> parent, Set<Class<?
extends Annotation>> stereotypes, Annotation[] annotations)
-    {
+        Set<Class<? extends Annotation>> stereotypes = producer.getStereotypes();
 
         boolean alternative = false;
 
@@ -1177,12 +1168,14 @@ public final class WebBeansUtil
 
         if (alternative)
         {
-            return hasInjectionTargetBeanAnnotatedWithAlternative(parent) &&
-                    webBeansContext.getAlternativesManager().isAlternative(parent);
+            // either the parent class is an enabled Alternative
+            // or the stereotype directly on the producer field or method is an enabled Alternative
+            producer.setEnabled(isAlternative(parent.getAnnotatedType(), parent.getStereotypes())
&& webBeansContext.getAlternativesManager().isAlternative(parent) ||
+                                isAlternative(parent.getAnnotatedType(), stereotypes) &&
webBeansContext.getAlternativesManager().isAlternative(producer));
         }
         else
         {
-            return parent.isEnabled();
+            producer.setEnabled(parent.isEnabled());
         }
     }
 



Mime
View raw message