Author: pete.muir(a)jboss.org
Date: 2009-03-15 21:13:04 -0400 (Sun, 15 Mar 2009)
New Revision: 2019
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Types.java
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedListInjection.java
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
Log:
WBRI-186
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-16 01:07:06
UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-16 01:13:04
UTC (rev 2019)
@@ -36,6 +36,8 @@
import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.NewSimpleBean;
import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.injection.ResolvableAnnotatedClass;
+import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.ListComparator;
@@ -72,41 +74,34 @@
{
for (InjectionPoint injectionPoint : bean.getInjectionPoints())
{
- if (injectionPoint.getType() instanceof Class)
+ if (injectionPoint.getAnnotation(New.class) != null &&
injectionPoint.getBindings().size() > 1)
{
- Class<?> type = (Class<?>) injectionPoint.getType();
- if (injectionPoint.getAnnotation(New.class) != null &&
injectionPoint.getBindings().size() > 1)
- {
- throw new DefinitionException("The injection point " +
injectionPoint + " is annotated with @New which cannot be combined with other binding
types");
- }
- Annotation[] bindings = injectionPoint.getBindings().toArray(new
Annotation[0]);
- Set<?> resolvedBeans = manager.resolveByType(type, bindings);
- if (resolvedBeans.isEmpty())
- {
- throw new UnsatisfiedDependencyException("The injection point
" + injectionPoint + " with binding types " +
Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + "
has unsatisfied dependencies with binding types ");
- }
- if (resolvedBeans.size() > 1)
- {
- throw new AmbiguousDependencyException("The injection point "
+ injectionPoint + " with binding types " +
Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + "
has ambiguous dependencies");
- }
- Bean<?> resolvedBean = (Bean<?>)
resolvedBeans.iterator().next();
- if
(MetaDataCache.instance().getScopeModel(resolvedBean.getScopeType()).isNormal() &&
!Proxies.isTypeProxyable(type))
- {
- throw new UnproxyableDependencyException("The injection point
" + injectionPoint + " has non-proxyable dependencies");
- }
- if (Reflections.isPrimitive((Class<?>) injectionPoint.getType())
&& resolvedBean.isNullable())
- {
- throw new NullableDependencyException("The injection point "
+ injectionPoint + " has nullable dependencies");
- }
- if (Beans.isPassivatingBean(bean) &&
!resolvedBean.isSerializable())
- {
- throw new UnserializableDependencyException("The bean " +
bean + " declares a passivating scopes but has non-serializable dependencies");
- }
+ throw new DefinitionException("The injection point " +
injectionPoint + " is annotated with @New which cannot be combined with other binding
types");
}
- else
+ Annotation[] bindings = injectionPoint.getBindings().toArray(new
Annotation[0]);
+ AnnotatedItem<?, ?> annotatedItem =
ResolvableAnnotatedClass.of(injectionPoint.getType(), bindings);
+ Set<?> resolvedBeans = manager.resolveByType(annotatedItem, bindings);
+ if (resolvedBeans.isEmpty())
{
- throw new UnsupportedOperationException("Not yet implemented");
+ throw new UnsatisfiedDependencyException("The injection point "
+ injectionPoint + " with binding types " +
Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + "
has unsatisfied dependencies with binding types ");
}
+ if (resolvedBeans.size() > 1)
+ {
+ throw new AmbiguousDependencyException("The injection point " +
injectionPoint + " with binding types " +
Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + "
has ambiguous dependencies");
+ }
+ Bean<?> resolvedBean = (Bean<?>)
resolvedBeans.iterator().next();
+ if
(MetaDataCache.instance().getScopeModel(resolvedBean.getScopeType()).isNormal() &&
!Proxies.isTypeProxyable(injectionPoint.getType()))
+ {
+ throw new UnproxyableDependencyException("The injection point "
+ injectionPoint + " has non-proxyable dependencies");
+ }
+ if (Reflections.isPrimitive(annotatedItem.getRawType()) &&
resolvedBean.isNullable())
+ {
+ throw new NullableDependencyException("The injection point " +
injectionPoint + " has nullable dependencies");
+ }
+ if (Beans.isPassivatingBean(bean) && !resolvedBean.isSerializable())
+ {
+ throw new UnserializableDependencyException("The bean " + bean +
" declares a passivating scopes but has non-serializable dependencies");
+ }
}
if (bean instanceof RIBean && !(bean instanceof NewSimpleBean)
&& !(bean instanceof NewEnterpriseBean))
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-16 01:07:06
UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-16 01:13:04
UTC (rev 2019)
@@ -350,7 +350,7 @@
}
if (bindings.length > element.getMetaAnnotations(BindingType.class).size())
{
- throw new DuplicateBindingTypeException("Duplicate bindings type passed
" + element.toString());
+ throw new DuplicateBindingTypeException("Duplicate bindings (" +
Arrays.asList(bindings) + ") type passed " + element.toString());
}
return resolver.get(element);
}
@@ -640,7 +640,7 @@
{
currentInjectionPoint.get().push(injectionPoint);
}
- AnnotatedItem<T, ?> element = ResolvableAnnotatedClass.of((Class<T>)
injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0]));
+ AnnotatedItem<T, ?> element =
ResolvableAnnotatedClass.of(injectionPoint.getType(),
injectionPoint.getBindings().toArray(new Annotation[0]));
Bean<T> bean = getBeanByType(element, element.getBindingsAsArray());
if (creationalContext instanceof CreationalContextImpl)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-16
01:07:06 UTC (rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -66,7 +66,7 @@
public void addClass(Class<?> clazz)
{
- if (!clazz.isAnnotation())
+ if (!clazz.isAnnotation() && !clazz.isEnum())
{
deferredClasses.add(AnnotatedClassImpl.of(clazz));
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -39,6 +39,22 @@
return new ResolvableAnnotatedClass<T>(clazz, clazz, annotations);
}
+ public static <T> ResolvableAnnotatedClass<T> of(Type type, Annotation[]
annotations)
+ {
+ if (type instanceof Class)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>) type, type,
annotations);
+ }
+ else if (type instanceof ParameterizedType)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>)
((ParameterizedType) type).getRawType(), type, annotations);
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Cannot create annotated item of
" + type);
+ }
+ }
+
public static <T> ResolvableAnnotatedClass<T> of(Member member,
Annotation[] annotations)
{
if (member instanceof Field)
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedItem.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -52,16 +52,13 @@
AnnotationStore getAnnotationStore();
}
-
- public Type getType()
- {
- return getRawType();
- }
// Cached string representation
private String toString;
private final AnnotationStore annotationStore;
private final Class<T> rawType;
+ private final Type[] actualTypeArguments;
+ private final Type type;
private final Set<? extends Type> flattenedTypes;
private final boolean proxyable;
private final boolean _parameterizedType;
@@ -75,12 +72,21 @@
* @param annotationMap A map of annotation to register
*
*/
- public AbstractAnnotatedItem(AnnotationStore annotatedItemHelper, Class<T>
rawType)
+ public AbstractAnnotatedItem(AnnotationStore annotatedItemHelper, Class<T>
rawType, Type type)
{
this.annotationStore = annotatedItemHelper;
this.rawType = rawType;
+ this.type = type;
+ if (type instanceof ParameterizedType)
+ {
+ this.actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
+ }
+ else
+ {
+ this.actualTypeArguments = new Type[0];
+ }
this._parameterizedType = Reflections.isParameterizedType(rawType);
- this.flattenedTypes = new
Reflections.HierarchyDiscovery<Type>(rawType).getFlattenedTypes();
+ this.flattenedTypes = new
Reflections.HierarchyDiscovery<Type>(type).getFlattenedTypes();
this.proxyable = Proxies.isTypesProxyable(flattenedTypes);
}
@@ -88,6 +94,8 @@
{
this.annotationStore = annotatedItemHelper;
this.rawType = null;
+ this.type = null;
+ this.actualTypeArguments = new Type[0];
this._parameterizedType = false;
this.flattenedTypes = null;
this.proxyable = false;
@@ -280,6 +288,16 @@
return rawType;
}
+ public Type getType()
+ {
+ return type;
+ }
+
+ public Type[] getActualTypeArguments()
+ {
+ return actualTypeArguments;
+ }
+
public Set<? extends Type> getFlattenedTypeHierarchy()
{
return flattenedTypes;
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -20,6 +20,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -110,9 +111,9 @@
*
* @param annotationMap The annotation map
*/
- public AbstractAnnotatedMember(AnnotationStore annotatedItemHelper, Member member,
Class<T> type)
+ protected AbstractAnnotatedMember(AnnotationStore annotatedItemHelper, Member member,
Class<T> rawType, Type type)
{
- super(annotatedItemHelper, type);
+ super(annotatedItemHelper, rawType, type);
name = member.getName();
_public = Modifier.isPublic(member.getModifiers());
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -18,6 +18,7 @@
package org.jboss.webbeans.introspector.jlr;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedType;
@@ -52,20 +53,20 @@
*
* @param annotationMap The annotation map
*/
- public AbstractAnnotatedType(AnnotationStore annotatedItemHelper, Class<T>
type)
+ public AbstractAnnotatedType(AnnotationStore annotatedItemHelper, Class<T>
rawType, Type type)
{
- super(annotatedItemHelper, type);
- this.name = type.getName();
- this._simpleName = type.getSimpleName();
- if (type.getSuperclass() != null)
+ super(annotatedItemHelper, rawType, type);
+ this.name = rawType.getName();
+ this._simpleName = rawType.getSimpleName();
+ if (rawType.getSuperclass() != null)
{
- this.superclass = AnnotatedClassImpl.of(type.getSuperclass());
+ this.superclass = AnnotatedClassImpl.of(rawType.getSuperclass());
}
else
{
this.superclass = null;
}
- this._public = Modifier.isFinal(type.getModifiers());
+ this._public = Modifier.isFinal(rawType.getModifiers());
}
/**
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -19,7 +19,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -111,7 +110,7 @@
*/
public AnnotatedAnnotationImpl(Class<T> annotationType)
{
- super(AnnotationStore.of(annotationType), annotationType);
+ super(AnnotationStore.of(annotationType), annotationType, annotationType);
this.clazz = annotationType;
members = new HashSet<AnnotatedMethod<?>>();
annotatedMembers = new AnnotatedMemberMap();
@@ -127,18 +126,6 @@
}
/**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedAnnotation#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return new Type[0];
- }
-
- /**
* Gets all members of the annotation
*
* Initializes the members first if they are null
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -21,7 +21,6 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collections;
@@ -211,11 +210,6 @@
}
}
- // The implementing class
- private final Class<T> clazz;
- // The type arguments
- private final Type[] actualTypeArguments;
-
// The set of abstracted fields
private final Set<AnnotatedField<?>> fields;
// The map from annotation type to abstracted field with annotation
@@ -265,16 +259,7 @@
private AnnotatedClassImpl(Class<T> rawType, Type type, Annotation[]
annotations, Annotation[] declaredAnnotations)
{
- super(AnnotationStore.of(annotations, declaredAnnotations), rawType);
- this.clazz = rawType;
- if (type instanceof ParameterizedType)
- {
- actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
- }
- else
- {
- actualTypeArguments = new Type[0];
- }
+ super(AnnotationStore.of(annotations, declaredAnnotations), rawType, type);
this.fields = new HashSet<AnnotatedField<?>>();
this.annotatedFields = new AnnotatedFieldMap();
@@ -284,7 +269,7 @@
this.declaredMetaAnnotatedFields = new AnnotatedFieldMap();
this._nonStaticMemberClass = Reflections.isNonMemberInnerClass(rawType);
this._abstract = Reflections.isAbstract(rawType);
- for (Class<?> c = clazz; c != Object.class && c != null; c =
c.getSuperclass())
+ for (Class<?> c = rawType; c != Object.class && c != null; c =
c.getSuperclass())
{
for (Field field : c.getDeclaredFields())
{
@@ -294,21 +279,21 @@
}
AnnotatedField<?> annotatedField = new
AnnotatedFieldImpl<Object>(field, this);
this.fields.add(annotatedField);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredFields.add(annotatedField);
}
for (Annotation annotation : annotatedField.getAnnotationsAsSet())
{
this.annotatedFields.put(annotation.annotationType(), annotatedField);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredAnnotatedFields.put(annotation.annotationType(),
annotatedField);
}
for (Annotation metaAnnotation :
annotation.annotationType().getAnnotations())
{
this.metaAnnotatedFields.put(metaAnnotation.annotationType(),
annotatedField);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredMetaAnnotatedFields.put(metaAnnotation.annotationType(), annotatedField);
}
@@ -321,7 +306,7 @@
this.constructors = new HashSet<AnnotatedConstructor<T>>();
this.constructorsByArgumentMap = new ConstructorsByArgumentMap();
this.annotatedConstructors = new AnnotatedConstructorMap();
- for (Constructor<?> constructor : clazz.getDeclaredConstructors())
+ for (Constructor<?> constructor : rawType.getDeclaredConstructors())
{
@SuppressWarnings("unchecked")
Constructor<T> c = (Constructor<T>) constructor;
@@ -349,7 +334,7 @@
this.declaredMethods = new HashSet<AnnotatedMethod<?>>();
this.declaredAnnotatedMethods = new AnnotatedMethodMap();
this.declaredMethodsByAnnotatedParameters = new AnnotatedMethodMap();
- for (Class<?> c = clazz; c != Object.class && c != null; c =
c.getSuperclass())
+ for (Class<?> c = rawType; c != Object.class && c != null; c =
c.getSuperclass())
{
for (Method method : c.getDeclaredMethods())
{
@@ -360,14 +345,14 @@
AnnotatedMethod<?> annotatedMethod = AnnotatedMethodImpl.of(method,
this);
this.methods.add(annotatedMethod);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredMethods.add(annotatedMethod);
}
for (Annotation annotation : annotatedMethod.getAnnotationsAsSet())
{
annotatedMethods.put(annotation.annotationType(), annotatedMethod);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredAnnotatedMethods.put(annotation.annotationType(),
annotatedMethod);
}
@@ -377,7 +362,7 @@
if (annotatedMethod.getAnnotatedParameters(annotationType).size() > 0)
{
methodsByAnnotatedParameters.put(annotationType, annotatedMethod);
- if (c == clazz)
+ if (c == rawType)
{
this.declaredMethodsByAnnotatedParameters.put(annotationType,
annotatedMethod);
}
@@ -394,7 +379,7 @@
*/
public Class<? extends T> getAnnotatedClass()
{
- return clazz;
+ return getRawType();
}
/**
@@ -404,7 +389,7 @@
*/
public Class<T> getDelegate()
{
- return clazz;
+ return getRawType();
}
/**
@@ -485,18 +470,6 @@
}
/**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedClass#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
- /**
* Gets the abstracted methods that have a certain annotation type present
*
* If the annotated methods map is null, initialize it first
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -45,9 +45,6 @@
public class AnnotatedConstructorImpl<T> extends AbstractAnnotatedMember<T,
Constructor<T>> implements AnnotatedConstructor<T>
{
-
- // The type arguments
- private static final Type[] actualTypeArguments = new Type[0];
// The underlying constructor
private final Constructor<T> constructor;
@@ -77,7 +74,7 @@
*/
public AnnotatedConstructorImpl(Constructor<T> constructor,
AnnotatedType<T> declaringClass)
{
- super(AnnotationStore.of(constructor), constructor,
constructor.getDeclaringClass());
+ super(AnnotationStore.of(constructor), constructor,
constructor.getDeclaringClass(), constructor.getDeclaringClass());
this.constructor = constructor;
this.declaringClass = declaringClass;
@@ -88,7 +85,8 @@
if (constructor.getParameterAnnotations()[i].length > 0)
{
Class<?> clazz = constructor.getParameterTypes()[i];
- AnnotatedParameter<?> parameter =
AnnotatedParameterImpl.of(constructor.getParameterAnnotations()[i], clazz, this);
+ Type type = constructor.getGenericParameterTypes()[i];
+ AnnotatedParameter<?> parameter =
AnnotatedParameterImpl.of(constructor.getParameterAnnotations()[i], clazz, type, this);
parameters.add(parameter);
for (Annotation annotation : parameter.getAnnotationsAsSet())
@@ -99,7 +97,8 @@
else
{
Class<?> clazz = constructor.getParameterTypes()[i];
- AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new
Annotation[0], clazz, this);
+ Type type = constructor.getGenericParameterTypes()[i];
+ AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new
Annotation[0], clazz, type, this);
parameters.add(parameter);
for (Annotation annotation : parameter.getAnnotationsAsSet())
@@ -131,18 +130,6 @@
}
/**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedConstructor#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
- /**
* Gets the abstracted parameters
*
* If the parameters are null, initalize them first
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedFieldImpl.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -18,8 +18,6 @@
package org.jboss.webbeans.introspector.jlr;
import java.lang.reflect.Field;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedType;
@@ -39,8 +37,6 @@
public class AnnotatedFieldImpl<T> extends AbstractAnnotatedMember<T, Field>
implements AnnotatedField<T>
{
- // The actual type arguments
- private final Type[] actualTypeArguments;
// The underlying field
private final Field field;
// The abstraction of the declaring class
@@ -60,19 +56,10 @@
*/
public AnnotatedFieldImpl(Field field, AnnotatedType<?> declaringClass)
{
- super(AnnotationStore.of(field), field, (Class<T>) field.getType());
+ super(AnnotationStore.of(field), field, (Class<T>) field.getType(),
field.getGenericType());
this.field = field;
field.setAccessible(true);
this.declaringClass = declaringClass;
- if (field.getGenericType() instanceof ParameterizedType)
- {
- ParameterizedType type = (ParameterizedType) field.getGenericType();
- actualTypeArguments = type.getActualTypeArguments();
- }
- else
- {
- actualTypeArguments = new Type[0];
- }
}
/**
@@ -89,18 +76,6 @@
{
return field;
}
-
- /**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedField#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
public void set(Object instance, Object value) throws IllegalArgumentException,
IllegalAccessException
{
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -20,13 +20,11 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Set;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
@@ -47,10 +45,6 @@
public class AnnotatedMethodImpl<T> extends AbstractAnnotatedMember<T,
Method> implements AnnotatedMethod<T>
{
- // The actual type arguments
- private final Type[] actualTypeArguments;
- private final Type underlyingType;
- private final Class<T> type;
// The underlying method
private final Method method;
@@ -69,8 +63,6 @@
// Cached string representation
private String toString;
- private final Set<? extends Type> flattenedTypes;
-
public static <T> AnnotatedMethodImpl<T> of(Method method,
AnnotatedType<?> declaringClass)
{
return new AnnotatedMethodImpl<T>(method, declaringClass);
@@ -88,24 +80,10 @@
@SuppressWarnings("unchecked")
protected AnnotatedMethodImpl(Method method, AnnotatedType<?> declaringClass)
{
- super(AnnotationStore.of(method), method, (Class<T>)
method.getReturnType());
+ super(AnnotationStore.of(method), method, (Class<T>) method.getReturnType(),
method.getGenericReturnType());
this.method = method;
this.method.setAccessible(true);
this.declaringClass = declaringClass;
- this.type = (Class<T>) method.getReturnType();
- if (method.getGenericReturnType() instanceof ParameterizedType)
- {
- this.underlyingType = method.getGenericReturnType();
- this.flattenedTypes = new
Reflections.HierarchyDiscovery<Type>(underlyingType).getFlattenedTypes();
- this.actualTypeArguments = ((ParameterizedType)
underlyingType).getActualTypeArguments();
- }
- else
- {
- this.underlyingType = type;
- this.flattenedTypes = super.getFlattenedTypeHierarchy();
- this.actualTypeArguments = new Type[0];
- }
-
this.parameters = new ArrayList<AnnotatedParameter<?>>();
this.annotatedParameters = new AnnotatedParameterMap();
for (int i = 0; i < method.getParameterTypes().length; i++)
@@ -113,7 +91,8 @@
if (method.getParameterAnnotations()[i].length > 0)
{
Class<? extends Object> clazz = method.getParameterTypes()[i];
- AnnotatedParameter<?> parameter =
AnnotatedParameterImpl.of(method.getParameterAnnotations()[i], (Class<Object>)
clazz, this);
+ Type type = method.getGenericParameterTypes()[i];
+ AnnotatedParameter<?> parameter =
AnnotatedParameterImpl.of(method.getParameterAnnotations()[i], (Class<Object>)
clazz, type, this);
this.parameters.add(parameter);
for (Annotation annotation : parameter.getAnnotationsAsSet())
{
@@ -126,7 +105,8 @@
else
{
Class<? extends Object> clazz = method.getParameterTypes()[i];
- AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new
Annotation[0], (Class<Object>) clazz, this);
+ Type type = method.getGenericParameterTypes()[i];
+ AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new
Annotation[0], (Class<Object>) clazz, type, this);
this.parameters.add(parameter);
}
}
@@ -151,18 +131,7 @@
{
return method;
}
-
- @Override
- public Type getType()
- {
- return underlyingType;
- }
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
public List<AnnotatedParameter<?>> getParameters()
{
return Collections.unmodifiableList(parameters);
@@ -240,10 +209,4 @@
return toString;
}
- @Override
- public Set<? extends Type> getFlattenedTypeHierarchy()
- {
- return flattenedTypes;
- }
-
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -40,10 +40,6 @@
public class AnnotatedParameterImpl<T> extends AbstractAnnotatedItem<T,
Object> implements AnnotatedParameter<T>
{
- // The type
- private final Class<T> type;
- // The actual type arguments
- private final Type[] actualTypeArguments = new Type[0];
// The final state
private final boolean _final = false;
// The static state
@@ -54,9 +50,9 @@
// Cached string representation
private String toString;
- public static <T> AnnotatedParameter<T> of(Annotation[] annotations,
Class<T> clazz, AnnotatedMember<?, ?> declaringMember)
+ public static <T> AnnotatedParameter<T> of(Annotation[] annotations,
Class<T> rawType, Type type, AnnotatedMember<?, ?> declaringMember)
{
- return new AnnotatedParameterImpl<T>(annotations, clazz, declaringMember);
+ return new AnnotatedParameterImpl<T>(annotations, rawType, type,
declaringMember);
}
/**
@@ -65,26 +61,13 @@
* @param annotations The annotations array
* @param type The type of the parameter
*/
- private AnnotatedParameterImpl(Annotation[] annotations, Class<T> type,
AnnotatedMember<?, ?> declaringMember)
+ protected AnnotatedParameterImpl(Annotation[] annotations, Class<T> rawType,
Type type, AnnotatedMember<?, ?> declaringMember)
{
- super(AnnotationStore.of(annotations, annotations), type);
- this.type = type;
+ super(AnnotationStore.of(annotations, annotations), rawType, type);
this.declaringMember = declaringMember;
}
/**
- * Gets the actual type arguments
- *
- * @return The type arguments
- *
- * @see org.jboss.webbeans.introspector.AnnotatedItem#getActualTypeArguments()
- */
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
- /**
* Gets the delegate
*
* @return The delegate (null)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Types.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Types.java 2009-03-16 01:07:06 UTC
(rev 2018)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Types.java 2009-03-16 01:13:04 UTC
(rev 2019)
@@ -68,6 +68,10 @@
{
return Double.class;
}
+ else if (type.equals(Void.TYPE))
+ {
+ return Void.class;
+ }
else
{
throw new IllegalStateException("Some weird type!!!");
Modified:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedListInjection.java
===================================================================
---
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedListInjection.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedListInjection.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -2,27 +2,30 @@
import java.util.List;
+import javax.inject.Current;
+import javax.inject.Initializer;
+
public class ParameterizedListInjection
{
private List<String> value;
- //@Current
+ @Current
private List<String> fieldInjection;
private List<String> setterInjection;
- //@Initializer
+ @Initializer
public void init(List<String> setterInjection)
{
this.setterInjection = setterInjection;
}
- /*@Initializer
+ @Initializer
public ParameterizedListInjection(List<String> com)
{
this.value = com;
- }*/
+ }
public java.util.List<String> getValue()
{
Modified:
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java
===================================================================
---
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ParameterizedProducerTest.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -6,19 +6,20 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
+import org.testng.annotations.Test;
@Artifact
public class ParameterizedProducerTest extends AbstractWebBeansTest
{
- //@Test
+ @Test
public void testInjectManagerProducer()
{
assert manager.getInstanceByType(new
TypeLiteral<List<String>>(){}).size() == 2;
ParameterizedListInjection item =
manager.getInstanceByType(ParameterizedListInjection.class);
+ assert item.getFieldInjection().size() == 2;
assert item.getValue().size() == 2;
- assert item.getFieldInjection().size() == 2;
assert item.getSetterInjection().size() == 2;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -9,6 +9,7 @@
import javax.event.Observer;
import javax.inject.DuplicateBindingTypeException;
import javax.inject.Standard;
+import javax.inject.TypeLiteral;
import javax.inject.manager.Bean;
import javax.inject.manager.Manager;
@@ -584,7 +585,7 @@
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertions( { @SpecAssertion(section = "7.6", id = "n") } )
public void testImplicitEventBeanMatchesAPITypeOfInectionPoint() throws Exception
{
@@ -596,14 +597,14 @@
{
// Retrieve the implicit event bean from the manager only by
// its API type
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new
FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new
TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert !eventBeans.isEmpty();
}
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertions( { @SpecAssertion(section = "7.6", id = "n") } )
public void testImplicitEventBeanMatchesBindingAnnotationsOfInjectionPoint() throws
Exception
{
@@ -615,14 +616,14 @@
{
// Retrieve the implicit event bean from the manager
// by its binding types (uses OrangeCheekedWaxbill)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new
FiresBinding(), new TameAnnotationLiteral(), new RoleBinding("Admin"));
+ Set<?> eventBeans = getCurrentManager().resolveByType(new
TypeLiteral<Event<AnEventType>>() {}, new FiresBinding(), new
TameAnnotationLiteral(), new RoleBinding("Admin"));
assert !eventBeans.isEmpty();
}
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertion(section = "7.6", id = "o")
public void testImplicitEventBeanHasStandardDeploymentType() throws Exception
{
@@ -634,7 +635,7 @@
{
// Retrieve the implicit event bean from the manager
// only by its API type (uses BlueFacedParrotFinch)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new
FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new
TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert eventBeans.size() == 1;
Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
assert eventBean.getDeploymentType().equals(Standard.class);
@@ -643,7 +644,7 @@
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertion(section = "7.6", id = "p")
public void testImplicitEventBeanHasDependentScope() throws Exception
{
@@ -654,7 +655,7 @@
{
// Retrieve the implicit event bean from the manager only
// by its API type (uses BlueFacedParrotFinch)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new
FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new
TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert eventBeans.size() == 1;
Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
assert eventBean.getScopeType().equals(Dependent.class);
@@ -662,7 +663,7 @@
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertion(section = "7.6", id = "q")
public void testImplicitEventBeanHasNoName() throws Exception
{
@@ -673,7 +674,7 @@
{
// Retrieve the implicit event bean from the manager only
// by its API type (uses BlueFacedParrotFinch)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new
FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new
TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert eventBeans.size() == 1;
Bean<?> eventBean = (Bean<?>) eventBeans.iterator().next();
assert eventBean.getName() == null;
@@ -681,7 +682,7 @@
}.run();
}
- @Test(groups = { "events" })
+ @Test(groups = { "events", "ri-broken" })
@SpecAssertions( { @SpecAssertion(section = "7.6", id = "a"),
@SpecAssertion(section = "7.6", id = "r") } )
public void testImplicitEventBeanProvidedByContainer() throws Exception
{
@@ -692,7 +693,7 @@
{
// Retrieve the implicit event bean from the manager only
// by its API type (uses BlueFacedParrotFinch)
- Set<?> eventBeans = getCurrentManager().resolveByType(Event.class, new
FiresBinding());
+ Set<?> eventBeans = getCurrentManager().resolveByType(new
TypeLiteral<Event<AnEventType>>() {}, new FiresBinding());
assert eventBeans.size() == 1;
}
}.run();
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/register/fires1/ImplicitEventBeanTest.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -17,10 +17,8 @@
package org.jboss.jsr299.tck.tests.event.register.fires1;
-import java.lang.annotation.Annotation;
import java.util.Set;
-import javax.event.Event;
import javax.event.Observer;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -110,11 +108,4 @@
}.run();
}
- @Test(groups = { "events" })
- @SpecAssertions( { @SpecAssertion(section = "7.6", id = "e"),
@SpecAssertion(section = "7.6", id = "f") })
- public void testImplicitEventBeanFireSignature() throws Exception
- {
- // All implicit event beans directly use the Event interface
- assert Event.class.getDeclaredMethod("fire", Object.class,
Annotation[].class) != null;
- }
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java 2009-03-16
01:07:06 UTC (rev 2018)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java 2009-03-16
01:13:04 UTC (rev 2019)
@@ -2,10 +2,13 @@
import static org.jboss.jsr299.tck.tests.lookup.dynamic.PayBy.PaymentMethod.CHEQUE;
+import java.util.Set;
+
import javax.context.Dependent;
import javax.inject.DuplicateBindingTypeException;
import javax.inject.Instance;
import javax.inject.Standard;
+import javax.inject.TypeLiteral;
import javax.inject.manager.Bean;
import org.hibernate.tck.annotations.SpecAssertion;
@@ -83,9 +86,9 @@
})
public void testImplicitBeanExists()
{
- Bean<Instance> instanceBean =
getCurrentManager().resolveByType(Instance.class,
- new PayByBinding() { public PaymentMethod value() { return CHEQUE;
}}).iterator().next();
-
+ Set<Bean<Instance<PaymentProcessor>>> beans =
getCurrentManager().resolveByType(new
TypeLiteral<Instance<PaymentProcessor>>() {}, new PayByBinding() { public
PaymentMethod value() { return CHEQUE; }});
+ assert beans.size() == 1;
+ Bean<Instance<PaymentProcessor>> instanceBean =
beans.iterator().next();
assert instanceBean != null;
assert instanceBean.getDeploymentType().equals(Standard.class);
assert instanceBean.getScopeType().equals(Dependent.class);