[weld-commits] Weld SVN: r4623 - core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr and 1 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Tue Nov 3 13:30:41 EST 2009


Author: pete.muir at jboss.org
Date: 2009-11-03 13:30:41 -0500 (Tue, 03 Nov 2009)
New Revision: 4623

Modified:
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java
   core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java
Log:
WELD-201

Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java	2009-11-03 17:53:48 UTC (rev 4622)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java	2009-11-03 18:30:41 UTC (rev 4623)
@@ -57,7 +57,7 @@
       assert getInstanceByType(Grocery.class, new AnyLiteral()).getFruit().getMetadata().getType().equals(TropicalFruit.class);
    }
    
-   @Test(groups = "ri-broken")
+   @Test
    @SpecAssertion(section = "11.4", id = "k")
    // WELD-201
    public void testGetTypeClosureUsed() {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java	2009-11-03 17:53:48 UTC (rev 4622)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java	2009-11-03 18:30:41 UTC (rev 4623)
@@ -46,6 +46,7 @@
 import org.jboss.weld.introspector.WeldMethod;
 import org.jboss.weld.resources.ClassTransformer;
 import org.jboss.weld.util.Names;
+import org.jboss.weld.util.Proxies;
 import org.jboss.weld.util.Reflections;
 
 import com.google.common.base.Supplier;
@@ -126,6 +127,10 @@
    private final boolean _local;
    private final boolean _anonymous;
    private final boolean _enum;
+   private final boolean _proxyable;
+   
+   private final Set<Type> typeClosureAsSet;
+   private final Map<Class<?>, Type> typeClosureAsMap;
 
    public static <T> WeldClass<T> of(Class<T> clazz, ClassTransformer classTransformer)
    {
@@ -163,6 +168,21 @@
       this._private = Modifier.isPrivate(rawType.getModifiers());
       this._packagePrivate = Reflections.isPackagePrivate(rawType.getModifiers());
       this._package = rawType.getPackage();
+      
+      if (annotatedType == null)
+      {
+         // If this annotated type has not been enhanced, use the default version
+         this.typeClosureAsSet = super.getTypeClosure();
+         this.typeClosureAsMap = super.getTypeClosureAsMap();
+         this._proxyable = super.isProxyable();
+      }
+      else
+      {
+         this.typeClosureAsSet = annotatedType.getTypeClosure();
+         this.typeClosureAsMap = Reflections.buildTypeMap(typeClosureAsSet);
+         this._proxyable = Proxies.isTypesProxyable(typeClosureAsSet);
+      }
+      
       this.fields = new HashSet<WeldField<?, ?>>();
       this.annotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldField<?, ?>>>(), new Supplier< Set<WeldField<?, ?>>>()
       {
@@ -787,5 +807,23 @@
    {
       return (Set) methods;
    }
+   
+   @Override
+   public boolean isProxyable()
+   {
+      return _proxyable;
+   }
+   
+   @Override
+   public Set<Type> getTypeClosure()
+   {
+      return typeClosureAsSet;
+   }
+   
+   @Override
+   public Map<Class<?>, Type> getTypeClosureAsMap()
+   {
+      return typeClosureAsMap;
+   }
 
 }
\ No newline at end of file

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-11-03 17:53:48 UTC (rev 4622)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java	2009-11-03 18:30:41 UTC (rev 4623)
@@ -271,6 +271,26 @@
       }
 
    }
+   
+   public static Map<Class<?>, Type> buildTypeMap(Set<Type> types)
+   {
+      Map<Class<?>, Type> map = new HashMap<Class<?>, Type>();
+      for (Type type : types)
+      {
+         if (type instanceof Class<?>)
+         {
+            map.put((Class<?>) type, type);
+         }
+         else if (type instanceof ParameterizedType)
+         {
+            if (((ParameterizedType) type).getRawType() instanceof Class<?>)
+            {
+               map.put((Class<?>) ((ParameterizedType) type).getRawType(), type);
+            }
+         }
+      }
+      return map;
+   }
 
    /**
     * Gets the property name from a getter method



More information about the weld-commits mailing list