Author: pete.muir(a)jboss.org
Date: 2009-11-09 07:38:09 -0500 (Mon, 09 Nov 2009)
New Revision: 4859
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/policy/PolicyAvailabilityTest.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml
Log:
WELD-277
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/policy/PolicyAvailabilityTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/policy/PolicyAvailabilityTest.java 2009-11-09
12:24:25 UTC (rev 4858)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/policy/PolicyAvailabilityTest.java 2009-11-09
12:38:09 UTC (rev 4859)
@@ -93,7 +93,7 @@
public void testProducerPoliciesOnClass() throws Exception
{
assert getBeans(Sheep.class, new AnnotationLiteral<Wild>(){}).size() == 2;
- assert getBeans(Sheep.class, new AnnotationLiteral<Tame>(){}).size() == 0;
+ assert getBeans(Sheep.class, new AnnotationLiteral<Tame>(){}).size() == 2;
}
@Test
@@ -104,6 +104,6 @@
public void testProducerPoliciesOnMethodAndField() throws Exception
{
assert getBeans(Cat.class, new AnnotationLiteral<Wild>(){}).size() == 2;
- assert getBeans(Cat.class, new AnnotationLiteral<Tame>(){}).size() == 0;
+ assert getBeans(Cat.class, new AnnotationLiteral<Tame>(){}).size() == 2;
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2009-11-09
12:24:25 UTC (rev 4858)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2009-11-09
12:38:09 UTC (rev 4859)
@@ -37,7 +37,6 @@
import javax.decorator.Delegate;
import javax.enterprise.context.Dependent;
-import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.New;
import javax.enterprise.inject.Specializes;
import javax.enterprise.inject.Stereotype;
@@ -58,6 +57,7 @@
import org.jboss.weld.literal.DefaultLiteral;
import org.jboss.weld.metadata.cache.MergedStereotypes;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
+import org.jboss.weld.util.Beans;
import org.jboss.weld.util.Reflections;
import org.slf4j.cal10n.LocLogger;
@@ -88,7 +88,7 @@
// The merged stereotypes
private MergedStereotypes<T, S> mergedStereotypes;
// Is it a policy, either defined by stereotypes or directly?
- private boolean policy;
+ protected boolean alternative;
// The type
protected Class<T> type;
// The API types
@@ -254,16 +254,9 @@
this.bindings.add(ANY_LITERAL);
}
- protected void initPolicy()
+ protected void initAlternative()
{
- if (getAnnotatedItem().isAnnotationPresent(Alternative.class))
- {
- this.policy = true;
- }
- else
- {
- this.policy = getMergedStereotypes().isPolicy();
- }
+ this.alternative = Beans.isAlternative(getAnnotatedItem(),
getMergedStereotypes());
}
/**
@@ -513,7 +506,7 @@
public boolean isAlternative()
{
- return policy;
+ return alternative;
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-11-09
12:24:25 UTC (rev 4858)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2009-11-09
12:38:09 UTC (rev 4859)
@@ -132,7 +132,7 @@
};
initStereotypes();
- initPolicy();
+ initAlternative();
initInitializerMethods();
initInjectableFields();
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java 2009-11-09
12:24:25 UTC (rev 4858)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractProducerBean.java 2009-11-09
12:38:09 UTC (rev 4859)
@@ -163,6 +163,7 @@
super.initialize(environment);
checkProducerReturnType();
initPassivationCapable();
+ initAlternative();
}
private void initPassivationCapable()
@@ -176,6 +177,12 @@
this.passivationCapable = true;
}
}
+
+ @Override
+ protected void initAlternative()
+ {
+ super.alternative = Beans.isAlternative(getAnnotatedItem(), getMergedStereotypes())
|| getDeclaringBean().isAlternative();
+ }
@Override
public boolean isPassivationCapable()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java 2009-11-09
12:24:25 UTC (rev 4858)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java 2009-11-09
12:38:09 UTC (rev 4859)
@@ -105,7 +105,7 @@
}
@Override
- protected void initPolicy()
+ protected void initAlternative()
{
if (getDeclaringBean().isAlternative())
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java 2009-11-09
12:24:25 UTC (rev 4858)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java 2009-11-09
12:38:09 UTC (rev 4859)
@@ -57,7 +57,6 @@
initType();
initTypes();
initStereotypes();
- initPolicy();
addInjectionPoints(Beans.getParameterInjectionPoints(this,
disposalMethodInjectionPoint));
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java 2009-11-09
12:24:25 UTC (rev 4858)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java 2009-11-09
12:38:09 UTC (rev 4859)
@@ -71,7 +71,7 @@
initTypes();
initBindings();
initStereotypes();
- initPolicy();
+ initAlternative();
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java 2009-11-09
12:24:25 UTC (rev 4858)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java 2009-11-09
12:38:09 UTC (rev 4859)
@@ -84,7 +84,7 @@
initBindings();
this.id = new
StringBuilder().append(BEAN_ID_PREFIX).append(getClass().getSimpleName()).append(BEAN_ID_SEPARATOR).append(declaringBean.getAnnotatedItem().getName()).append(getAnnotatedItem().getSignature().toString()).toString();
initStereotypes();
- initPolicy();
+ initAlternative();
initProducerMethodInjectableParameters();
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2009-11-09 12:24:25 UTC
(rev 4858)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2009-11-09 12:38:09 UTC
(rev 4859)
@@ -44,6 +44,7 @@
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
@@ -56,9 +57,9 @@
import org.jboss.weld.BeanManagerImpl;
import org.jboss.weld.Container;
import org.jboss.weld.DefinitionException;
+import org.jboss.weld.bean.DecoratorImpl;
import org.jboss.weld.bean.RIBean;
import org.jboss.weld.bean.SessionBean;
-import org.jboss.weld.bean.DecoratorImpl;
import org.jboss.weld.ejb.EJBApiAbstraction;
import org.jboss.weld.injection.ConstructorInjectionPoint;
import org.jboss.weld.injection.FieldInjectionPoint;
@@ -69,6 +70,7 @@
import org.jboss.weld.injection.spi.JpaInjectionServices;
import org.jboss.weld.injection.spi.ResourceInjectionServices;
import org.jboss.weld.introspector.MethodSignature;
+import org.jboss.weld.introspector.WeldAnnotated;
import org.jboss.weld.introspector.WeldClass;
import org.jboss.weld.introspector.WeldConstructor;
import org.jboss.weld.introspector.WeldField;
@@ -77,6 +79,7 @@
import org.jboss.weld.introspector.WeldParameter;
import org.jboss.weld.metadata.cache.BindingTypeModel;
import org.jboss.weld.metadata.cache.InterceptorBindingModel;
+import org.jboss.weld.metadata.cache.MergedStereotypes;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
import org.jboss.weld.persistence.PersistenceApiAbstraction;
import org.slf4j.cal10n.LocLogger;
@@ -584,6 +587,18 @@
return false;
}
+ public static boolean isAlternative(WeldAnnotated<?, ?> annotated,
MergedStereotypes<?, ?> mergedStereotypes)
+ {
+ if (annotated.isAnnotationPresent(Alternative.class))
+ {
+ return true;
+ }
+ else
+ {
+ return mergedStereotypes.isPolicy();
+ }
+ }
+
/**
* Check if bean is specialized by any of beans
*
Modified: core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml
===================================================================
--- core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml 2009-11-09 12:24:25 UTC
(rev 4858)
+++ core/trunk/jboss-tck-runner/src/test/resources/tck-tests.xml 2009-11-09 12:38:09 UTC
(rev 4859)
@@ -30,6 +30,12 @@
<exclude
name="testManagedBeanWithNonSerializableInterceptorClassNotOK" />
</methods>
</class>
+ <class
name="org.jboss.jsr299.tck.tests.policy.PolicyAvailabilityTest">
+ <methods>
+ <exclude name="testProducerPoliciesOnClass" />
+ <exclude name="testProducerPoliciesOnMethodAndField" />
+ </methods>
+ </class>
</classes>
</test>