Author: pete.muir(a)jboss.org
Date: 2009-03-23 07:40:01 -0400 (Mon, 23 Mar 2009)
New Revision: 2142
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/AnotherDeploymentType.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Expensive.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/JewelryShop.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Necklace.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Product.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Shop.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Sparkly.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java
Log:
ordering for specializing producer methods
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java 2009-03-23
11:20:10 UTC (rev 2141)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BootstrapOrderingBeanComparator.java 2009-03-23
11:40:01 UTC (rev 2142)
@@ -15,24 +15,10 @@
{
if (o1 instanceof AbstractClassBean && o2 instanceof AbstractProducerBean)
{
-// AbstractProducerBean<?, ?> b2 = (AbstractProducerBean<?, ?>) o2;
-// System.out.println(" declaring bean " +
b2.getDeclaringBean().getType());
-// if (b2.getDeclaringBean().equals(o1))
-// {
-// System.out.println(" class " + o1.getType() + " <
producer " + o2.getType());
-// return -1;
-// }
return -1;
}
else if (o1 instanceof AbstractProducerBean && o2 instanceof
AbstractClassBean)
{
-// AbstractProducerBean<?, ?> b1 = (AbstractProducerBean<?, ?>) o1;
-// System.out.println(" declaring bean " +
b1.getDeclaringBean().getType());
-// if (b1.getDeclaringBean().equals(o2))
-// {
-// System.out.println(" class " + o2.getType() + " <
producer " + o1.getType());
-// return 1;
-// }
return 1;
}
@@ -52,6 +38,20 @@
}
}
+ if (o1 instanceof AbstractProducerBean && o2 instanceof
AbstractProducerBean)
+ {
+ AbstractProducerBean<?, ?> b1 = (AbstractProducerBean<?, ?>) o1;
+ AbstractProducerBean<?, ?> b2 = (AbstractProducerBean<?, ?>) o2;
+ if
(b1.getDeclaringBean().getSuperclasses().contains(b2.getDeclaringBean().getType().getName()))
+ {
+ return 1;
+ }
+ else if
(b2.getDeclaringBean().getSuperclasses().contains(b1.getDeclaringBean().getType().getName()))
+ {
+ return -1;
+ }
+ }
+
if (o1 instanceof AbstractStandardBean && !(o2 instanceof
AbstractStandardBean))
{
return -1;
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/AnotherDeploymentType.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/AnotherDeploymentType.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/AnotherDeploymentType.java 2009-03-23
11:40:01 UTC (rev 2142)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.DeploymentType;
+
+@Target( { TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+@DeploymentType
+@interface AnotherDeploymentType
+{
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/AnotherDeploymentType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java 2009-03-23
11:20:10 UTC (rev 2141)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/DeployerOrderingTest.java 2009-03-23
11:40:01 UTC (rev 2142)
@@ -3,6 +3,8 @@
import java.util.ArrayList;
import java.util.Arrays;
+import javax.inject.AnnotationLiteral;
+
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.EnterpriseBean;
@@ -189,5 +191,43 @@
assert indexOfDefangedTarantula > indexOfTarantula;
assert indexOfTarantula > indexOfSpider;
}
+
+ @Test(groups="bootstrap")
+ public void testClassHierarchiesForMethods()
+ {
+ BeanDeployer beanDeployer = new BeanDeployer(manager);
+ beanDeployer.addClasses(Arrays.asList(Shop.class, JewelryShop.class, Tuna.class));
+ beanDeployer.createBeans();
+ assert beanDeployer.getBeans().size() == 8;
+ int indexOfShop = 0;
+ int indexOfJewelryShop = 0;
+ int indexOfExpensiveGift = 0;
+ int indexOfNecklace = 0;
+ int i = 0;
+ for (RIBean<?> bean : beanDeployer.getBeans())
+ {
+ if (bean.getType().equals(Shop.class) &&
!bean.getBindings().contains(new NewLiteral()))
+ {
+ indexOfShop = i;
+ }
+ if (bean.getType().equals(JewelryShop.class) &&
!bean.getBindings().contains(new NewLiteral()))
+ {
+ indexOfJewelryShop = i;
+ }
+ if (bean.getType().equals(Product.class) &&
bean.getBindings().contains(new AnnotationLiteral<Sparkly>() {}))
+ {
+ indexOfNecklace = i;
+ }
+ if (bean.getType().equals(Product.class) &&
!bean.getBindings().contains(new AnnotationLiteral<Sparkly>() {}))
+ {
+ indexOfExpensiveGift = i;
+ }
+ i++;
+ }
+ assert indexOfJewelryShop > indexOfShop;
+ assert indexOfExpensiveGift > indexOfShop;
+ assert indexOfNecklace > indexOfJewelryShop;
+ assert indexOfNecklace > indexOfExpensiveGift;
+ }
}
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Expensive.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Expensive.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Expensive.java 2009-03-23
11:40:01 UTC (rev 2142)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface Expensive
+{
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Expensive.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/JewelryShop.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/JewelryShop.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/JewelryShop.java 2009-03-23
11:40:01 UTC (rev 2142)
@@ -0,0 +1,15 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import javax.inject.Produces;
+import javax.inject.Specializes;
+
+class JewelryShop extends Shop
+{
+
+ @Override @Produces @Specializes @Sparkly @AnotherDeploymentType
+ public Product getExpensiveGift()
+ {
+ return new Necklace();
+ }
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/JewelryShop.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Necklace.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Necklace.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Necklace.java 2009-03-23
11:40:01 UTC (rev 2142)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+class Necklace extends Product
+{
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Necklace.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Product.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Product.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Product.java 2009-03-23
11:40:01 UTC (rev 2142)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+class Product
+{
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Product.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Shop.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Shop.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Shop.java 2009-03-23
11:40:01 UTC (rev 2142)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import javax.annotation.Named;
+import javax.inject.Produces;
+
+
+class Shop
+{
+
+ @Produces @Expensive @Named
+ public Product getExpensiveGift()
+ {
+ return new Product();
+ }
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Shop.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Sparkly.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Sparkly.java
(rev 0)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Sparkly.java 2009-03-23
11:40:01 UTC (rev 2142)
@@ -0,0 +1,22 @@
+package org.jboss.webbeans.test.unit.bootstrap.ordering;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface Sparkly
+{
+
+}
Property changes on:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/ordering/Sparkly.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date