Author: kabir.khan(a)jboss.com
Date: 2009-09-17 11:02:18 -0400 (Thu, 17 Sep 2009)
New Revision: 3697
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentItem.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java
Log:
@Specialized on producer methods need to be taken into account, as well @Specialized on
class itself which was already done
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java 2009-09-17
12:54:36 UTC (rev 3696)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java 2009-09-17
15:02:18 UTC (rev 3697)
@@ -271,6 +271,7 @@
@Override
protected void specialize(BeanDeployerEnvironment environment)
{
+ System.out.println("======> " + this);
WBMethod<?, ?> superClassMethod =
getDeclaringBean().getAnnotatedItem().getWBSuperclass().getWBMethod(getAnnotatedItem().getAnnotatedMethod());
if (environment.getProducerMethod(superClassMethod) == null)
{
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentItem.java
===================================================================
---
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentItem.java 2009-09-17
12:54:36 UTC (rev 3696)
+++
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/DeploymentItem.java 2009-09-17
15:02:18 UTC (rev 3697)
@@ -26,6 +26,7 @@
import java.util.List;
import java.util.Set;
+import javax.enterprise.inject.Produces;
import javax.enterprise.inject.Specializes;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.ObserverMethod;
@@ -33,6 +34,7 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBMethod;
/**
*
@@ -72,10 +74,28 @@
{
addDependency(getSuperClassDependency());
}
+ else
+ {
+ Set<WBMethod<?, ?>> producerMethods =
getWBClass().getDeclaredWBAnnotatedMethods(Produces.class);
+ if (!producerMethods.isEmpty())
+ {
+ for (WBMethod<?, ?> producerMethod : producerMethods)
+ {
+ if (producerMethod.getAnnotation(Specializes.class) != null)
+ {
+ addDependency(getSuperClassDependency());
+ break;
+ }
+ }
+ }
+ }
+
initialized = true;
}
}
+
+
void addDependency(DeploymentItem<?> dependency)
{
if (dependencies == Collections.EMPTY_LIST)
Modified:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java
===================================================================
---
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java 2009-09-17
12:54:36 UTC (rev 3696)
+++
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java 2009-09-17
15:02:18 UTC (rev 3697)
@@ -183,6 +183,13 @@
}
}
+ @Test
+ public void testSpecializingProducerMethod()
+ {
+ assertArrays(sortClasses(EmployeeProducer.class,
SpecializedEmployeeProducer.class), EmployeeProducer.class,
SpecializedEmployeeProducer.class);
+ assertArrays(sortClasses(SpecializedEmployeeProducer.class,
EmployeeProducer.class), EmployeeProducer.class, SpecializedEmployeeProducer.class);
+ }
+
private OrderedEjbDescriptors createEjbDescriptors(Class<?>...classes)
{
OrderedEjbDescriptors descriptors = new OrderedEjbDescriptors();