openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1083098 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
Date Fri, 18 Mar 2011 22:41:56 GMT
Author: struberg
Date: Fri Mar 18 22:41:56 2011
New Revision: 1083098

URL: http://svn.apache.org/viewvc?rev=1083098&view=rev
Log:
OWB-546 pickup @Typed in AnnotatedTypes

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java?rev=1083098&r1=1083097&r2=1083098&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
Fri Mar 18 22:41:56 2011
@@ -23,9 +23,12 @@ import java.lang.reflect.Type;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.enterprise.inject.Typed;
 import javax.enterprise.inject.spi.Annotated;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
 
 /**
@@ -144,6 +147,42 @@ abstract class AbstractAnnotated impleme
             typeClosures = new HashSet<Type>();
             this.typeClosures.add(Object.class);
             ClassUtil.setTypeHierarchy(this.typeClosures, this.baseType);
+
+            Annotation[] anns = annotations.toArray(new Annotation[annotations.size()]);
+            if(AnnotationUtil.hasAnnotation(anns, Typed.class))
+            {
+                Typed beanTypes = (Typed) AnnotationUtil.getAnnotation(anns, Typed.class);
+                Class<?>[] types = beanTypes.value();
+
+                //New api types
+                Set<Type> newTypes = new HashSet<Type>();
+                for(Class<?> type : types)
+                {
+                    Type foundType = null;
+
+                    for(Type apiType : typeClosures)
+                    {
+                        if(ClassUtil.getClazz(apiType) == type)
+                        {
+                            foundType = apiType;
+                            break;
+                        }
+                    }
+
+                    if(foundType == null)
+                    {
+                        throw new WebBeansConfigurationException("@Type values must be in
bean api types of class: " + baseType);
+                    }
+
+                    newTypes.add(foundType);
+                }
+
+                typeClosures.clear();
+                typeClosures.addAll(newTypes);
+
+                typeClosures.add(Object.class);
+            }
+
         }
     }
 



Mime
View raw message