geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r829428 - /geronimo/server/branches/2.2/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java
Date Sat, 24 Oct 2009 18:13:20 GMT
Author: djencks
Date: Sat Oct 24 18:13:20 2009
New Revision: 829428

URL: http://svn.apache.org/viewvc?rev=829428&view=rev
Log:
GERONIMO-4930 allow wildcards in generic constructor parameters in annotated gbeans

Modified:
    geronimo/server/branches/2.2/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java

Modified: geronimo/server/branches/2.2/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java?rev=829428&r1=829427&r2=829428&view=diff
==============================================================================
--- geronimo/server/branches/2.2/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java
(original)
+++ geronimo/server/branches/2.2/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/annotation/AnnotationGBeanInfoBuilder.java
Sat Oct 24 18:13:20 2009
@@ -25,6 +25,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.lang.reflect.WildcardType;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
@@ -207,7 +208,17 @@
         if (Collection.class.isAssignableFrom(parameterType)) {
             if (genericType instanceof ParameterizedType) {
                 ParameterizedType parameterizedType = (ParameterizedType) genericType;
-                return (Class) parameterizedType.getActualTypeArguments()[0];
+                Type componentType = parameterizedType.getActualTypeArguments()[0];
+                if (componentType instanceof Class) {
+                    return (Class) componentType;
+                }
+                if (componentType instanceof WildcardType) {
+                    Type[] upper = ((WildcardType)componentType).getUpperBounds();
+                    if (upper.length == 1 && upper[0] instanceof Class) {
+                        return (Class) upper[0];
+                    }
+                }
+                throw new GBeanAnnotationException("Generic type is not a class: " + componentType);
             } else {
                 throw new GBeanAnnotationException(Collection.class + " parameter must be
generified");
             }



Mime
View raw message