[webbeans-commits] Webbeans SVN: r3554 - in ri/trunk: tests and 2 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Tue Aug 18 17:16:40 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-08-18 17:16:39 -0400 (Tue, 18 Aug 2009)
New Revision: 3554
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/AnnotatedTypeDecoratorTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/Foo.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotated.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedCallable.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedConstructor.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedField.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMember.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMethod.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedParameter.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedType.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/NotAnnotated.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBAnnotationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBConstructorImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBFieldImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBMethodImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java
ri/trunk/tests/unit-tests.xml
Log:
WBR-370
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBAnnotationImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBAnnotationImpl.java 2009-08-18 17:31:02 UTC (rev 3553)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBAnnotationImpl.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -73,7 +73,7 @@
*/
protected WBAnnotationImpl(Class<T> annotationType, ClassTransformer classTransformer)
{
- super(annotationType, annotationType, AnnotationStore.of(annotationType, classTransformer.getTypeStore().get(annotationType), classTransformer.getTypeStore().get(annotationType), classTransformer.getTypeStore()), classTransformer);
+ super(annotationType, annotationType, null, AnnotationStore.of(annotationType, classTransformer.getTypeStore().get(annotationType), classTransformer.getTypeStore().get(annotationType), classTransformer.getTypeStore()), classTransformer);
this.clazz = annotationType;
members = new HashSet<WBMethod<?, ?>>();
annotatedMembers = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WBMethod<?, ?>>>(), new Supplier<Set<WBMethod<?, ?>>>()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java 2009-08-18 17:31:02 UTC (rev 3553)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -127,16 +127,16 @@
public static <T> WBClass<T> of(Class<T> clazz, ClassTransformer classTransformer)
{
AnnotationStore annotationStore = AnnotationStore.of(clazz.getAnnotations(), clazz.getDeclaredAnnotations(), classTransformer.getTypeStore());
- return new WBClassImpl<T>(clazz, clazz, annotationStore, classTransformer);
+ return new WBClassImpl<T>(clazz, clazz, null, annotationStore, classTransformer);
}
public static <T> WBClass<T> of(AnnotatedType<T> annotatedType, ClassTransformer classTransformer)
{
AnnotationStore annotationStore = AnnotationStore.of(annotatedType.getAnnotations(), annotatedType.getAnnotations(), classTransformer.getTypeStore());
- return new WBClassImpl<T>(annotatedType.getJavaClass(), annotatedType.getBaseType(), annotationStore, classTransformer);
+ return new WBClassImpl<T>(annotatedType.getJavaClass(), annotatedType.getBaseType(), annotatedType, annotationStore, classTransformer);
}
- protected WBClassImpl(Class<T> rawType, Type type, AnnotationStore annotationStore, ClassTransformer classTransformer)
+ protected WBClassImpl(Class<T> rawType, Type type, AnnotatedType<T> annotatedType, AnnotationStore annotationStore, ClassTransformer classTransformer)
{
super(annotationStore, rawType, type);
this.name = rawType.getName();
@@ -194,6 +194,17 @@
this._nonStaticMemberClass = Reflections.isNonStaticInnerClass(rawType);
this._abstract = Reflections.isAbstract(rawType);
this._enum = rawType.isEnum();
+
+
+ Map<Field, AnnotatedField<? super T>> annotatedTypeFields = new HashMap<Field, AnnotatedField<? super T>>();
+ if (annotatedType != null)
+ {
+ for (AnnotatedField<? super T> annotatedField : annotatedType.getFields())
+ {
+ annotatedTypeFields.put(annotatedField.getJavaMember(), annotatedField);
+ }
+ }
+
for (Class<?> c = rawType; c != Object.class && c != null; c = c.getSuperclass())
{
for (Field field : c.getDeclaredFields())
@@ -202,7 +213,16 @@
{
field.setAccessible(true);
}
- WBField<?, ?> annotatedField = WBFieldImpl.of(field, getDeclaringWBClass(field, classTransformer), classTransformer);
+ WBField<?, ?> annotatedField = null;
+ if (annotatedTypeFields.containsKey(field))
+ {
+ annotatedField = WBFieldImpl.of(annotatedTypeFields.get(field), this.<T>getDeclaringWBClass(field, classTransformer), classTransformer);
+ }
+ else
+ {
+ annotatedField = WBFieldImpl.of(field, getDeclaringWBClass(field, classTransformer), classTransformer);
+ }
+
this.fields.add(annotatedField);
if (c == rawType)
{
@@ -249,12 +269,32 @@
}
});
+
+ Map<Constructor<? super T>, AnnotatedConstructor<T>> annotatedTypeConstructors = new HashMap<Constructor<? super T>, AnnotatedConstructor<T>>();
+ if (annotatedType != null)
+ {
+ for (AnnotatedConstructor<T> annotated : annotatedType.getConstructors())
+ {
+ annotatedTypeConstructors.put(annotated.getJavaMember(), annotated);
+ }
+ }
+
this.declaredConstructorsBySignature = new HashMap<ConstructorSignature, WBConstructor<?>>();
for (Constructor<?> constructor : rawType.getDeclaredConstructors())
{
- // TODO Fix this cast
- Constructor<T> c = (Constructor<T>) constructor;
- WBConstructor<T> annotatedConstructor = WBConstructorImpl.of(c, this.<T>getDeclaringWBClass(c, classTransformer), classTransformer);
+ WBConstructor<T> annotatedConstructor = null;
+ if (annotatedTypeConstructors.containsKey(constructor))
+ {
+ WBClass<T> declaringClass = this.getDeclaringWBClass(constructor, classTransformer);
+ annotatedConstructor = WBConstructorImpl.of(annotatedTypeConstructors.get(constructor), declaringClass, classTransformer);
+ }
+ else
+ {
+ // TODO Fix this cast
+ Constructor<T> c = (Constructor<T>) constructor;
+ annotatedConstructor = WBConstructorImpl.of(c, this.<T>getDeclaringWBClass(c, classTransformer), classTransformer);
+ }
+
if (!constructor.isAccessible())
{
constructor.setAccessible(true);
@@ -322,6 +362,16 @@
});
this.declaredMethodsBySignature = new HashMap<MethodSignature, WBMethod<?, ?>>();
this.methodsBySignature = new HashMap<MethodSignature, WBMethod<?, ?>>();
+
+ Map<Method, AnnotatedMethod<?>> annotatedTypeMethods = new HashMap<Method, AnnotatedMethod<?>>();
+ if (annotatedType != null)
+ {
+ for (AnnotatedMethod<?> annotated : annotatedType.getMethods())
+ {
+ annotatedTypeMethods.put(annotated.getJavaMember(), annotated);
+ }
+ }
+
for (Class<?> c = rawType; c != Object.class && c != null; c = c.getSuperclass())
{
for (Method method : c.getDeclaredMethods())
@@ -331,7 +381,15 @@
method.setAccessible(true);
}
- WBMethod<?, ?> annotatedMethod = WBMethodImpl.of(method, getDeclaringWBClass(method, classTransformer), classTransformer);
+ WBMethod<?, ?> annotatedMethod = null;
+ if (annotatedTypeMethods.containsKey(method))
+ {
+ annotatedMethod = WBMethodImpl.of(annotatedTypeMethods.get(method), this, classTransformer);
+ }
+ else
+ {
+ annotatedMethod = WBMethodImpl.of(method, getDeclaringWBClass(method, classTransformer), classTransformer);
+ }
this.methods.add(annotatedMethod);
this.methodsBySignature.put(annotatedMethod.getSignature(), annotatedMethod);
if (c == rawType)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBConstructorImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBConstructorImpl.java 2009-08-18 17:31:02 UTC (rev 3553)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBConstructorImpl.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -27,7 +27,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
import javax.enterprise.inject.spi.AnnotatedParameter;
import org.jboss.webbeans.BeanManagerImpl;
@@ -70,8 +72,15 @@
public static <T> WBConstructor<T> of(Constructor<T> constructor, WBClass<T> declaringClass, ClassTransformer classTransformer)
{
- return new WBConstructorImpl<T>(ensureAccessible(constructor), declaringClass, classTransformer);
+ AnnotationStore annotationStore = AnnotationStore.of(constructor, classTransformer.getTypeStore());
+ return new WBConstructorImpl<T>(ensureAccessible(constructor), null, annotationStore, declaringClass, classTransformer);
}
+
+ public static <T> WBConstructor<T> of(AnnotatedConstructor<T> annotatedConstructor, WBClass<T> declaringClass, ClassTransformer classTransformer)
+ {
+ AnnotationStore annotationStore = AnnotationStore.of(annotatedConstructor.getAnnotations(), annotatedConstructor.getAnnotations(), classTransformer.getTypeStore());
+ return new WBConstructorImpl<T>(ensureAccessible(annotatedConstructor.getJavaMember()), annotatedConstructor, annotationStore, declaringClass, classTransformer);
+ }
/**
* Constructor
@@ -81,9 +90,9 @@
* @param constructor The constructor method
* @param declaringClass The declaring class
*/
- private WBConstructorImpl(Constructor<T> constructor, WBClass<T> declaringClass, ClassTransformer classTransformer)
+ private WBConstructorImpl(Constructor<T> constructor, AnnotatedConstructor<T> annotatedConstructor, AnnotationStore annotationStore, WBClass<T> declaringClass, ClassTransformer classTransformer)
{
- super(AnnotationStore.of(constructor, classTransformer.getTypeStore()), constructor, constructor.getDeclaringClass(), constructor.getDeclaringClass(), declaringClass);
+ super(annotationStore, constructor, constructor.getDeclaringClass(), constructor.getDeclaringClass(), declaringClass);
this.constructor = constructor;
this.parameters = new ArrayList<WBParameter<?, ?>>();
@@ -97,13 +106,33 @@
});
+ Map<Integer, AnnotatedParameter<?>> annotatedTypeParameters = new HashMap<Integer, AnnotatedParameter<?>>();
+
+ if (annotatedConstructor != null)
+ {
+ for (AnnotatedParameter<?> annotated : annotatedConstructor.getParameters())
+ {
+ annotatedTypeParameters.put(annotated.getPosition(), annotated);
+ }
+ }
+
for (int i = 0; i < constructor.getParameterTypes().length; i++)
{
if (constructor.getParameterAnnotations()[i].length > 0)
{
Class<?> clazz = constructor.getParameterTypes()[i];
Type type = constructor.getGenericParameterTypes()[i];
- WBParameter<?, ?> parameter = WBParameterImpl.of(constructor.getParameterAnnotations()[i], clazz, type, this, i, classTransformer);
+ WBParameter<?, ?> parameter = null;
+ if (annotatedTypeParameters.containsKey(i))
+ {
+ AnnotatedParameter<?> annotatedParameter = annotatedTypeParameters.get(i);
+ parameter = WBParameterImpl.of(annotatedParameter.getAnnotations(), clazz, type, this, i, classTransformer);
+ }
+ else
+ {
+ parameter = WBParameterImpl.of(constructor.getParameterAnnotations()[i], clazz, type, this, i, classTransformer);
+ }
+
parameters.add(parameter);
for (Annotation annotation : parameter.getAnnotations())
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBFieldImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBFieldImpl.java 2009-08-18 17:31:02 UTC (rev 3553)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBFieldImpl.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -20,6 +20,8 @@
import java.lang.reflect.Field;
+import javax.enterprise.inject.spi.AnnotatedField;
+
import org.jboss.webbeans.introspector.AnnotationStore;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBField;
@@ -47,9 +49,16 @@
public static <T, X> WBFieldImpl<T, X> of(Field field, WBClass<X> declaringClass, ClassTransformer classTransformer)
{
- return new WBFieldImpl<T, X>(ensureAccessible(field), declaringClass, classTransformer);
+ AnnotationStore annotationStore = AnnotationStore.of(field, classTransformer.getTypeStore());
+ return new WBFieldImpl<T, X>(ensureAccessible(field), annotationStore, declaringClass, classTransformer);
}
+ public static <T, X> WBFieldImpl<T, X> of(AnnotatedField<? super X> annotatedField, WBClass<X> declaringClass, ClassTransformer classTransformer)
+ {
+ AnnotationStore annotationStore = AnnotationStore.of(annotatedField.getAnnotations(), annotatedField.getAnnotations(), classTransformer.getTypeStore());
+ return new WBFieldImpl<T, X>(ensureAccessible(annotatedField.getJavaMember()), annotationStore, declaringClass, classTransformer);
+ }
+
/**
* Constructor
*
@@ -59,9 +68,9 @@
* @param field The actual field
* @param declaringClass The abstraction of the declaring class
*/
- private WBFieldImpl(Field field, WBClass<X> declaringClass, ClassTransformer classTransformer)
+ private WBFieldImpl(Field field, AnnotationStore annotationStore, WBClass<X> declaringClass, ClassTransformer classTransformer)
{
- super(AnnotationStore.of(field, classTransformer.getTypeStore()), field, (Class<T>) field.getType(), field.getGenericType(), declaringClass);
+ super(annotationStore, field, (Class<T>) field.getType(), field.getGenericType(), declaringClass);
this.field = field;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBMethodImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBMethodImpl.java 2009-08-18 17:31:02 UTC (rev 3553)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBMethodImpl.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -28,7 +28,9 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
import org.jboss.webbeans.introspector.AnnotationStore;
@@ -75,8 +77,15 @@
public static <T, X> WBMethodImpl<T, X> of(Method method, WBClass<X> declaringClass, ClassTransformer classTransformer)
{
- return new WBMethodImpl<T, X>(ensureAccessible(method), declaringClass, classTransformer);
+ AnnotationStore annotationStore = AnnotationStore.of(method, classTransformer.getTypeStore());
+ return new WBMethodImpl<T, X>(ensureAccessible(method), null, annotationStore, declaringClass, classTransformer);
}
+
+ public static <T, X> WBMethodImpl<T, X> of(AnnotatedMethod<T> method, WBClass<X> declaringClass, ClassTransformer classTransformer)
+ {
+ AnnotationStore annotationStore = AnnotationStore.of(method.getAnnotations(), method.getAnnotations(), classTransformer.getTypeStore());
+ return new WBMethodImpl<T, X>(ensureAccessible(method.getJavaMember()), method, annotationStore, declaringClass, classTransformer);
+ }
/**
* Constructor
@@ -88,9 +97,9 @@
* @param declaringClass The declaring class abstraction
*/
@SuppressWarnings("unchecked")
- private WBMethodImpl(Method method, WBClass<X> declaringClass, ClassTransformer classTransformer)
+ private WBMethodImpl(Method method, AnnotatedMethod<T> annotatedMethod, AnnotationStore annotationStore, WBClass<X> declaringClass, ClassTransformer classTransformer)
{
- super(AnnotationStore.of(method, classTransformer.getTypeStore()), method, (Class<T>) method.getReturnType(), method.getGenericReturnType(), declaringClass);
+ super(annotationStore, method, (Class<T>) method.getReturnType(), method.getGenericReturnType(), declaringClass);
this.method = method;
this.parameters = new ArrayList<WBParameter<?, ?>>();
this.annotatedParameters = Multimaps.newListMultimap(new HashMap<Class<? extends Annotation>, Collection<WBParameter<?, ?>>>(), new Supplier< List<WBParameter<?, ?>>>()
@@ -102,6 +111,16 @@
}
});
+
+ Map<Integer, AnnotatedParameter<?>> annotatedTypeParameters = new HashMap<Integer, AnnotatedParameter<?>>();
+
+ if (annotatedMethod != null)
+ {
+ for (AnnotatedParameter<?> annotated : annotatedMethod.getParameters())
+ {
+ annotatedTypeParameters.put(annotated.getPosition(), annotated);
+ }
+ }
for (int i = 0; i < method.getParameterTypes().length; i++)
{
@@ -109,7 +128,16 @@
{
Class<? extends Object> clazz = method.getParameterTypes()[i];
Type type = method.getGenericParameterTypes()[i];
- WBParameter<?, ?> parameter = WBParameterImpl.of(method.getParameterAnnotations()[i], (Class<Object>) clazz, type, this, i, classTransformer);
+ WBParameter<?, ?> parameter = null;
+ if (annotatedTypeParameters.containsKey(i))
+ {
+ AnnotatedParameter<?> annotatedParameter = annotatedTypeParameters.get(i);
+ parameter = WBParameterImpl.of(annotatedParameter.getAnnotations(), clazz, type, this, i, classTransformer);
+ }
+ else
+ {
+ parameter = WBParameterImpl.of(method.getParameterAnnotations()[i], clazz, type, this, i, classTransformer);
+ }
this.parameters.add(parameter);
for (Annotation annotation : parameter.getAnnotations())
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java 2009-08-18 17:31:02 UTC (rev 3553)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -18,6 +18,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.util.Set;
import javax.enterprise.inject.spi.AnnotatedCallable;
@@ -38,6 +39,8 @@
public class WBParameterImpl<T, X> extends AbstractWBAnnotated<T, Object> implements WBParameter<T, X>
{
+ private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
+
// The final state
private final boolean _final = false;
// The static state
@@ -54,6 +57,11 @@
{
return new WBParameterImpl<T, X>(annotations, rawType, type, declaringMember, position, classTransformer);
}
+
+ public static <T, X> WBParameter<T, X> of(Set<Annotation> annotations, Class<T> rawType, Type type, WBCallable<?, X, ?> declaringMember, int position, ClassTransformer classTransformer)
+ {
+ return new WBParameterImpl<T, X>(annotations.toArray(EMPTY_ANNOTATION_ARRAY), rawType, type, declaringMember, position, classTransformer);
+ }
/**
* Constructor
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/AnnotatedTypeDecoratorTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/AnnotatedTypeDecoratorTest.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/AnnotatedTypeDecoratorTest.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,135 @@
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.webbeans.test.AbstractWebBeansTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Artifact
+public class AnnotatedTypeDecoratorTest extends AbstractWebBeansTest
+{
+ @Test
+ public void testAnnotationDecorator() throws Exception
+ {
+ NotAnnotated.reset();
+ AnnotatedType<NotAnnotated> type = getCurrentManager().createAnnotatedType(NotAnnotated.class);
+ checkAnnotations(type, new NoAnnotationsChecker());
+
+ type = new MockAnnotatedType<NotAnnotated>(type);
+ checkAnnotations(type, new MockAnnotationsChecker());
+
+ NonContextual<NotAnnotated> nonContextual = new NonContextual<NotAnnotated>(getCurrentManager(), type);
+ NotAnnotated instance = nonContextual.create();
+ assertNotNull(instance);
+ nonContextual.postConstruct(instance);
+
+ assertNotNull(instance.getFromField());
+ assertNotNull(NotAnnotated.getFromConstructor());
+ assertNotNull(NotAnnotated.getFromInitializer());
+ }
+
+ private void checkAnnotations(AnnotatedType<NotAnnotated> type, TypeChecker checker)
+ {
+ checker.assertAnnotations(type);
+
+ assertEquals(1, type.getConstructors().size());
+
+ checker.assertAnnotations(type.getConstructors().iterator().next());
+ checker.assertAnnotations(type.getConstructors().iterator().next().getParameters().get(0));
+
+ assertEquals(3, type.getFields().size());
+ for (AnnotatedField<? super NotAnnotated> field : type.getFields())
+ {
+ if (field.getJavaMember().getName().equals("fromField"))
+ {
+ checker.assertAnnotations(field);
+ }
+ else
+ {
+ assertEquals(0, field.getAnnotations().size());
+ }
+ }
+ assertEquals(5, type.getMethods().size());
+ checker.assertAnnotations(type.getMethods().iterator().next());
+ }
+
+
+
+
+ interface TypeChecker
+ {
+ void assertAnnotations(Annotated annotated);
+ }
+
+ class NoAnnotationsChecker implements TypeChecker
+ {
+
+ public void assertAnnotations(Annotated annotated)
+ {
+ assertEquals(0, annotated.getAnnotations().size());
+ }
+ }
+
+ class MockAnnotationsChecker implements TypeChecker
+ {
+
+ public void assertAnnotations(Annotated annotated)
+ {
+ if (annotated instanceof MockAnnotatedCallable)
+ {
+ assertEquals(1, annotated.getAnnotations().size());
+ assertTrue(annotated.isAnnotationPresent(Initializer.class));
+ }
+ else if (annotated instanceof MockAnnotatedField<?>)
+ {
+ assertEquals(1, annotated.getAnnotations().size());
+ assertTrue(annotated.isAnnotationPresent(Current.class));
+ }
+ }
+ }
+
+ public class NonContextual<T> {
+
+ final InjectionTarget<T> it;
+ final BeanManager manager;
+ CreationalContext<T> cc;
+
+ public NonContextual(BeanManager manager, AnnotatedType<T> type) {
+ this.manager = manager;
+ this.it = manager.createInjectionTarget(type);
+ cc = manager.createCreationalContext(null);
+ }
+
+ public T create()
+ {
+ return it.produce(cc);
+ }
+
+ public CreationalContext<T> postConstruct(T instance) {
+ it.inject(instance, cc);
+ it.postConstruct(instance);
+ return cc;
+ }
+
+ public void preDestroy(T instance) {
+ it.preDestroy(instance);
+ }
+ }
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/AnnotatedTypeDecoratorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/Foo.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/Foo.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/Foo.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+/**
+ * @author pmuir
+ *
+ */
+public class Foo
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/Foo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotated.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotated.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotated.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,83 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.spi.Annotated;
+
+import org.jboss.webbeans.literal.CurrentLiteral;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockAnnotated implements Annotated
+{
+ private final static Current CURRENT = new CurrentLiteral();
+
+ private Annotated delegate;
+
+ public MockAnnotated(Annotated delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ Annotated getDelegate()
+ {
+ return delegate;
+ }
+
+ public Type getBaseType()
+ {
+ return delegate.getBaseType();
+ }
+
+ public Set<Type> getTypeClosure()
+ {
+ return delegate.getTypeClosure();
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ if (annotationType == Current.class)
+ {
+ return (T)CURRENT;
+ }
+ return null;
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ return Collections.singleton((Annotation)CURRENT);
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return annotationType == Current.class;
+ }
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotated.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedCallable.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedCallable.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedCallable.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,111 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+import org.jboss.annotation.factory.AnnotationCreator;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class MockAnnotatedCallable<X> extends MockAnnotatedMember<X> implements AnnotatedCallable<X>
+{
+ private final static Initializer INITIALIZER;
+ static
+ {
+ try
+ {
+ INITIALIZER = (Initializer)AnnotationCreator.createAnnotation("@" + Initializer.class.getName(), Initializer.class);
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private final List<AnnotatedParameter<X>> parameters;
+
+ public MockAnnotatedCallable(Annotated delegate)
+ {
+ super(delegate);
+ parameters = initialiseParameters();
+ }
+
+ @Override
+ AnnotatedCallable<X> getDelegate()
+ {
+ return (AnnotatedCallable<X>) super.getDelegate();
+ }
+
+ private List<AnnotatedParameter<X>> initialiseParameters()
+ {
+ int size = getDelegate().getParameters().size();
+ List<AnnotatedParameter<X>> params = new ArrayList<AnnotatedParameter<X>>(size);
+ if (size > 0)
+ {
+ for (AnnotatedParameter<X> param : getDelegate().getParameters())
+ {
+ params.add(new MockAnnotatedParameter<X>(param, this));
+ }
+ }
+ return params;
+ }
+
+ public List<AnnotatedParameter<X>> getParameters()
+ {
+ return parameters;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ if (annotationType == Initializer.class)
+ {
+ return (T)INITIALIZER;
+ }
+ return null;
+ }
+
+ @Override
+ public Set<Annotation> getAnnotations()
+ {
+ return Collections.singleton((Annotation)INITIALIZER);
+ }
+
+ @Override
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return annotationType == Initializer.class;
+ }
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedCallable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedConstructor.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedConstructor.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedConstructor.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+import java.lang.reflect.Constructor;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class MockAnnotatedConstructor<X> extends MockAnnotatedCallable<X> implements AnnotatedConstructor<X>
+{
+ MockAnnotatedConstructor(AnnotatedConstructor<X> delegate)
+ {
+ super(delegate);
+ }
+
+ @Override
+ AnnotatedConstructor<X> getDelegate()
+ {
+ return (AnnotatedConstructor<X>)super.getDelegate();
+ }
+
+ public Constructor<X> getJavaMember()
+ {
+ return getDelegate().getJavaMember();
+ }
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedConstructor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedField.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedField.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedField.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,81 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedField;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class MockAnnotatedField<X> extends MockAnnotatedMember<X> implements AnnotatedField<X>
+{
+ MockAnnotatedField(AnnotatedField<? super X> delegate)
+ {
+ super(delegate);
+ }
+
+ @Override
+ AnnotatedField<X> getDelegate()
+ {
+ return (AnnotatedField<X>)super.getDelegate();
+ }
+
+ public Field getJavaMember()
+ {
+ return getDelegate().getJavaMember();
+ }
+
+ private boolean isDecoratedField()
+ {
+ return getJavaMember().getName().equals("fromField");
+ }
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ if (isDecoratedField())
+ return super.getAnnotation(annotationType);
+ return null;
+ }
+
+ @Override
+ public Set<Annotation> getAnnotations()
+ {
+ if (isDecoratedField())
+ return super.getAnnotations();
+ return Collections.emptySet();
+ }
+
+ @Override
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ if (isDecoratedField())
+ return super.isAnnotationPresent(annotationType);
+ return false;
+ }
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMember.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMember.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMember.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class MockAnnotatedMember<X> extends MockAnnotated implements AnnotatedMember<X>
+{
+ public MockAnnotatedMember(Annotated delegate)
+ {
+ super(delegate);
+ }
+
+ @Override
+ AnnotatedMember<X> getDelegate()
+ {
+ return (AnnotatedMember<X>)super.getDelegate();
+ }
+
+ public AnnotatedType<X> getDeclaringType()
+ {
+ return getDelegate().getDeclaringType();
+ }
+
+ public boolean isStatic()
+ {
+ return getDelegate().isStatic();
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMember.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMethod.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMethod.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMethod.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockAnnotatedMethod<X> extends MockAnnotatedCallable<X> implements AnnotatedMethod<X>
+{
+ public MockAnnotatedMethod(Annotated delegate)
+ {
+ // FIXME MDRAnnotatedMethod constructor
+ super(delegate);
+ }
+
+ @Override
+ public AnnotatedMethod<X> getDelegate()
+ {
+ return (AnnotatedMethod<X>)super.getDelegate();
+
+ }
+
+ public Method getJavaMember()
+ {
+ return getDelegate().getJavaMember();
+ }
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedMethod.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedParameter.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedParameter.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedParameter.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockAnnotatedParameter<X> extends MockAnnotated implements AnnotatedParameter<X>
+{
+ private final AnnotatedCallable<X> callable;
+
+ public MockAnnotatedParameter(Annotated delegate, AnnotatedCallable<X> callable)
+ {
+ super(delegate);
+ this.callable = callable;
+ }
+
+ @Override
+ AnnotatedParameter<X> getDelegate()
+ {
+ return (AnnotatedParameter<X>)super.getDelegate();
+ }
+
+ public AnnotatedCallable<X> getDeclaringCallable()
+ {
+ return callable;
+ }
+
+ public int getPosition()
+ {
+ return getDelegate().getPosition();
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedParameter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedType.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedType.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedType.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,122 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class MockAnnotatedType<X> extends MockAnnotated implements AnnotatedType<X>
+{
+ private final Set<AnnotatedConstructor<X>> annotatedConstructors;
+
+ private final Set<AnnotatedField<? super X>> annotatedFields;
+
+ private final Set<AnnotatedMethod<? super X>> annotatedMethods;
+
+ MockAnnotatedType(AnnotatedType<X> delegate)
+ {
+ super(delegate);
+ annotatedConstructors = initialiseConstructors();
+ annotatedFields = initialiseAnnotatedFields();
+ annotatedMethods = initialiseMethods();
+ }
+
+ private Set<AnnotatedField<? super X>> initialiseAnnotatedFields()
+ {
+ Set<AnnotatedField<? super X>> fields = new HashSet<AnnotatedField<? super X>>();
+ for (AnnotatedField<? super X> field : getDelegate().getFields())
+ {
+ if (field.isStatic())
+ {
+ fields.add(field);
+ }
+ else
+ {
+ fields.add(new MockAnnotatedField<X>(field));
+ }
+ }
+ return fields;
+ }
+
+ private Set<AnnotatedConstructor<X>> initialiseConstructors()
+ {
+ Set<AnnotatedConstructor<X>> constructors = new HashSet<AnnotatedConstructor<X>>();
+ for (AnnotatedConstructor<X> constructor : getDelegate().getConstructors())
+ {
+ constructors.add(new MockAnnotatedConstructor<X>(constructor));
+ }
+ return constructors;
+ }
+
+ private Set<AnnotatedMethod<? super X>> initialiseMethods()
+ {
+ Set<AnnotatedMethod<? super X>> methods = new HashSet<AnnotatedMethod<? super X>>();
+ for (AnnotatedMethod<? super X> method : getDelegate().getMethods())
+ {
+ if (method.isStatic())
+ {
+ methods.add(method);
+ }
+ else
+ {
+ methods.add(new MockAnnotatedMethod<X>(method));
+ }
+ }
+ return methods;
+ }
+
+ @Override
+ AnnotatedType<X> getDelegate()
+ {
+ return (AnnotatedType<X>)super.getDelegate();
+ }
+
+ public Set<AnnotatedConstructor<X>> getConstructors()
+ {
+ return annotatedConstructors;
+ }
+
+ public Set<AnnotatedField<? super X>> getFields()
+ {
+ return annotatedFields;
+ }
+
+ public Set<AnnotatedMethod<? super X>> getMethods()
+ {
+ return annotatedMethods;
+ }
+
+ public Class<X> getJavaClass()
+ {
+ return getDelegate().getJavaClass();
+ }
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/MockAnnotatedType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/NotAnnotated.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/NotAnnotated.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/NotAnnotated.java 2009-08-18 21:16:39 UTC (rev 3554)
@@ -0,0 +1,77 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.webbeans.test.unit.annotated.decoration;
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class NotAnnotated
+{
+ private static Foo fromConstructor;
+
+ private static Foo fromInitialize;
+
+ private Foo fromField;
+
+ public NotAnnotated(Foo foo)
+ {
+ fromConstructor = foo;
+ }
+
+ public void initialize(Foo foo)
+ {
+ fromInitialize = foo;
+ }
+
+ /**
+ * @return the beanFromConstructor
+ */
+ public static Foo getFromConstructor()
+ {
+ return fromConstructor;
+ }
+
+ /**
+ * @return the beanFromInitialize
+ */
+ public static Foo getFromInitializer()
+ {
+ return fromInitialize;
+ }
+
+ /**
+ * @return the fromField
+ */
+ public Foo getFromField()
+ {
+ return fromField;
+ }
+
+ public static void reset()
+ {
+ fromConstructor = null;
+ fromInitialize = null;
+ }
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/annotated/decoration/NotAnnotated.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/tests/unit-tests.xml
===================================================================
--- ri/trunk/tests/unit-tests.xml 2009-08-18 17:31:02 UTC (rev 3553)
+++ ri/trunk/tests/unit-tests.xml 2009-08-18 21:16:39 UTC (rev 3554)
@@ -24,6 +24,7 @@
<package name="org.jboss.webbeans.test.unit.activities.current" />
<package name="org.jboss.webbeans.test.unit.activities.child" />
<package name="org.jboss.webbeans.test.unit.annotated" />
+ <package name="org.jboss.webbeans.test.unit.annotated.decoration" />
<package name="org.jboss.webbeans.test.unit.bootstrap" />
<package name="org.jboss.webbeans.test.unit.bootstrap.environments" />
<package name="org.jboss.webbeans.test.unit.bootstrap.environments.multipleEnterprise" />
More information about the weld-commits
mailing list