Author: struberg
Date: Fri May 26 19:45:32 2017
New Revision: 1796331
URL: http://svn.apache.org/viewvc?rev=1796331&view=rev
Log:
OWB-1182 <alternative> is also allowed if the class only has an @Alternative
producer method
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
openwebbeans/trunk/webbeans-tck/standalone-suite.xml
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=1796331&r1=1796330&r2=1796331&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 May 26 19:45:32 2017
@@ -53,6 +53,7 @@ import org.apache.webbeans.exception.Web
import javax.annotation.Priority;
import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Produces;
import javax.enterprise.inject.Vetoed;
import javax.enterprise.inject.spi.BeanAttributes;
import javax.enterprise.inject.spi.DefinitionException;
@@ -751,12 +752,18 @@ public class BeansDeployer
for (Class<?> alternativeClass : xmlConfiguredAlternatives)
{
+ // If the class itself is annotated with @Alternative, then all is
fine
if (AnnotationUtil.hasClassAnnotation(alternativeClass,
Alternative.class) ||
AnnotationUtil.hasMetaAnnotation(alternativeClass.getAnnotations(),
Alternative.class))
{
continue;
}
+ if (hasAlternativeProducerMethod(alternativeClass))
+ {
+ continue;
+ }
+
boolean foundAlternativeClass = false;
Set<Bean<?>> beans = injectionResolver.implResolveByType(false,
alternativeClass, AnyLiteral.INSTANCE);
@@ -800,6 +807,23 @@ public class BeansDeployer
}
+ private boolean hasAlternativeProducerMethod(Class<?> alternativeClass)
+ {
+ // It's also ok if the class has an @Alternative producer method
+ List<Method> nonPrivateMethods =
ClassUtil.getNonPrivateMethods(alternativeClass, true);
+ for (Method method : nonPrivateMethods)
+ {
+ if ((method.getAnnotation(Alternative.class) != null ||
+ AnnotationUtil.hasMetaAnnotation(method.getAnnotations(),
Alternative.class))
+ && method.getAnnotation(Produces.class) != null )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Validate all injection points.
Modified: openwebbeans/trunk/webbeans-tck/standalone-suite.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/standalone-suite.xml?rev=1796331&r1=1796330&r2=1796331&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/standalone-suite.xml (original)
+++ openwebbeans/trunk/webbeans-tck/standalone-suite.xml Fri May 26 19:45:32
2017
@@ -55,6 +55,135 @@
<classes>
+
+<!--
+ Tests broken in the CDI-1.2 TCK:
+
+ <!– Issues in the spec –>
+ <!– CDI-437 –>
+ <class
name="org.jboss.cdi.tck.tests.lookup.byname.ambiguous.broken.AmbiguousELNamesTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
+
+ <!– Issues in the TCK –>
+ <!– CDITCK-444 –>
+ <class
name="org.jboss.cdi.tck.tests.extensions.lifecycle.processBeanAttributes.broken.invalid.InvalidStereotypeTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
+
+ <!– CDITCK-418 –>
+ <class
name="org.jboss.cdi.tck.interceptors.tests.contract.interceptorLifeCycle.environment.jndi.ejb.InterceptorEnvironmentJNDISessionBeanTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
+
+ <!– CDITCK-417 –>
+ <class
name="org.jboss.cdi.tck.tests.extensions.registration.BeanRegistrationByExtensionInEarLibraryTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
+
+ <!– CDITCK-421 –>
+ <class
name="org.jboss.cdi.tck.interceptors.tests.contract.aroundInvoke.AroundInvokeAccessInterceptorTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
+
+ <!– CDITCK-427 –>
+ <class
name="org.jboss.cdi.tck.tests.lookup.circular.CircularDependencyTest">
+ <methods>
+ <exclude
name="testDependentProducerMethodDeclaredOnNormalBeanWhichInjectsProducedBean"/>
+ </methods>
+ </class>
+
+ <!– CDITCK-428 –>
+ <class
name="org.jboss.cdi.tck.interceptors.tests.contract.interceptorLifeCycle.InterceptorLifeCycleTest">
+ <methods>
+ <exclude
name="testInterceptorInstanceCreatedWhenTargetInstanceCreated"/>
+ </methods>
+ </class>
+
+ <class
name="org.jboss.cdi.tck.interceptors.tests.contract.aroundTimeout.AroundTimeoutInterceptorTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
+
+ <!– CDITCK-423 –>
+ <class
name="org.jboss.cdi.tck.tests.implementation.enterprise.definition.remote.RemoteInterfaceNotInAPITypesTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
+
+ <!– CDITCK-437 –>
+ <class
name="org.jboss.cdi.tck.tests.decorators.interceptor.DecoratorAndInterceptorTest">
+ <methods>
+ <exclude name="testLifecycleCallbacks"/>
+ </methods>
+ </class>
+
+ <!– CDITCK-449 –>
+ <class
name="org.jboss.cdi.tck.tests.extensions.beanManager.beanAttributes.CreateBeanAttributesTest">
+ <methods>
+ <exclude
name="testBeanAttributesForManagedBeanWithModifiedAnnotatedType"/>
+ </methods>
+ </class>
+
+ <!– CDITCK-466 –>
+ <class
name="org.jboss.cdi.tck.tests.extensions.lifecycle.bbd.broken.passivatingScope.AddingPassivatingScopeTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
+
+ <!– CDI-514 (issue got moved from original CDITC
–>
+ <class name="org.jboss.cdi.tck.tests.event.fires.FireEventTest">
+ <methods>
+ <exclude name="testDuplicateBindingsToFireEventFails"/>
+ </methods>
+ </class>
+ <class name="org.jboss.cdi.tck.tests.event.select.SelectEventTest">
+ <methods>
+ <exclude name=".*DuplicateBindingType"/>
+ </methods>
+ </class>
+ <class
name="org.jboss.cdi.tck.tests.event.resolve.binding.DuplicateBindingTypesWhenResolvingTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
+ <class
name="org.jboss.cdi.tck.tests.lookup.dynamic.DynamicLookupTest">
+ <methods>
+ <exclude name="testDuplicateBindingsThrowsException"/>
+ </methods>
+ </class>
+ <class
name="org.jboss.cdi.tck.tests.extensions.bean.bytype.BeanByTypeTest">
+ <methods>
+ <exclude name="testSameBindingTwice"/>
+ </methods>
+ </class>
+ <class
name="org.jboss.cdi.tck.tests.interceptors.definition.InterceptorDefinitionTest">
+ <methods>
+ <exclude
name="testSameBindingTypesToResolveInterceptorsFails"/>
+ </methods>
+ </class>
+
+
+ <!– CDI-517 –>
+ <class
name="org.jboss.cdi.tck.tests.lookup.typesafe.resolution.parameterized.raw.RawBeanTypeParameterizedRequiredTypeTest">
+ <methods>
+ <exclude name="testNotAssignableTypeParams"/>
+ </methods>
+ </class>
+-->
</classes>