[weld-commits] Weld SVN: r5210 - in core/trunk: impl/src/main/java/org/jboss/weld/util and 2 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Dec 3 13:08:12 EST 2009


Author: pete.muir at jboss.org
Date: 2009-12-03 13:08:11 -0500 (Thu, 03 Dec 2009)
New Revision: 5210

Added:
   core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Animal.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Dog.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/DogBean.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanDefinitionTest.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java
   core/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWeldTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanTest.java
Log:
WELD-305

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-12-03 16:28:16 UTC (rev 5209)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java	2009-12-03 18:08:11 UTC (rev 5210)
@@ -199,7 +199,7 @@
       }
       else
       {
-         this.types = getAnnotatedItem().getTypeClosure();
+         this.types = new HashSet<Type>(getAnnotatedItem().getTypeClosure());
          if (getType().isInterface())
          {
             this.types.add(Object.class);

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java	2009-12-03 16:28:16 UTC (rev 5209)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java	2009-12-03 18:08:11 UTC (rev 5210)
@@ -73,6 +73,7 @@
 import org.jboss.weld.util.Beans;
 import org.jboss.weld.util.Proxies;
 import org.jboss.weld.util.Proxies.TypeInfo;
+import org.jboss.weld.util.Reflections.HierarchyDiscovery;
 
 /**
  * An enterprise bean representation
@@ -206,9 +207,10 @@
    protected void initTypes()
    {
       Map<Class<?>, Type> types = new LinkedHashMap<Class<?>, Type>();
+      
       for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces())
       {
-         types.put(businessInterfaceDescriptor.getInterface(), businessInterfaceDescriptor.getInterface());
+         types.putAll(new HierarchyDiscovery(businessInterfaceDescriptor.getInterface()).getTypeMap());
       }
       if (getAnnotatedItem().isAnnotationPresent(Typed.class))
       {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java	2009-12-03 16:28:16 UTC (rev 5209)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java	2009-12-03 18:08:11 UTC (rev 5210)
@@ -42,7 +42,6 @@
 import java.security.AccessControlException;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
@@ -58,6 +57,9 @@
 
 import ch.qos.cal10n.IMessageConveyor;
 
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+
 /**
  * Utility class for static reflection-type operations
  * 
@@ -82,7 +84,7 @@
 
       private final Type type;
 
-      private Set<Type> typeSet;
+      private BiMap<Type, Class<?>> types;
 
       public HierarchyDiscovery(Type type)
       {
@@ -91,21 +93,30 @@
 
       protected void add(Class<?> clazz, Type type)
       {
-         typeSet.add(type);
+         types.forcePut(type, clazz);
       }
 
       public Set<Type> getTypeClosure()
       {
-         if (typeSet == null)
+         if (types == null)
          {
             init();
          }
-         return typeSet;
+         return types.keySet();
       }
       
+      public Map<Class<?>, Type> getTypeMap()
+      {
+         if (types == null)
+         {
+            init();
+         }
+         return types.inverse();
+      }
+      
       private void init()
       {
-         this.typeSet = new HashSet<Type>();
+         this.types = HashBiMap.create();
          discoverTypes(type);
       }
 

Modified: core/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWeldTest.java
===================================================================
--- core/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWeldTest.java	2009-12-03 16:28:16 UTC (rev 5209)
+++ core/trunk/tests/src/main/java/org/jboss/weld/test/AbstractWeldTest.java	2009-12-03 18:08:11 UTC (rev 5210)
@@ -90,6 +90,12 @@
       }
       return annotationTypeList.size() == 0;
    }
+   
+   public boolean typeSetMatches(Set<Type> types, Type... requiredTypes)
+   {
+      List<Type> typeList = Arrays.asList(requiredTypes);
+      return requiredTypes.length == types.size() && types.containsAll(typeList);
+   }
 
    protected Iterable<URL> getResources(String name)
    {

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Animal.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Animal.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Animal.java	2009-12-03 18:08:11 UTC (rev 5210)
@@ -0,0 +1,6 @@
+package org.jboss.weld.tests.enterprise;
+
+public interface Animal
+{
+
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Animal.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Dog.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Dog.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Dog.java	2009-12-03 18:08:11 UTC (rev 5210)
@@ -0,0 +1,9 @@
+package org.jboss.weld.tests.enterprise;
+
+import javax.ejb.Local;
+
+ at Local
+public interface Dog extends Animal
+{
+
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/Dog.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/DogBean.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/DogBean.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/DogBean.java	2009-12-03 18:08:11 UTC (rev 5210)
@@ -0,0 +1,10 @@
+package org.jboss.weld.tests.enterprise;
+
+import javax.ejb.Stateless;
+
+
+ at Stateless
+public class DogBean implements Dog
+{
+
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/DogBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanDefinitionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanDefinitionTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanDefinitionTest.java	2009-12-03 18:08:11 UTC (rev 5210)
@@ -0,0 +1,23 @@
+package org.jboss.weld.tests.enterprise;
+
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+ at Artifact
+ at Packaging(PackagingType.EAR)
+public class EnterpriseBeanDefinitionTest extends AbstractWeldTest
+{
+   
+   @Test(description="WELD-305")
+   public void testSuperInterfacesAreBeanTypes()
+   {
+      Bean<?> bean = getBean(Dog.class);
+      assert typeSetMatches(bean.getTypes(), Object.class, Dog.class, Animal.class);
+   }
+   
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanDefinitionTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanTest.java	2009-12-03 16:28:16 UTC (rev 5209)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/enterprise/EnterpriseBeanTest.java	2009-12-03 18:08:11 UTC (rev 5210)
@@ -36,5 +36,4 @@
       assert false : "Expected a BowlerHatException to be in the cause stack";
    }
    
-   
 }



More information about the weld-commits mailing list