[weld-commits] Weld SVN: r5190 - in extensions/trunk/core/src/main/java/org/jboss/weld/extensions: util and 2 other directories.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Wed Dec 2 07:08:08 EST 2009
Author: pete.muir at jboss.org
Date: 2009-12-02 07:08:07 -0500 (Wed, 02 Dec 2009)
New Revision: 5190
Added:
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationStore.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedMethod.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/TypeStore.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/AnnotationRedefinition.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/Reannotated.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedCallable.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedConstructor.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedField.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMember.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMethod.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedParameter.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedType.java
Removed:
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java
Modified:
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/CoreExtension.java
extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/BeanImpl.java
Log:
Reorg, WELDX-54
Modified: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/CoreExtension.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/CoreExtension.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/CoreExtension.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -21,11 +21,11 @@
import javax.inject.Named;
import javax.inject.Qualifier;
-import org.jboss.weld.extensions.util.AnnotationRedefinition;
import org.jboss.weld.extensions.util.BeanImpl;
-import org.jboss.weld.extensions.util.Reannotated;
-import org.jboss.weld.extensions.util.ReannotatedMember;
-import org.jboss.weld.extensions.util.ReannotatedType;
+import org.jboss.weld.extensions.util.reannotated.AnnotationRedefinition;
+import org.jboss.weld.extensions.util.reannotated.Reannotated;
+import org.jboss.weld.extensions.util.reannotated.ReannotatedMember;
+import org.jboss.weld.extensions.util.reannotated.ReannotatedType;
public class CoreExtension implements Extension
{
Deleted: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -1,8 +0,0 @@
-package org.jboss.weld.extensions.util;
-
-import java.lang.annotation.Annotation;
-
-public interface AnnotationRedefinition<X extends Annotation>
-{
- public X redefine(X annotation, Reannotated reannotated);
-}
Modified: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/BeanImpl.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/BeanImpl.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/BeanImpl.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -15,6 +15,8 @@
import javax.inject.Qualifier;
import javax.inject.Scope;
+import org.jboss.weld.extensions.util.reannotated.ReannotatedType;
+
/**
* This implementation of Bean is immutable and threadsafe.
*
Deleted: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -1,158 +0,0 @@
-package org.jboss.weld.extensions.util;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.AbstractSet;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.Annotated;
-
-/**
- * This class is not thread-safe, and the client must provide any synchronization needed
- *
- * @author Gavin King
- * @author Pete Muir
- *
- *
- */
-public abstract class Reannotated implements Annotated
-{
-
- private static class AnnotationSet extends AbstractSet<Annotation>
- {
-
- List<Annotation> list = new ArrayList<Annotation>();
-
- AnnotationSet(Map<Class<? extends Annotation>, Annotation> annotations, Set<Annotation> delegateAnnotations)
- {
- list.addAll(annotations.values());
- for (Annotation ann : delegateAnnotations)
- {
- if (!annotations.containsKey(ann.annotationType()))
- {
- list.add(ann);
- }
- }
- }
-
- @Override
- public Iterator<Annotation> iterator()
- {
- return list.iterator();
- }
-
- @Override
- public int size()
- {
- return list.size();
- }
-
- }
-
-
- protected abstract Annotated delegate();
-
- private final Map<Class<? extends Annotation>, Annotation> annotations;
-
- public Reannotated()
- {
- this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
- }
-
- public <X extends Annotation> void redefine(Class<X> annotationType, AnnotationRedefinition<X> visitor)
- {
- if (isAnnotationPresent(annotationType))
- {
- X redefined = visitor.redefine(getAnnotation(annotationType), this);
- if (redefined == null)
- {
- annotations.remove(annotationType);
- }
- else
- {
- annotations.put(annotationType, redefined);
- }
- }
- }
-
- /*
- * public void undefine(Class<? extends Annotation> annotationType) {
- * annotations.put(annotationType, null); }
- */
-
- public void define(Annotation ann)
- {
- annotations.put(ann.annotationType(), ann);
- }
-
- public boolean isAnnotationWithMetatypePresent(Class<? extends Annotation> metaannotationType)
- {
- for (Annotation ann : getAnnotations())
- {
- if (ann.annotationType().isAnnotationPresent(metaannotationType))
- {
- return true;
- }
- }
- return false;
- }
-
- public Set<Annotation> getAnnotationsWithMetatype(Class<? extends Annotation> metaannotationType)
- {
- Set<Annotation> set = new HashSet<Annotation>();
- for (Annotation ann : getAnnotations())
- {
- if (ann.annotationType().isAnnotationPresent(metaannotationType))
- {
- set.add(ann);
- }
- }
- return set;
- }
-
- public abstract Class<?> getJavaClass();
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType)
- {
- if (annotationType == null)
- {
- throw new IllegalArgumentException("annotationType argument must not be null");
- }
- Annotation ann = annotations.get(annotationType);
- if (ann != null)
- {
- return annotationType.cast(ann);
- }
- else
- {
- return delegate().getAnnotation(annotationType);
- }
- }
-
- public Set<Annotation> getAnnotations()
- {
- return new AnnotationSet(annotations, delegate().getAnnotations());
- }
-
- public Type getBaseType()
- {
- return delegate().getBaseType();
- }
-
- public Set<Type> getTypeClosure()
- {
- return delegate().getTypeClosure();
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return annotations.containsKey(annotationType) || delegate().isAnnotationPresent(annotationType);
- }
-
-}
Deleted: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -1,60 +0,0 @@
-package org.jboss.weld.extensions.util;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.enterprise.inject.spi.AnnotatedCallable;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-
-/**
- * This implementation of {@link AnnotatedCallable} is not threadsafe and any synchronization should be performed by the client
- *
- * @author Gavin King
- * @author Pete Muir
- *
- * @param <X>
- */
-public abstract class ReannotatedCallable<X> extends ReannotatedMember<X> implements AnnotatedCallable<X>
-{
-
- private final List<ReannotatedParameter<X>> parameters = new ArrayList<ReannotatedParameter<X>>();
-
- public ReannotatedCallable(ReannotatedType<X> declaringType, List<AnnotatedParameter<X>> params)
- {
- super(declaringType);
- for (AnnotatedParameter<X> param : params)
- {
- parameters.add(new ReannotatedParameter<X>(param, this, param.getPosition()));
- }
- }
-
- @Override
- protected abstract AnnotatedCallable<X> delegate();
-
- public List<AnnotatedParameter<X>> getParameters()
- {
- return new ArrayList<AnnotatedParameter<X>>(parameters);
- }
-
- public ReannotatedParameter<X> getParameter(int pos)
- {
- return parameters.get(pos);
- }
-
- public <Y extends Annotation> void redefineParameters(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- for (ReannotatedParameter<X> param : parameters)
- {
- param.redefine(annotationType, visitor);
- }
- }
-
- @Override
- public <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- redefine(annotationType, visitor);
- redefineParameters(annotationType, visitor);
- }
-
-}
Deleted: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -1,43 +0,0 @@
-package org.jboss.weld.extensions.util;
-
-import java.lang.reflect.Constructor;
-
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-
-/**
- * This implementation of {@link AnnotatedConstructor} is not threadsafe and any synchronization must be performed by the client
- *
- * @author Gavin King
- *
- * @param <X>
- */
-public class ReannotatedConstructor<X> extends ReannotatedCallable<X> implements AnnotatedConstructor<X>
-{
-
- private final AnnotatedConstructor<X> constructor;
-
- ReannotatedConstructor(ReannotatedType<X> declaringType, AnnotatedConstructor<X> constructor)
- {
- super(declaringType, constructor.getParameters());
- this.constructor = constructor;
- }
-
- @Override
- protected AnnotatedConstructor<X> delegate()
- {
- return constructor;
- }
-
- @Override
- public Constructor<X> getJavaMember()
- {
- return constructor.getJavaMember();
- }
-
- @Override
- public boolean isStatic()
- {
- return constructor.isStatic();
- }
-
-}
Deleted: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -1,50 +0,0 @@
-package org.jboss.weld.extensions.util;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-
-import javax.enterprise.inject.spi.AnnotatedField;
-
-/**
- * This implementation of {@link AnnotatedField} is not threadsafe and any synchronization must be performed by the client
- *
- * @author Gavin King
- *
- * @param <X>
- */
-public class ReannotatedField<X> extends ReannotatedMember<X> implements AnnotatedField<X>
-{
-
- private final AnnotatedField<X> field;
-
- ReannotatedField(ReannotatedType<X> declaringType, AnnotatedField<X> field)
- {
- super(declaringType);
- this.field = field;
- }
-
- @Override
- protected AnnotatedField<X> delegate()
- {
- return field;
- }
-
- @Override
- public Field getJavaMember()
- {
- return field.getJavaMember();
- }
-
- @Override
- public boolean isStatic()
- {
- return field.isStatic();
- }
-
- @Override
- public <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- redefine(annotationType, visitor);
- }
-
-}
Deleted: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -1,51 +0,0 @@
-package org.jboss.weld.extensions.util;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
-
-import javax.enterprise.inject.spi.AnnotatedMember;
-
-/**
- * This implementation of {@link AnnotatedMember} is not threadsafe and any synchronization must be performed by the client
- *
- * @author Gavin King
- *
- * @param <X>
- */
-public abstract class ReannotatedMember<X> extends Reannotated implements AnnotatedMember<X>
-{
-
- private final ReannotatedType<X> declaringType;
-
- ReannotatedMember(ReannotatedType<X> declaringType)
- {
- this.declaringType = declaringType;
- }
-
- public ReannotatedType<X> getDeclaringType()
- {
- return declaringType;
- }
-
- @Override
- protected abstract AnnotatedMember<X> delegate();
-
- public Member getJavaMember()
- {
- return delegate().getJavaMember();
- }
-
- public boolean isStatic()
- {
- return delegate().isStatic();
- }
-
- @Override
- public Class<?> getJavaClass()
- {
- return getJavaMember().getDeclaringClass();
- }
-
- public abstract <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor);
-
-}
Deleted: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -1,43 +0,0 @@
-package org.jboss.weld.extensions.util;
-
-import java.lang.reflect.Method;
-
-import javax.enterprise.inject.spi.AnnotatedMethod;
-
-/**
- * This implementation of {@link AnnotatedMethod} is not threadsafe and any synchronization must be performed by the client
- *
- * @author Gavin King
- *
- * @param <X>
- */
-public class ReannotatedMethod<X> extends ReannotatedCallable<X> implements AnnotatedMethod<X>
-{
-
- private final AnnotatedMethod<X> method;
-
- ReannotatedMethod(ReannotatedType<X> declaringType, AnnotatedMethod<X> method)
- {
- super(declaringType, method.getParameters());
- this.method = method;
- }
-
- @Override
- protected AnnotatedMethod<X> delegate()
- {
- return method;
- }
-
- @Override
- public Method getJavaMember()
- {
- return method.getJavaMember();
- }
-
- @Override
- public boolean isStatic()
- {
- return method.isStatic();
- }
-
-}
Deleted: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -1,60 +0,0 @@
-package org.jboss.weld.extensions.util;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-
-import javax.enterprise.inject.spi.AnnotatedParameter;
-
-/**
- * This implementation of {@link AnnotatedParameter} is not threadsafe and any synchronization must be performed by the client
- *
- * @author Gavin King
- *
- * @param <X>
- */
-public class ReannotatedParameter<X> extends Reannotated implements AnnotatedParameter<X>
-{
-
- private final AnnotatedParameter<X> parameter;
- private final ReannotatedCallable<X> callable;
- private final int pos;
-
- public ReannotatedParameter(AnnotatedParameter<X> parameter, ReannotatedCallable<X> callable, int pos)
- {
- this.parameter = parameter;
- this.callable = callable;
- this.pos = pos;
- }
-
- @Override
- protected AnnotatedParameter<X> delegate()
- {
- return parameter;
- }
-
- public ReannotatedCallable<X> getDeclaringCallable()
- {
- return callable;
- }
-
- public int getPosition()
- {
- return pos;
- }
-
- @Override
- public Class<?> getJavaClass()
- {
- Member member = callable.getJavaMember();
- if (member instanceof Method)
- {
- return Method.class.cast(member).getParameterTypes()[pos];
- }
- else
- {
- return Constructor.class.cast(member).getParameterTypes()[pos];
- }
- }
-
-}
Deleted: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java 2009-12-02 11:39:20 UTC (rev 5189)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -1,239 +0,0 @@
-package org.jboss.weld.extensions.util;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-import javax.enterprise.inject.spi.AnnotatedField;
-import javax.enterprise.inject.spi.AnnotatedMember;
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-/**
- * This implementation of {@link AnnotatedType} is not threadsafe and any synchronization must be performed by the client
- *
- * @author Gavin King
- *
- * @param <X>
- */
-public class ReannotatedType<X> extends Reannotated implements AnnotatedType<X>
-{
-
- private final AnnotatedType<X> type;
- private final HashMap<Class<?>, ReannotatedType<?>> types;
-
- private final Map<Member, ReannotatedField<? super X>> fields;
- private final Map<Member, ReannotatedMethod<? super X>> methods;
- private final Map<Member, ReannotatedConstructor<X>> constructors;
-
- public ReannotatedType(AnnotatedType<X> type)
- {
- this(type, new HashMap<Class<?>, ReannotatedType<?>>());
- }
-
- public ReannotatedType(AnnotatedType<X> type, HashMap<Class<?>, ReannotatedType<?>> types)
- {
- this.type = type;
- this.types = types;
-
- fields = new HashMap<Member, ReannotatedField<? super X>>();
- methods = new HashMap<Member, ReannotatedMethod<? super X>>();
- constructors = new HashMap<Member, ReannotatedConstructor<X>>();
-
- for (AnnotatedField<? super X> field : type.getFields())
- {
- addField(field);
- }
- for (AnnotatedMethod<? super X> method : type.getMethods())
- {
- addMethod(method);
- }
- for (AnnotatedConstructor<X> constructor : type.getConstructors())
- {
- addConstructor(constructor);
- }
- }
-
- private <Y> ReannotatedType<Y> getDeclaringType(AnnotatedMember<Y> member)
- {
- return getSupertype(member.getDeclaringType());
- }
-
- @SuppressWarnings("unchecked")
- private <Y> ReannotatedType<Y> getSupertype(AnnotatedType<Y> supertype)
- {
- Class<Y> memberJavaClass = supertype.getJavaClass();
- if (memberJavaClass == type.getJavaClass())
- {
- return (ReannotatedType<Y>) this;
- }
- else
- {
- ReannotatedType<Y> result = (ReannotatedType<Y>) types.get(memberJavaClass);
- if (result == null)
- {
- result = new ReannotatedType<Y>(supertype, types);
- types.put(memberJavaClass, result);
- }
- return result;
- }
- }
-
- private void addConstructor(AnnotatedConstructor<X> constructor)
- {
- constructors.put(constructor.getJavaMember(), new ReannotatedConstructor<X>(this, constructor));
- }
-
- @SuppressWarnings("unchecked")
- private void addMethod(AnnotatedMethod<? super X> method)
- {
- Class<? super X> methodJavaClass = method.getDeclaringType().getJavaClass();
- if (methodJavaClass.isAssignableFrom(type.getJavaClass()))
- {
- final ReannotatedMethod<? super X> reannotated;
- if (methodJavaClass == type.getJavaClass())
- {
- reannotated = new ReannotatedMethod(getDeclaringType(method), method);
- }
- else
- {
- reannotated = getInheritedMethod(method);
- }
- methods.put(method.getJavaMember(), reannotated);
- }
- }
-
- @SuppressWarnings("unchecked")
- private void addField(AnnotatedField<? super X> field)
- {
- Class<? super X> fieldJavaClass = field.getDeclaringType().getJavaClass();
- final ReannotatedField<? super X> reannotated;
- if (fieldJavaClass.isAssignableFrom(type.getJavaClass()))
- {
- if (fieldJavaClass == type.getJavaClass())
- {
- reannotated = new ReannotatedField(getDeclaringType(field), field);
- }
- else
- {
- reannotated = getInheritedField(field);
- }
- fields.put(field.getJavaMember(), reannotated);
- }
- }
-
- private <Y> ReannotatedField<? super Y> getInheritedField(AnnotatedField<Y> field)
- {
- return getDeclaringType(field).getField(field.getJavaMember());
- }
-
- private <Y> ReannotatedMethod<? super Y> getInheritedMethod(AnnotatedMethod<Y> method)
- {
- return getDeclaringType(method).getMethod(method.getJavaMember());
- }
-
- @Override
- protected AnnotatedType<X> delegate()
- {
- return type;
- }
-
- public Set<AnnotatedConstructor<X>> getConstructors()
- {
- return new HashSet<AnnotatedConstructor<X>>(constructors.values());
- }
-
- public Set<AnnotatedMethod<? super X>> getMethods()
- {
- return new HashSet<AnnotatedMethod<? super X>>(methods.values());
- }
-
- public Set<AnnotatedField<? super X>> getFields()
- {
- return new HashSet<AnnotatedField<? super X>>(fields.values());
- }
-
- public ReannotatedConstructor<X> getConstructor(Constructor<X> constructor)
- {
- return constructors.get(constructor);
- }
-
- public ReannotatedMethod<? super X> getMethod(Method constructor)
- {
- return methods.get(constructor);
- }
-
- public ReannotatedField<? super X> getField(Field field)
- {
- return fields.get(field);
- }
-
- public <Y extends Annotation> void redefineConstructors(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- for (ReannotatedConstructor<X> constructor : constructors.values())
- {
- constructor.redefine(annotationType, visitor);
- }
- }
-
- public <Y extends Annotation> void redefineMethods(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- for (ReannotatedMethod<? super X> method : methods.values())
- {
- method.redefine(annotationType, visitor);
- }
- }
-
- public <Y extends Annotation> void redefineFields(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- for (ReannotatedField<? super X> field : fields.values())
- {
- field.redefine(annotationType, visitor);
- }
- }
-
- public <Y extends Annotation> void redefineMembers(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- redefineFields(annotationType, visitor);
- redefineMethods(annotationType, visitor);
- redefineConstructors(annotationType, visitor);
- }
-
- public <Y extends Annotation> void redefineMembersAndParameters(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- redefineMembers(annotationType, visitor);
- redefineParameters(annotationType, visitor);
- }
-
- public <Y extends Annotation> void redefineParameters(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- for (ReannotatedMethod<? super X> method : methods.values())
- {
- method.redefineParameters(annotationType, visitor);
- }
- for (ReannotatedConstructor<X> constructor : constructors.values())
- {
- constructor.redefineParameters(annotationType, visitor);
- }
- }
-
- public <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
- {
- redefine(annotationType, visitor);
- redefineMembersAndParameters(annotationType, visitor);
- }
-
- @Override
- public Class<X> getJavaClass()
- {
- return type.getJavaClass();
- }
-
-}
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,73 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+public abstract class AbstractNewAnnotatedCallable<X, Y extends Member> extends AbstractNewAnnotatedMember<X, Y> implements AnnotatedCallable<X>
+{
+
+ private final List<NewAnnotatedParameter<X>> parameters = new ArrayList<NewAnnotatedParameter<X>>();
+
+ protected AbstractNewAnnotatedCallable(AnnotatedType<X> type, Method method, boolean readAnnotations)
+ {
+ super(type, (Y) method, method.getReturnType(), readAnnotations);
+ int len = method.getTypeParameters().length;
+ for (int i = 0; i < len; ++i)
+ {
+ NewAnnotatedParameter<X> p = new NewAnnotatedParameter<X>(this, method.getParameterTypes()[i], i, readAnnotations);
+ parameters.add(p);
+ }
+ }
+
+ protected AbstractNewAnnotatedCallable(AnnotatedType<X> type, Constructor<X> constructor, boolean readAnnotations)
+ {
+ super(type, (Y) constructor, constructor.getDeclaringClass(), readAnnotations);
+ int len = constructor.getTypeParameters().length;
+ for (int i = 0; i < len; ++i)
+ {
+ NewAnnotatedParameter<X> p = new NewAnnotatedParameter<X>(this, constructor.getParameterTypes()[i], i, readAnnotations);
+ parameters.add(p);
+ }
+ }
+
+
+ @Override
+ public void clearAllAnnotations()
+ {
+ super.clearAllAnnotations();
+ for (NewAnnotatedParameter<X> p : parameters)
+ {
+ p.clearAllAnnotations();
+ }
+ }
+
+ public List<AnnotatedParameter<X>> getParameters()
+ {
+ return (List) Collections.unmodifiableList(parameters);
+ }
+
+ public List<NewAnnotatedParameter<X>> getNewAnnotatedParameters()
+ {
+ return Collections.unmodifiableList(parameters);
+ }
+
+ public NewAnnotatedParameter<X> getParameter(int index)
+ {
+ return parameters.get(index);
+
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,77 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Annotated;
+
+/**
+ * The base class for all New Annotated types.
+ *
+ * @author Stuart Douglas
+ *
+ */
+public abstract class AbstractNewAnnotatedElement implements Annotated
+{
+
+ private final Class<?> type;
+
+ private final TypeStore typeStore = new TypeStore();
+ private final AnnotationStore annotations = new AnnotationStore();
+
+ /**
+ * Clears all annotation data from the the class. Useful if we are not
+ * interested in the annotations that are actually on the class but instead
+ * want to apply our own
+ */
+ public void clearAllAnnotations()
+ {
+ annotations.clear();
+ }
+
+ protected AbstractNewAnnotatedElement(Class<?> type, boolean readAnnotations)
+ {
+ typeStore.add(type);
+ this.type = type;
+ if (readAnnotations)
+ {
+ annotations.addAll(type);
+ }
+ }
+
+ public void addAnnotation(Annotation a)
+ {
+ annotations.addAnnotation(a);
+ }
+
+ public void removeAnnotation(Class<? extends Annotation> c)
+ {
+ annotations.removeAnnotation(c);
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ return annotations.getAnnotation(annotationType);
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ return annotations.getAnnotations();
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return annotations.isAnnotationPresent(annotationType);
+ }
+
+ public Set<Type> getTypeClosure()
+ {
+ return typeStore.getTypes();
+ }
+
+ public Type getBaseType()
+ {
+ return type;
+ }
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,41 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Modifier;
+
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+public abstract class AbstractNewAnnotatedMember<X, M extends Member> extends AbstractNewAnnotatedElement implements AnnotatedMember<X>
+{
+ private final AnnotatedType<X> declaringType;
+ private final M javaMember;
+
+ protected AbstractNewAnnotatedMember(AnnotatedType<X> declaringType, M member, Class<?> memberType, boolean readAnnotations)
+ {
+ super(memberType, readAnnotations);
+ this.declaringType = declaringType;
+ this.javaMember = member;
+ }
+
+ public AnnotatedType<X> getDeclaringType()
+ {
+ return declaringType;
+ }
+
+ public M getJavaMember()
+ {
+ return javaMember;
+ }
+
+ public boolean isStatic()
+ {
+ return Modifier.isStatic(javaMember.getModifiers());
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationStore.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationStore.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationStore.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,65 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class AnnotationStore
+{
+ HashMap<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
+ Set<Annotation> annotations = new HashSet<Annotation>();
+
+ public void clear()
+ {
+ annotationMap.clear();
+ annotations.clear();
+ }
+
+ public void addAnnotation(Annotation a)
+ {
+ annotations.add(a);
+ annotationMap.put(a.getClass(), a);
+ }
+
+ public void removeAnnotation(Class a)
+ {
+ Annotation an = annotationMap.get(a);
+ if (an != null)
+ {
+ annotations.remove(an);
+ annotationMap.remove(a);
+ }
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> type)
+ {
+ return (T) annotationMap.get(type);
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ return Collections.unmodifiableSet(annotations);
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> type)
+ {
+ return annotationMap.containsKey(type);
+ }
+
+ public void addAll(AnnotatedElement element)
+ {
+ for (Annotation a : element.getAnnotations())
+ {
+ addAnnotation(a);
+ }
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,21 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import java.lang.reflect.Constructor;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class NewAnnotatedConstructor<X> extends AbstractNewAnnotatedCallable<X, Constructor<X>>
+ implements AnnotatedConstructor<X>
+{
+
+ NewAnnotatedConstructor(NewAnnotatedType<X> type, Constructor<?> constructor, boolean readAnnotations)
+ {
+ super(type, (Constructor<X>) constructor, readAnnotations);
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,22 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import java.lang.reflect.Field;
+
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class NewAnnotatedField<X> extends AbstractNewAnnotatedMember<X, Field> implements
+ AnnotatedField<X>
+{
+
+ NewAnnotatedField(AnnotatedType<X> declaringType, Field field, boolean readAnnotations)
+ {
+ super(declaringType, field, field.getType(), readAnnotations);
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedMethod.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedMethod.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedMethod.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,25 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class NewAnnotatedMethod<X> extends AbstractNewAnnotatedCallable<X, Method> implements AnnotatedMethod<X>
+{
+ NewAnnotatedMethod(AnnotatedType<X> type, Method method, boolean readAnnotations)
+ {
+ super(type, method, readAnnotations);
+ int count = 0;
+ for (Class<?> c : method.getParameterTypes())
+ {
+ NewAnnotatedParameter<X> mp = new NewAnnotatedParameter<X>(this, c, count++, readAnnotations);
+ getParameters().add(mp);
+ }
+ }
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedMethod.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,34 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class NewAnnotatedParameter<X> extends AbstractNewAnnotatedElement implements AnnotatedParameter<X>
+{
+
+ private final int position;
+ private final AnnotatedCallable<X> declaringCallable;
+
+ NewAnnotatedParameter(AnnotatedCallable<X> declaringCallable, Class type, int position, boolean readAnnotations)
+ {
+ super(type, readAnnotations);
+ this.declaringCallable = declaringCallable;
+ this.position = position;
+ }
+
+ public AnnotatedCallable<X> getDeclaringCallable()
+ {
+ return declaringCallable;
+ }
+
+ public int getPosition()
+ {
+ return position;
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,112 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+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;
+
+/**
+ * AnnotatedType implementation for adding beans in the BeforeBeanDiscovery
+ * event
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class NewAnnotatedType<X> extends AbstractNewAnnotatedElement implements AnnotatedType<X>
+{
+
+ private final Set<NewAnnotatedConstructor<X>> constructors = new HashSet<NewAnnotatedConstructor<X>>();
+ private final Set<NewAnnotatedField<? super X>> fields = new HashSet<NewAnnotatedField<? super X>>();
+ private final Set<NewAnnotatedMethod<? super X>> methods = new HashSet<NewAnnotatedMethod<? super X>>();
+
+ // maps fields to the field objects
+ private final Map<Field, NewAnnotatedField<X>> fieldMap = new HashMap<Field, NewAnnotatedField<X>>();
+ // maps method names to the method objects
+ private final Map<Method, NewAnnotatedMethod<X>> methodMap = new HashMap<Method, NewAnnotatedMethod<X>>();
+
+ private final Class<X> javaClass;
+
+ public NewAnnotatedType(Class<X> clazz, boolean readAnnotations)
+ {
+ super(clazz, readAnnotations);
+ javaClass = clazz;
+ for (Constructor<?> c : clazz.getConstructors())
+ {
+ constructors.add(new NewAnnotatedConstructor<X>(this, c, readAnnotations));
+ }
+ for (Method m : clazz.getMethods())
+ {
+ NewAnnotatedMethod<X> met = new NewAnnotatedMethod<X>(this, m, readAnnotations);
+ methods.add(met);
+ methodMap.put(m, met);
+ }
+ for (Field f : clazz.getFields())
+ {
+ NewAnnotatedField<X> b = new NewAnnotatedField<X>(this, f, readAnnotations);
+ fields.add(b);
+ fieldMap.put(f, b);
+ }
+
+ }
+
+ /**
+ * clears all existing annotation data from a type
+ */
+ @Override
+ public void clearAllAnnotations()
+ {
+ super.clearAllAnnotations();
+ for (AbstractNewAnnotatedElement c : constructors)
+ {
+ c.clearAllAnnotations();
+ }
+ for (AbstractNewAnnotatedElement c : fields)
+ {
+ c.clearAllAnnotations();
+ }
+ for (AbstractNewAnnotatedElement c : methods)
+ {
+ c.clearAllAnnotations();
+ }
+ }
+
+ public Set<AnnotatedConstructor<X>> getConstructors()
+ {
+ return (Set) Collections.unmodifiableSet(constructors);
+ }
+
+ public Set<AnnotatedField<? super X>> getFields()
+ {
+ return (Set) Collections.unmodifiableSet(fields);
+ }
+
+ public Class<X> getJavaClass()
+ {
+ return javaClass;
+ }
+
+ public Set<AnnotatedMethod<? super X>> getMethods()
+ {
+ return (Set) Collections.unmodifiableSet(methods);
+ }
+
+ public NewAnnotatedField<X> getField(Field field)
+ {
+ return fieldMap.get(field);
+ }
+
+ public NewAnnotatedMethod<X> getMethod(Method m)
+ {
+ return methodMap.get(m);
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/TypeStore.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/TypeStore.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/TypeStore.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,45 @@
+package org.jboss.weld.extensions.util.annotated;
+
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class TypeStore
+{
+
+ final Set<Type> types = new HashSet<Type>();
+
+ public void add(Class<?> beanType)
+ {
+ Class<?> c = beanType;
+ do
+ {
+ types.add(c);
+ c = c.getSuperclass();
+ }
+ while (c != null);
+ for (Class<?> i : beanType.getInterfaces())
+ {
+ types.add(i);
+ }
+ }
+
+ public void addInterfaces(Class<?> beanType)
+ {
+ for (Class<?> i : beanType.getInterfaces())
+ {
+ types.add(i);
+ }
+ }
+
+ public Set<Type> getTypes()
+ {
+ return types;
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/annotated/TypeStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/AnnotationRedefinition.java (from rev 5183, extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java)
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/AnnotationRedefinition.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/AnnotationRedefinition.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,8 @@
+package org.jboss.weld.extensions.util.reannotated;
+
+import java.lang.annotation.Annotation;
+
+public interface AnnotationRedefinition<X extends Annotation>
+{
+ public X redefine(X annotation, Reannotated reannotated);
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/AnnotationRedefinition.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/Reannotated.java (from rev 5183, extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java)
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/Reannotated.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/Reannotated.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,158 @@
+package org.jboss.weld.extensions.util.reannotated;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Annotated;
+
+/**
+ * This class is not thread-safe, and the client must provide any synchronization needed
+ *
+ * @author Gavin King
+ * @author Pete Muir
+ *
+ *
+ */
+public abstract class Reannotated implements Annotated
+{
+
+ private static class AnnotationSet extends AbstractSet<Annotation>
+ {
+
+ List<Annotation> list = new ArrayList<Annotation>();
+
+ AnnotationSet(Map<Class<? extends Annotation>, Annotation> annotations, Set<Annotation> delegateAnnotations)
+ {
+ list.addAll(annotations.values());
+ for (Annotation ann : delegateAnnotations)
+ {
+ if (!annotations.containsKey(ann.annotationType()))
+ {
+ list.add(ann);
+ }
+ }
+ }
+
+ @Override
+ public Iterator<Annotation> iterator()
+ {
+ return list.iterator();
+ }
+
+ @Override
+ public int size()
+ {
+ return list.size();
+ }
+
+ }
+
+
+ protected abstract Annotated delegate();
+
+ private final Map<Class<? extends Annotation>, Annotation> annotations;
+
+ public Reannotated()
+ {
+ this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+ }
+
+ public <X extends Annotation> void redefine(Class<X> annotationType, AnnotationRedefinition<X> visitor)
+ {
+ if (isAnnotationPresent(annotationType))
+ {
+ X redefined = visitor.redefine(getAnnotation(annotationType), this);
+ if (redefined == null)
+ {
+ annotations.remove(annotationType);
+ }
+ else
+ {
+ annotations.put(annotationType, redefined);
+ }
+ }
+ }
+
+ /*
+ * public void undefine(Class<? extends Annotation> annotationType) {
+ * annotations.put(annotationType, null); }
+ */
+
+ public void define(Annotation ann)
+ {
+ annotations.put(ann.annotationType(), ann);
+ }
+
+ public boolean isAnnotationWithMetatypePresent(Class<? extends Annotation> metaannotationType)
+ {
+ for (Annotation ann : getAnnotations())
+ {
+ if (ann.annotationType().isAnnotationPresent(metaannotationType))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Set<Annotation> getAnnotationsWithMetatype(Class<? extends Annotation> metaannotationType)
+ {
+ Set<Annotation> set = new HashSet<Annotation>();
+ for (Annotation ann : getAnnotations())
+ {
+ if (ann.annotationType().isAnnotationPresent(metaannotationType))
+ {
+ set.add(ann);
+ }
+ }
+ return set;
+ }
+
+ public abstract Class<?> getJavaClass();
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ if (annotationType == null)
+ {
+ throw new IllegalArgumentException("annotationType argument must not be null");
+ }
+ Annotation ann = annotations.get(annotationType);
+ if (ann != null)
+ {
+ return annotationType.cast(ann);
+ }
+ else
+ {
+ return delegate().getAnnotation(annotationType);
+ }
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ return new AnnotationSet(annotations, delegate().getAnnotations());
+ }
+
+ public Type getBaseType()
+ {
+ return delegate().getBaseType();
+ }
+
+ public Set<Type> getTypeClosure()
+ {
+ return delegate().getTypeClosure();
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return annotations.containsKey(annotationType) || delegate().isAnnotationPresent(annotationType);
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/Reannotated.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedCallable.java (from rev 5183, extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java)
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedCallable.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedCallable.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,60 @@
+package org.jboss.weld.extensions.util.reannotated;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+/**
+ * This implementation of {@link AnnotatedCallable} is not threadsafe and any synchronization should be performed by the client
+ *
+ * @author Gavin King
+ * @author Pete Muir
+ *
+ * @param <X>
+ */
+public abstract class ReannotatedCallable<X> extends ReannotatedMember<X> implements AnnotatedCallable<X>
+{
+
+ private final List<ReannotatedParameter<X>> parameters = new ArrayList<ReannotatedParameter<X>>();
+
+ public ReannotatedCallable(ReannotatedType<X> declaringType, List<AnnotatedParameter<X>> params)
+ {
+ super(declaringType);
+ for (AnnotatedParameter<X> param : params)
+ {
+ parameters.add(new ReannotatedParameter<X>(param, this, param.getPosition()));
+ }
+ }
+
+ @Override
+ protected abstract AnnotatedCallable<X> delegate();
+
+ public List<AnnotatedParameter<X>> getParameters()
+ {
+ return new ArrayList<AnnotatedParameter<X>>(parameters);
+ }
+
+ public ReannotatedParameter<X> getParameter(int pos)
+ {
+ return parameters.get(pos);
+ }
+
+ public <Y extends Annotation> void redefineParameters(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ for (ReannotatedParameter<X> param : parameters)
+ {
+ param.redefine(annotationType, visitor);
+ }
+ }
+
+ @Override
+ public <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ redefine(annotationType, visitor);
+ redefineParameters(annotationType, visitor);
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedCallable.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedConstructor.java (from rev 5183, extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java)
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedConstructor.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedConstructor.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,43 @@
+package org.jboss.weld.extensions.util.reannotated;
+
+import java.lang.reflect.Constructor;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+
+/**
+ * This implementation of {@link AnnotatedConstructor} is not threadsafe and any synchronization must be performed by the client
+ *
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedConstructor<X> extends ReannotatedCallable<X> implements AnnotatedConstructor<X>
+{
+
+ private final AnnotatedConstructor<X> constructor;
+
+ ReannotatedConstructor(ReannotatedType<X> declaringType, AnnotatedConstructor<X> constructor)
+ {
+ super(declaringType, constructor.getParameters());
+ this.constructor = constructor;
+ }
+
+ @Override
+ protected AnnotatedConstructor<X> delegate()
+ {
+ return constructor;
+ }
+
+ @Override
+ public Constructor<X> getJavaMember()
+ {
+ return constructor.getJavaMember();
+ }
+
+ @Override
+ public boolean isStatic()
+ {
+ return constructor.isStatic();
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedConstructor.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedField.java (from rev 5183, extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java)
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedField.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedField.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,50 @@
+package org.jboss.weld.extensions.util.reannotated;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+import javax.enterprise.inject.spi.AnnotatedField;
+
+/**
+ * This implementation of {@link AnnotatedField} is not threadsafe and any synchronization must be performed by the client
+ *
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedField<X> extends ReannotatedMember<X> implements AnnotatedField<X>
+{
+
+ private final AnnotatedField<X> field;
+
+ ReannotatedField(ReannotatedType<X> declaringType, AnnotatedField<X> field)
+ {
+ super(declaringType);
+ this.field = field;
+ }
+
+ @Override
+ protected AnnotatedField<X> delegate()
+ {
+ return field;
+ }
+
+ @Override
+ public Field getJavaMember()
+ {
+ return field.getJavaMember();
+ }
+
+ @Override
+ public boolean isStatic()
+ {
+ return field.isStatic();
+ }
+
+ @Override
+ public <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ redefine(annotationType, visitor);
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedField.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMember.java (from rev 5183, extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java)
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMember.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMember.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,51 @@
+package org.jboss.weld.extensions.util.reannotated;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+
+import javax.enterprise.inject.spi.AnnotatedMember;
+
+/**
+ * This implementation of {@link AnnotatedMember} is not threadsafe and any synchronization must be performed by the client
+ *
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public abstract class ReannotatedMember<X> extends Reannotated implements AnnotatedMember<X>
+{
+
+ private final ReannotatedType<X> declaringType;
+
+ ReannotatedMember(ReannotatedType<X> declaringType)
+ {
+ this.declaringType = declaringType;
+ }
+
+ public ReannotatedType<X> getDeclaringType()
+ {
+ return declaringType;
+ }
+
+ @Override
+ protected abstract AnnotatedMember<X> delegate();
+
+ public Member getJavaMember()
+ {
+ return delegate().getJavaMember();
+ }
+
+ public boolean isStatic()
+ {
+ return delegate().isStatic();
+ }
+
+ @Override
+ public Class<?> getJavaClass()
+ {
+ return getJavaMember().getDeclaringClass();
+ }
+
+ public abstract <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor);
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMember.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMethod.java (from rev 5183, extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java)
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMethod.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMethod.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,43 @@
+package org.jboss.weld.extensions.util.reannotated;
+
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.AnnotatedMethod;
+
+/**
+ * This implementation of {@link AnnotatedMethod} is not threadsafe and any synchronization must be performed by the client
+ *
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedMethod<X> extends ReannotatedCallable<X> implements AnnotatedMethod<X>
+{
+
+ private final AnnotatedMethod<X> method;
+
+ ReannotatedMethod(ReannotatedType<X> declaringType, AnnotatedMethod<X> method)
+ {
+ super(declaringType, method.getParameters());
+ this.method = method;
+ }
+
+ @Override
+ protected AnnotatedMethod<X> delegate()
+ {
+ return method;
+ }
+
+ @Override
+ public Method getJavaMember()
+ {
+ return method.getJavaMember();
+ }
+
+ @Override
+ public boolean isStatic()
+ {
+ return method.isStatic();
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedMethod.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedParameter.java (from rev 5183, extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java)
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedParameter.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedParameter.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,60 @@
+package org.jboss.weld.extensions.util.reannotated;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+/**
+ * This implementation of {@link AnnotatedParameter} is not threadsafe and any synchronization must be performed by the client
+ *
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedParameter<X> extends Reannotated implements AnnotatedParameter<X>
+{
+
+ private final AnnotatedParameter<X> parameter;
+ private final ReannotatedCallable<X> callable;
+ private final int pos;
+
+ public ReannotatedParameter(AnnotatedParameter<X> parameter, ReannotatedCallable<X> callable, int pos)
+ {
+ this.parameter = parameter;
+ this.callable = callable;
+ this.pos = pos;
+ }
+
+ @Override
+ protected AnnotatedParameter<X> delegate()
+ {
+ return parameter;
+ }
+
+ public ReannotatedCallable<X> getDeclaringCallable()
+ {
+ return callable;
+ }
+
+ public int getPosition()
+ {
+ return pos;
+ }
+
+ @Override
+ public Class<?> getJavaClass()
+ {
+ Member member = callable.getJavaMember();
+ if (member instanceof Method)
+ {
+ return Method.class.cast(member).getParameterTypes()[pos];
+ }
+ else
+ {
+ return Constructor.class.cast(member).getParameterTypes()[pos];
+ }
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedParameter.java
___________________________________________________________________
Name: svn:eol-style
+ native
Copied: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedType.java (from rev 5183, extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java)
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedType.java (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedType.java 2009-12-02 12:08:07 UTC (rev 5190)
@@ -0,0 +1,239 @@
+package org.jboss.weld.extensions.util.reannotated;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ * This implementation of {@link AnnotatedType} is not threadsafe and any synchronization must be performed by the client
+ *
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedType<X> extends Reannotated implements AnnotatedType<X>
+{
+
+ private final AnnotatedType<X> type;
+ private final HashMap<Class<?>, ReannotatedType<?>> types;
+
+ private final Map<Member, ReannotatedField<? super X>> fields;
+ private final Map<Member, ReannotatedMethod<? super X>> methods;
+ private final Map<Member, ReannotatedConstructor<X>> constructors;
+
+ public ReannotatedType(AnnotatedType<X> type)
+ {
+ this(type, new HashMap<Class<?>, ReannotatedType<?>>());
+ }
+
+ public ReannotatedType(AnnotatedType<X> type, HashMap<Class<?>, ReannotatedType<?>> types)
+ {
+ this.type = type;
+ this.types = types;
+
+ fields = new HashMap<Member, ReannotatedField<? super X>>();
+ methods = new HashMap<Member, ReannotatedMethod<? super X>>();
+ constructors = new HashMap<Member, ReannotatedConstructor<X>>();
+
+ for (AnnotatedField<? super X> field : type.getFields())
+ {
+ addField(field);
+ }
+ for (AnnotatedMethod<? super X> method : type.getMethods())
+ {
+ addMethod(method);
+ }
+ for (AnnotatedConstructor<X> constructor : type.getConstructors())
+ {
+ addConstructor(constructor);
+ }
+ }
+
+ private <Y> ReannotatedType<Y> getDeclaringType(AnnotatedMember<Y> member)
+ {
+ return getSupertype(member.getDeclaringType());
+ }
+
+ @SuppressWarnings("unchecked")
+ private <Y> ReannotatedType<Y> getSupertype(AnnotatedType<Y> supertype)
+ {
+ Class<Y> memberJavaClass = supertype.getJavaClass();
+ if (memberJavaClass == type.getJavaClass())
+ {
+ return (ReannotatedType<Y>) this;
+ }
+ else
+ {
+ ReannotatedType<Y> result = (ReannotatedType<Y>) types.get(memberJavaClass);
+ if (result == null)
+ {
+ result = new ReannotatedType<Y>(supertype, types);
+ types.put(memberJavaClass, result);
+ }
+ return result;
+ }
+ }
+
+ private void addConstructor(AnnotatedConstructor<X> constructor)
+ {
+ constructors.put(constructor.getJavaMember(), new ReannotatedConstructor<X>(this, constructor));
+ }
+
+ @SuppressWarnings("unchecked")
+ private void addMethod(AnnotatedMethod<? super X> method)
+ {
+ Class<? super X> methodJavaClass = method.getDeclaringType().getJavaClass();
+ if (methodJavaClass.isAssignableFrom(type.getJavaClass()))
+ {
+ final ReannotatedMethod<? super X> reannotated;
+ if (methodJavaClass == type.getJavaClass())
+ {
+ reannotated = new ReannotatedMethod(getDeclaringType(method), method);
+ }
+ else
+ {
+ reannotated = getInheritedMethod(method);
+ }
+ methods.put(method.getJavaMember(), reannotated);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void addField(AnnotatedField<? super X> field)
+ {
+ Class<? super X> fieldJavaClass = field.getDeclaringType().getJavaClass();
+ final ReannotatedField<? super X> reannotated;
+ if (fieldJavaClass.isAssignableFrom(type.getJavaClass()))
+ {
+ if (fieldJavaClass == type.getJavaClass())
+ {
+ reannotated = new ReannotatedField(getDeclaringType(field), field);
+ }
+ else
+ {
+ reannotated = getInheritedField(field);
+ }
+ fields.put(field.getJavaMember(), reannotated);
+ }
+ }
+
+ private <Y> ReannotatedField<? super Y> getInheritedField(AnnotatedField<Y> field)
+ {
+ return getDeclaringType(field).getField(field.getJavaMember());
+ }
+
+ private <Y> ReannotatedMethod<? super Y> getInheritedMethod(AnnotatedMethod<Y> method)
+ {
+ return getDeclaringType(method).getMethod(method.getJavaMember());
+ }
+
+ @Override
+ protected AnnotatedType<X> delegate()
+ {
+ return type;
+ }
+
+ public Set<AnnotatedConstructor<X>> getConstructors()
+ {
+ return new HashSet<AnnotatedConstructor<X>>(constructors.values());
+ }
+
+ public Set<AnnotatedMethod<? super X>> getMethods()
+ {
+ return new HashSet<AnnotatedMethod<? super X>>(methods.values());
+ }
+
+ public Set<AnnotatedField<? super X>> getFields()
+ {
+ return new HashSet<AnnotatedField<? super X>>(fields.values());
+ }
+
+ public ReannotatedConstructor<X> getConstructor(Constructor<X> constructor)
+ {
+ return constructors.get(constructor);
+ }
+
+ public ReannotatedMethod<? super X> getMethod(Method constructor)
+ {
+ return methods.get(constructor);
+ }
+
+ public ReannotatedField<? super X> getField(Field field)
+ {
+ return fields.get(field);
+ }
+
+ public <Y extends Annotation> void redefineConstructors(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ for (ReannotatedConstructor<X> constructor : constructors.values())
+ {
+ constructor.redefine(annotationType, visitor);
+ }
+ }
+
+ public <Y extends Annotation> void redefineMethods(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ for (ReannotatedMethod<? super X> method : methods.values())
+ {
+ method.redefine(annotationType, visitor);
+ }
+ }
+
+ public <Y extends Annotation> void redefineFields(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ for (ReannotatedField<? super X> field : fields.values())
+ {
+ field.redefine(annotationType, visitor);
+ }
+ }
+
+ public <Y extends Annotation> void redefineMembers(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ redefineFields(annotationType, visitor);
+ redefineMethods(annotationType, visitor);
+ redefineConstructors(annotationType, visitor);
+ }
+
+ public <Y extends Annotation> void redefineMembersAndParameters(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ redefineMembers(annotationType, visitor);
+ redefineParameters(annotationType, visitor);
+ }
+
+ public <Y extends Annotation> void redefineParameters(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ for (ReannotatedMethod<? super X> method : methods.values())
+ {
+ method.redefineParameters(annotationType, visitor);
+ }
+ for (ReannotatedConstructor<X> constructor : constructors.values())
+ {
+ constructor.redefineParameters(annotationType, visitor);
+ }
+ }
+
+ public <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+ {
+ redefine(annotationType, visitor);
+ redefineMembersAndParameters(annotationType, visitor);
+ }
+
+ @Override
+ public Class<X> getJavaClass()
+ {
+ return type.getJavaClass();
+ }
+
+}
Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/ReannotatedType.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the weld-commits
mailing list