geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1086146 - in /geronimo/xbean/trunk/xbean-finder/src: main/java/org/apache/xbean/finder/ test/java/org/apache/xbean/finder/
Date Mon, 28 Mar 2011 08:04:08 GMT
Author: dblevins
Date: Mon Mar 28 08:04:08 2011
New Revision: 1086146

URL: http://svn.apache.org/viewvc?rev=1086146&view=rev
Log:
XBEAN-165: Meta Annotation Support
Promoted the inner classes and further reworked the unrolling of loaded classes to not be tied to ASM data
Now possible to individually construct the wrappers
General tweaking of the API names/types

Added:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Annotated.java   (contents, props changed)
      - copied, changed from r1085842, geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedTarget.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java   (contents, props changed)
      - copied, changed from r1085842, geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedTarget.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedClass.java   (with props)
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedConstructor.java   (with props)
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedField.java   (with props)
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedMethod.java   (with props)
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedObject.java   (with props)
Removed:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedTarget.java
Modified:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedMember.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IAnnotationFinder.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedFieldTest.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodTest.java

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java?rev=1086146&r1=1086145&r2=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java Mon Mar 28 08:04:08 2011
@@ -213,36 +213,11 @@ public abstract class AbstractFinder imp
     }
 
     @Override
-    public List<AnnotatedTarget<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation) {
+    public List<Annotated<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation) {
         List<Class<?>> classes = findAnnotatedClasses(annotation);
-        List<AnnotatedTarget<Class<?>>> list = new ArrayList<AnnotatedTarget<Class<?>>>();
+        List<Annotated<Class<?>>> list = new ArrayList<Annotated<Class<?>>>();
         for (final Class<?> clazz : classes) {
-            list.add(new AnnotatedTarget<Class<?>>(){
-                @Override
-                public Class<?> getTarget() {
-                    return clazz;
-                }
-
-                @Override
-                public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
-                    return getTarget().isAnnotationPresent(annotationClass);
-                }
-
-                @Override
-                public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
-                    return getTarget().getAnnotation(annotationClass);
-                }
-
-                @Override
-                public Annotation[] getAnnotations() {
-                    return getTarget().getAnnotations();
-                }
-
-                @Override
-                public Annotation[] getDeclaredAnnotations() {
-                    return getTarget().getDeclaredAnnotations();
-                }
-            });
+            list.add(new MetaAnnotatedClass(clazz));
         }
         return list;
     }
@@ -335,106 +310,11 @@ public abstract class AbstractFinder imp
     }
 
     @Override
-    public List<AnnotatedMethod<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation) {
+    public List<Annotated<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation) {
         List<Method> methods = findAnnotatedMethods(annotation);
-        List<AnnotatedMethod<Method>> list = new ArrayList<AnnotatedMethod<Method>>();
+        List<Annotated<Method>> list = new ArrayList<Annotated<Method>>();
         for (final Method method : methods) {
-            list.add(new AnnotatedMethod<Method>(){
-                @Override
-                public Method getTarget() {
-                    return method;
-                }
-
-                @Override
-                public Class<?> getDeclaringClass() {
-                    return getTarget().getDeclaringClass();
-                }
-
-                @Override
-                public String getName() {
-                    return getTarget().getName();
-                }
-
-                @Override
-                public int getModifiers() {
-                    return getTarget().getModifiers();
-                }
-
-                @Override
-                public Class<?>[] getParameterTypes() {
-                    return getTarget().getParameterTypes();
-                }
-
-                @Override
-                public Type[] getGenericParameterTypes() {
-                    return getTarget().getGenericParameterTypes();
-                }
-
-                @Override
-                public Class<?>[] getExceptionTypes() {
-                    return getTarget().getExceptionTypes();
-                }
-
-                @Override
-                public Type[] getGenericExceptionTypes() {
-                    return getTarget().getGenericExceptionTypes();
-                }
-
-                @Override
-                public boolean equals(Object obj) {
-                    return getTarget().equals(obj);
-                }
-
-                @Override
-                public int hashCode() {
-                    return getTarget().hashCode();
-                }
-
-                @Override
-                public String toString() {
-                    return getTarget().toString();
-                }
-
-                @Override
-                public String toGenericString() {
-                    return getTarget().toGenericString();
-                }
-
-                @Override
-                public boolean isVarArgs() {
-                    return getTarget().isVarArgs();
-                }
-
-                @Override
-                public boolean isSynthetic() {
-                    return getTarget().isSynthetic();
-                }
-
-                @Override
-                public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
-                    return getTarget().getAnnotation(annotationClass);
-                }
-
-                @Override
-                public Annotation[] getDeclaredAnnotations() {
-                    return getTarget().getDeclaredAnnotations();
-                }
-
-                @Override
-                public Annotation[][] getParameterAnnotations() {
-                    return getTarget().getParameterAnnotations();
-                }
-
-                @Override
-                public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
-                    return getTarget().isAnnotationPresent(annotationClass);
-                }
-
-                @Override
-                public Annotation[] getAnnotations() {
-                    return getTarget().getAnnotations();
-                }
-            });
+            list.add(new MetaAnnotatedMethod(method));
         }
         return list;
     }
@@ -498,73 +378,11 @@ public abstract class AbstractFinder imp
     }
 
     @Override
-    public List<AnnotatedMember<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation) {
+    public List<Annotated<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation) {
         List<Field> fields = findAnnotatedFields(annotation);
-        List<AnnotatedMember<Field>> list = new ArrayList<AnnotatedMember<Field>>();
+        List<Annotated<Field>> list = new ArrayList<Annotated<Field>>();
         for (final Field field : fields) {
-            list.add(new AnnotatedMember<Field>(){
-                @Override
-                public Field getTarget() {
-                    return field;
-                }
-
-                @Override
-                public Class<?> getDeclaringClass() {
-                    return getTarget().getDeclaringClass();
-                }
-
-                @Override
-                public String getName() {
-                    return getTarget().getName();
-                }
-
-                @Override
-                public int getModifiers() {
-                    return getTarget().getModifiers();
-                }
-
-                @Override
-                public boolean isSynthetic() {
-                    return getTarget().isSynthetic();
-                }
-
-                @Override
-                public boolean equals(Object obj) {
-                    return getTarget().equals(obj);
-                }
-
-                @Override
-                public int hashCode() {
-                    return getTarget().hashCode();
-                }
-
-                @Override
-                public String toString() {
-                    return getTarget().toString();
-                }
-
-                @Override
-                public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
-                    return getTarget().getAnnotation(annotationClass);
-                }
-
-                @Override
-                public Annotation[] getDeclaredAnnotations() {
-                    return getTarget().getDeclaredAnnotations();
-                }
-
-                @Override
-                public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
-                    return getTarget().isAnnotationPresent(annotationClass);
-                }
-
-                @Override
-                public Annotation[] getAnnotations() {
-                    return getTarget().getAnnotations();
-                }
-
-                
-            });
+            list.add(new MetaAnnotatedField(field));
         }
 
         return list;

Copied: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Annotated.java (from r1085842, geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedTarget.java)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Annotated.java?p2=geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Annotated.java&p1=geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedTarget.java&r1=1085842&r2=1086146&rev=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedTarget.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Annotated.java Mon Mar 28 08:04:08 2011
@@ -18,12 +18,11 @@ package org.apache.xbean.finder;
 
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.GenericDeclaration;
+import java.util.Collection;
 
 /**
  * @version $Rev$ $Date$
  */
-public interface AnnotatedTarget<T> extends AnnotatedElement {
-
-    T getTarget();
-
+public interface Annotated<T> extends AnnotatedElement {
+    T get();
 }

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Annotated.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedMember.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedMember.java?rev=1086146&r1=1086145&r2=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedMember.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedMember.java Mon Mar 28 08:04:08 2011
@@ -16,12 +16,11 @@
  */
 package org.apache.xbean.finder;
 
-import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Member;
 
 /**
  * @version $Rev$ $Date$
  */
-public interface AnnotatedMember<T> extends AnnotatedTarget<T>, Member {
+public interface AnnotatedMember<T> extends Annotated<T>, Member {
 
 }

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java?rev=1086146&r1=1086145&r2=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java Mon Mar 28 08:04:08 2011
@@ -36,16 +36,12 @@ import org.objectweb.asm.signature.Signa
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -56,7 +52,7 @@ import java.util.Set;
 /**
  * ClassFinder searches the classpath of the specified classloader for
  * packages, classes, constructors, methods, or fields with specific annotations.
- *
+ * <p/>
  * For security reasons ASM is used to find the annotations.  Classes are not
  * loaded unless they match the requirements of a called findAnnotated* method.
  * Once loaded, these classes are cached.
@@ -168,7 +164,7 @@ public class AnnotationFinder implements
         for (AnnotationInfo info : classInfo.getAnnotations()) {
             if (info.getName().equals(name)) return true;
         }
-        
+
         return true;
     }
 
@@ -314,14 +310,14 @@ public class AnnotationFinder implements
     }
 
     @Override
-    public List<AnnotatedTarget<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation) {
+    public List<Annotated<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
         Set<Class<?>> classes = findMetaAnnotatedClasses(annotation, new HashSet<Class<?>>());
 
-        List<AnnotatedTarget<Class<?>>> list = new ArrayList<AnnotatedTarget<Class<?>>>();
+        List<Annotated<Class<?>>> list = new ArrayList<Annotated<Class<?>>>();
 
         for (Class<?> clazz : classes) {
-            list.add(new MetaAnnotatedClass(clazz, unrollClass(clazz)));
+            list.add(new MetaAnnotatedClass(clazz));
         }
 
         return list;
@@ -444,15 +440,15 @@ public class AnnotationFinder implements
     }
 
     @Override
-    public List<AnnotatedMethod<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation) {
+    public List<Annotated<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
 
         Set<Method> methods = findMetaAnnotatedMethods(annotation, new HashSet<Method>(), new HashSet<String>());
 
-        List<AnnotatedMethod<Method>> targets = new ArrayList<AnnotatedMethod<Method>>();
+        List<Annotated<Method>> targets = new ArrayList<Annotated<Method>>();
 
         for (Method method : methods) {
-            targets.add(new MetaAnnotatedMethod(method, unrollMethod(method)));
+            targets.add(new MetaAnnotatedMethod(method));
         }
 
         return targets;
@@ -504,15 +500,15 @@ public class AnnotationFinder implements
     }
 
     @Override
-    public List<AnnotatedMember<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation) {
+    public List<Annotated<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
 
         Set<Field> fields = findMetaAnnotatedFields(annotation, new HashSet<Field>(), new HashSet<String>());
 
-        List<AnnotatedMember<Field>> targets = new ArrayList<AnnotatedMember<Field>>();
+        List<Annotated<Field>> targets = new ArrayList<Annotated<Field>>();
 
         for (Field field : fields) {
-            targets.add(new MetaAnnotatedField(field, unrollField(field)));
+            targets.add(new MetaAnnotatedField(field));
         }
 
         return targets;
@@ -1175,7 +1171,7 @@ public class AnnotationFinder implements
         public String toString() {
             return declaringClass + "#" + name;
         }
-        
+
         @Override
         public String getMetaAnnotationName() {
             return declaringClass.getMetaAnnotationName();
@@ -1479,291 +1475,4 @@ public class AnnotationFinder implements
 
     }
 
-    private void unroll(Class<? extends Annotation> clazz, int depth, Map<Class<? extends Annotation>, MetaAnnotation<?>> found) {
-        if (!isMetaAnnotation(clazz)) return;
-
-        for (Annotation annotation : getDeclaredMetaAnnotations(clazz)) {
-            Class<? extends Annotation> type = annotation.annotationType();
-
-            MetaAnnotation existing = found.get(type);
-
-            if (existing != null) {
-
-                if (existing.getDepth() > depth) {
-
-                    // OVERWRITE
-
-                    found.put(type, new MetaAnnotation(annotation, depth, clazz));
-
-                    unroll(type, depth + 1, found);
-
-                } else if (existing.getDepth() < depth) {
-
-                    // IGNORE
-
-                    // ignore, what we have already is higher priority
-
-                } else {
-
-                    // CONFLICT
-
-                    // They are the same depth and therefore conflicting
-                    existing.getConflicts().add(new MetaAnnotation(annotation, depth, clazz));
-
-                }
-
-            } else {
-
-                // NEW
-
-                found.put(type, new MetaAnnotation(annotation, depth, clazz));
-
-                unroll(type, depth + 1, found);
-
-            }
-        }
-    }
-
-    private Collection<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> clazz) {
-
-        Map<Class, Annotation> map = new HashMap<Class, Annotation>();
-
-        // pull in the annotations declared on this annotation
-
-        for (Annotation annotation : clazz.getDeclaredAnnotations()) {
-            map.put(annotation.annotationType(), annotation);
-        }
-
-        // pull in the meta-annotations from infos annotated with this
-        // these include special inner-classes that serve as adapters
-        
-        for (Info info : annotated.get(clazz.getName())) {
-
-            if (!clazz.getName().equals(info.getMetaAnnotationName())) continue;
-
-            for (Annotation annotation : info.getDeclaredAnnotations()) {
-                map.put(annotation.annotationType(), annotation);
-            }
-
-        }
-
-        map.remove(Target.class);
-        map.remove(Retention.class);
-        map.remove(Documented.class);
-        map.remove(clazz);
-
-        for (Class<? extends Annotation> metaroot : metaroots) {
-            map.remove(metaroot);
-        }
-
-        return map.values();
-    }
-
-    private boolean isMetaAnnotation(Class<? extends Annotation> clazz) {
-        if (!clazz.isAnnotation()) return false;
-
-        for (Annotation annotation : clazz.getDeclaredAnnotations()) {
-            if (metaroots.contains(annotation.annotationType())) return true;
-        }
-
-        return false;
-    }
-
-    private Map<Class<? extends Annotation>, MetaAnnotation<?>> unrollClass(Class<?> clazz) {
-        Map<Class<? extends Annotation>, MetaAnnotation<?>> map = new HashMap<Class<? extends Annotation>, MetaAnnotation<?>>();
-        for (Annotation annotation : clazz.getDeclaredAnnotations()) {
-            map.put(annotation.annotationType(), new MetaAnnotation(annotation, 0, clazz));
-            unroll(annotation.annotationType(), 1, map);
-        }
-        return map;
-    }
-
-    private Map<Class<? extends Annotation>, MetaAnnotation<?>> unrollField(Field target) {
-        Map<Class<? extends Annotation>, MetaAnnotation<?>> map = new HashMap<Class<? extends Annotation>, MetaAnnotation<?>>();
-        for (Annotation annotation : target.getDeclaredAnnotations()) {
-            map.put(annotation.annotationType(), new MetaAnnotation(annotation, 0, target.getDeclaringClass()));
-            unroll(annotation.annotationType(), 1, map);
-        }
-        return map;
-    }
-
-    private Map<Class<? extends Annotation>, MetaAnnotation<?>> unrollMethod(Method target) {
-        Map<Class<? extends Annotation>, MetaAnnotation<?>> map = new HashMap<Class<? extends Annotation>, MetaAnnotation<?>>();
-        for (Annotation annotation : target.getDeclaredAnnotations()) {
-            map.put(annotation.annotationType(), new MetaAnnotation(annotation, 0, target.getDeclaringClass()));
-            unroll(annotation.annotationType(), 1, map);
-        }
-        return map;
-    }
-
-    private static abstract class MetaAnnotatedTarget<T> implements AnnotatedTarget<T>, MetaAnnotated {
-        protected final Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations = new HashMap<Class<? extends Annotation>, MetaAnnotation<?>>();
-        protected final T target;
-
-        public MetaAnnotatedTarget(T target, Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations) {
-            this.target = target;
-            this.annotations.putAll(annotations);
-        }
-
-        @Override
-        public T getTarget() {
-            return target;
-        }
-
-        @Override
-        public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
-            return annotations.containsKey(annotationClass);
-        }
-
-        @Override
-        public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
-            MetaAnnotation<T> annotation = (MetaAnnotation<T>) annotations.get(annotationClass);
-            return (annotation == null) ? null : annotation.getAnnotation();
-        }
-
-        @Override
-        public Annotation[] getAnnotations() {
-            Annotation[] annotations = new Annotation[this.annotations.size()];
-
-            int i = 0;
-            for (MetaAnnotation annotation : this.annotations.values()) {
-                annotations[i++] = annotation.getAnnotation();
-            }
-
-            return annotations;
-        }
-
-        @Override
-        public Collection<MetaAnnotation<?>> getMetaAnnotations() {
-            return Collections.unmodifiableCollection(annotations.values());
-        }
-    }
-
-    private static class MetaAnnotatedClass extends MetaAnnotatedTarget<Class<?>> {
-
-        private MetaAnnotatedClass(Class<?> clazz, Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations) {
-            super(clazz, annotations);
-        }
-
-        @Override
-        public Annotation[] getDeclaredAnnotations() {
-            return getTarget().getDeclaredAnnotations();
-        }
-    }
-
-
-    private static class MetaAnnotatedField extends MetaAnnotatedTarget<Field> implements AnnotatedMember<Field>{
-
-        private MetaAnnotatedField(Field target, Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations) {
-            super(target, annotations);
-        }
-
-        @Override
-        public Annotation[] getDeclaredAnnotations() {
-            return getTarget().getDeclaredAnnotations();
-        }
-
-        @Override
-        public Class<?> getDeclaringClass() {
-            return getTarget().getDeclaringClass();
-        }
-
-        @Override
-        public String getName() {
-            return getTarget().getName();
-        }
-
-        @Override
-        public int getModifiers() {
-            return getTarget().getModifiers();
-        }
-
-        @Override
-        public boolean isSynthetic() {
-            return getTarget().isSynthetic();
-        }
-    }
-
-    private static class MetaAnnotatedMethod extends MetaAnnotatedTarget<Method> implements AnnotatedMethod<Method> {
-
-        private MetaAnnotatedMethod(Method target, Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations) {
-            super(target, annotations);
-        }
-
-        @Override
-        public Annotation[] getDeclaredAnnotations() {
-            return getTarget().getDeclaredAnnotations();
-        }
-
-        @Override
-        public Annotation[][] getParameterAnnotations() {
-            return getTarget().getParameterAnnotations();
-        }
-
-        @Override
-        public Class<?> getDeclaringClass() {
-            return getTarget().getDeclaringClass();
-        }
-
-        @Override
-        public String getName() {
-            return getTarget().getName();
-        }
-
-        @Override
-        public int getModifiers() {
-            return getTarget().getModifiers();
-        }
-
-        @Override
-        public Class<?>[] getParameterTypes() {
-            return getTarget().getParameterTypes();
-        }
-
-        @Override
-        public java.lang.reflect.Type[] getGenericParameterTypes() {
-            return getTarget().getGenericParameterTypes();
-        }
-
-        @Override
-        public Class<?>[] getExceptionTypes() {
-            return getTarget().getExceptionTypes();
-        }
-
-        @Override
-        public java.lang.reflect.Type[] getGenericExceptionTypes() {
-            return getTarget().getGenericExceptionTypes();
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            return getTarget().equals(obj);
-        }
-
-        @Override
-        public int hashCode() {
-            return getTarget().hashCode();
-        }
-
-        @Override
-        public String toString() {
-            return getTarget().toString();
-        }
-
-        @Override
-        public String toGenericString() {
-            return getTarget().toGenericString();
-        }
-
-        @Override
-        public boolean isVarArgs() {
-            return getTarget().isVarArgs();
-        }
-
-        @Override
-        public boolean isSynthetic() {
-            return getTarget().isSynthetic();
-        }
-
-    }
 }
\ No newline at end of file

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IAnnotationFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IAnnotationFinder.java?rev=1086146&r1=1086145&r2=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IAnnotationFinder.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IAnnotationFinder.java Mon Mar 28 08:04:08 2011
@@ -49,9 +49,9 @@ public interface IAnnotationFinder {
 
     <T> List<Class<? extends T>> findImplementations(Class<T> clazz);
 
-    List<AnnotatedMethod<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation);
+    List<Annotated<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation);
 
-    List<AnnotatedMember<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation);
+    List<Annotated<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation);
 
-    List<AnnotatedTarget<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation);
+    List<Annotated<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation);
 }

Copied: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java (from r1085842, geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedTarget.java)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java?p2=geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java&p1=geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedTarget.java&r1=1085842&r2=1086146&rev=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotatedTarget.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java Mon Mar 28 08:04:08 2011
@@ -16,14 +16,13 @@
  */
 package org.apache.xbean.finder;
 
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.GenericDeclaration;
+import java.util.Collection;
 
 /**
  * @version $Rev$ $Date$
  */
-public interface AnnotatedTarget<T> extends AnnotatedElement {
+public interface MetaAnnotated<T> extends Annotated<T> {
 
-    T getTarget();
+    public Collection<MetaAnnotation<?>> getMetaAnnotations();
 
 }

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedClass.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedClass.java?rev=1086146&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedClass.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedClass.java Mon Mar 28 08:04:08 2011
@@ -0,0 +1,299 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.finder;
+
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+/**
+* @version $Rev$ $Date$
+*/
+public class MetaAnnotatedClass<T> extends MetaAnnotatedObject<Class<T>> {
+
+    public MetaAnnotatedClass(Class<T> clazz) {
+        super(clazz, unroll(clazz, clazz));
+    }
+
+    @Override
+    public Annotation[] getDeclaredAnnotations() {
+        return target.getDeclaredAnnotations();
+    }
+
+    public MetaAnnotatedClass<?> forName(String className) throws ClassNotFoundException {
+        return to(target.forName(className));
+    }
+
+    private MetaAnnotatedClass<?> to(Class<?> clazz) {
+        return new MetaAnnotatedClass(clazz);
+    }
+
+    public MetaAnnotatedClass<?> forName(String name, boolean initialize, ClassLoader loader) throws ClassNotFoundException {
+        return to(target.forName(name, initialize, loader));
+    }
+
+    public T newInstance() throws InstantiationException, IllegalAccessException {
+        return target.newInstance();
+    }
+
+    public boolean isInstance(Object obj) {
+        return target.isInstance(obj);
+    }
+
+    public boolean isAssignableFrom(Class<?> cls) {
+        return target.isAssignableFrom(cls);
+    }
+
+    public boolean isInterface() {
+        return target.isInterface();
+    }
+
+    public boolean isArray() {
+        return target.isArray();
+    }
+
+    public boolean isPrimitive() {
+        return target.isPrimitive();
+    }
+
+    public boolean isAnnotation() {
+        return target.isAnnotation();
+    }
+
+    public boolean isSynthetic() {
+        return target.isSynthetic();
+    }
+
+    public String getName() {
+        return target.getName();
+    }
+
+    public ClassLoader getClassLoader() {
+        return target.getClassLoader();
+    }
+
+    public TypeVariable<Class<T>>[] getTypeParameters() {
+        return target.getTypeParameters();
+    }
+
+    public MetaAnnotatedClass<? super T> getSuperclass() {
+        return new MetaAnnotatedClass(target.getSuperclass());
+    }
+
+    public Type getGenericSuperclass() {
+        return target.getGenericSuperclass();
+    }
+
+    public Package getPackage() {
+        return target.getPackage();
+    }
+
+    public MetaAnnotatedClass<?>[] getInterfaces() {
+        return to(target.getInterfaces());
+    }
+
+    public Type[] getGenericInterfaces() {
+        return target.getGenericInterfaces();
+    }
+
+    public MetaAnnotatedClass<?> getComponentType() {
+        return to(target.getComponentType());
+    }
+
+    public int getModifiers() {
+        return target.getModifiers();
+    }
+
+    public Object[] getSigners() {
+        return target.getSigners();
+    }
+
+    public MetaAnnotatedMethod getEnclosingMethod() {
+        return to(target.getEnclosingMethod());
+    }
+
+    public MetaAnnotatedConstructor<?> getEnclosingConstructor() {
+        return to(target.getEnclosingConstructor());
+    }
+
+    public MetaAnnotatedClass<?> getDeclaringClass() {
+        return to(target.getDeclaringClass());
+    }
+
+    public MetaAnnotatedClass<?> getEnclosingClass() {
+        return to(target.getEnclosingClass());
+    }
+
+    public String getSimpleName() {
+        return target.getSimpleName();
+    }
+
+    public String getCanonicalName() {
+        return target.getCanonicalName();
+    }
+
+    public boolean isAnonymousClass() {
+        return target.isAnonymousClass();
+    }
+
+    public boolean isLocalClass() {
+        return target.isLocalClass();
+    }
+
+    public boolean isMemberClass() {
+        return target.isMemberClass();
+    }
+
+    public MetaAnnotatedClass<?>[] getClasses() {
+        return to(target.getClasses());
+    }
+
+    public MetaAnnotatedField[] getFields() throws SecurityException {
+        return to(target.getFields());
+    }
+
+    public MetaAnnotatedMethod[] getMethods() throws SecurityException {
+        return to(target.getMethods());
+    }
+
+    public MetaAnnotatedConstructor<?>[] getConstructors() throws SecurityException {
+        return to(target.getConstructors());
+    }
+
+    public MetaAnnotatedField getField(String name) throws NoSuchFieldException, SecurityException {
+        return to(target.getField(name));
+    }
+
+    public MetaAnnotatedMethod getMethod(String name, Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException {
+        return to(target.getMethod(name, parameterTypes));
+    }
+
+    public MetaAnnotatedConstructor<T> getConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException {
+        return new MetaAnnotatedConstructor(target.getConstructor(parameterTypes));
+    }
+
+    public MetaAnnotatedClass<?>[] getDeclaredClasses() throws SecurityException {
+        return to(target.getDeclaredClasses());
+    }
+
+    public MetaAnnotatedField[] getDeclaredFields() throws SecurityException {
+        return to(target.getDeclaredFields());
+    }
+
+    public MetaAnnotatedMethod[] getDeclaredMethods() throws SecurityException {
+        return to(target.getDeclaredMethods());
+    }
+
+    public MetaAnnotatedConstructor<?>[] getDeclaredConstructors() throws SecurityException {
+        return to(target.getDeclaredConstructors());
+    }
+
+    public MetaAnnotatedField getDeclaredField(String name) throws NoSuchFieldException, SecurityException {
+        return to(target.getDeclaredField(name));
+    }
+
+    public MetaAnnotatedMethod getDeclaredMethod(String name, Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException {
+        return to(target.getDeclaredMethod(name, parameterTypes));
+    }
+
+    public MetaAnnotatedConstructor<T> getDeclaredConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException {
+        return new MetaAnnotatedConstructor(target.getDeclaredConstructor(parameterTypes));
+    }
+
+    public InputStream getResourceAsStream(String name) {
+        return target.getResourceAsStream(name);
+    }
+
+    public URL getResource(String name) {
+        return target.getResource(name);
+    }
+
+    public ProtectionDomain getProtectionDomain() {
+        return target.getProtectionDomain();
+    }
+
+    public boolean desiredAssertionStatus() {
+        return target.desiredAssertionStatus();
+    }
+
+    public boolean isEnum() {
+        return target.isEnum();
+    }
+
+    public T[] getEnumConstants() {
+        return target.getEnumConstants();
+    }
+
+    public T cast(Object obj) {
+        return target.cast(obj);
+    }
+
+    public <U> Class<? extends U> asSubclass(Class<U> clazz) {
+        return target.asSubclass(clazz);
+    }
+
+    private MetaAnnotatedMethod[] to(Method[] a) {
+        MetaAnnotatedMethod[] b = new MetaAnnotatedMethod[a.length];
+        for (int i = 0; i < a.length; i++) {
+            b[i] = new MetaAnnotatedMethod(a[i]);
+        }
+        return b;
+    } 
+
+    private MetaAnnotatedMethod to(Method method) {
+        return new MetaAnnotatedMethod(method);
+    }
+    
+    private MetaAnnotatedConstructor<?>[] to(Constructor<?>[] a) {
+        MetaAnnotatedConstructor<?>[] b = new MetaAnnotatedConstructor[a.length];
+        for (int i = 0; i < a.length; i++) {
+            b[i] = new MetaAnnotatedConstructor(a[i]);
+        }
+        return b;
+    } 
+
+    private MetaAnnotatedConstructor<?> to(Constructor<?> constructor) {
+        return new MetaAnnotatedConstructor(constructor);
+    }
+
+    private MetaAnnotatedClass<?>[] to(Class<?>[] a) {
+        MetaAnnotatedClass<?>[] b = new MetaAnnotatedClass[a.length];
+        for (int i = 0; i < a.length; i++) {
+            b[i] = to(a[i]);
+        }
+        return b;
+    } 
+
+    private MetaAnnotatedField[] to(Field[] a) {
+        MetaAnnotatedField[] b = new MetaAnnotatedField[a.length];
+        for (int i = 0; i < a.length; i++) {
+            b[i] = new MetaAnnotatedField(a[i]);
+        }
+        return b;
+    } 
+
+    private MetaAnnotatedField to(Field field) {
+        return new MetaAnnotatedField(field);
+    }
+    
+}

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedClass.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedConstructor.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedConstructor.java?rev=1086146&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedConstructor.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedConstructor.java Mon Mar 28 08:04:08 2011
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.finder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MetaAnnotatedConstructor<T> extends MetaAnnotatedObject<Constructor<T>> implements AnnotatedMethod<Constructor<T>> {
+
+    public MetaAnnotatedConstructor(Constructor<T> target) {
+        super(target, unroll(target.getDeclaringClass(), target));
+    }
+
+    @Override
+    public Annotation[] getDeclaredAnnotations() {
+        return get().getDeclaredAnnotations();
+    }
+
+    @Override
+    public Annotation[][] getParameterAnnotations() {
+        return get().getParameterAnnotations();
+    }
+
+    @Override
+    public Class<?> getDeclaringClass() {
+        return get().getDeclaringClass();
+    }
+
+    @Override
+    public String getName() {
+        return get().getName();
+    }
+
+    @Override
+    public int getModifiers() {
+        return get().getModifiers();
+    }
+
+    @Override
+    public Class<?>[] getParameterTypes() {
+        return get().getParameterTypes();
+    }
+
+    @Override
+    public java.lang.reflect.Type[] getGenericParameterTypes() {
+        return get().getGenericParameterTypes();
+    }
+
+    @Override
+    public Class<?>[] getExceptionTypes() {
+        return get().getExceptionTypes();
+    }
+
+    @Override
+    public java.lang.reflect.Type[] getGenericExceptionTypes() {
+        return get().getGenericExceptionTypes();
+    }
+
+    @Override
+    public String toGenericString() {
+        return get().toGenericString();
+    }
+
+    @Override
+    public boolean isVarArgs() {
+        return get().isVarArgs();
+    }
+
+    @Override
+    public boolean isSynthetic() {
+        return get().isSynthetic();
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedConstructor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedField.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedField.java?rev=1086146&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedField.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedField.java Mon Mar 28 08:04:08 2011
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.finder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+/**
+* @version $Rev$ $Date$
+*/
+public class MetaAnnotatedField extends MetaAnnotatedObject<Field> implements AnnotatedMember<Field> {
+
+    public MetaAnnotatedField(Field field) {
+        super(field, unroll(field.getDeclaringClass(), field));
+    }
+
+    @Override
+    public Annotation[] getDeclaredAnnotations() {
+        return get().getDeclaredAnnotations();
+    }
+
+    @Override
+    public Class<?> getDeclaringClass() {
+        return get().getDeclaringClass();
+    }
+
+    @Override
+    public String getName() {
+        return get().getName();
+    }
+
+    @Override
+    public int getModifiers() {
+        return get().getModifiers();
+    }
+
+    @Override
+    public boolean isSynthetic() {
+        return get().isSynthetic();
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedMethod.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedMethod.java?rev=1086146&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedMethod.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedMethod.java Mon Mar 28 08:04:08 2011
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.finder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+* @version $Rev$ $Date$
+*/
+public class MetaAnnotatedMethod extends MetaAnnotatedObject<Method> implements AnnotatedMethod<Method> {
+
+    public MetaAnnotatedMethod(Method method) {
+        super(method, unroll(method.getDeclaringClass(), method));
+    }
+
+    @Override
+    public Annotation[] getDeclaredAnnotations() {
+        return target.getDeclaredAnnotations();
+    }
+
+    @Override
+    public Annotation[][] getParameterAnnotations() {
+        return target.getParameterAnnotations();
+    }
+
+    @Override
+    public Class<?> getDeclaringClass() {
+        return target.getDeclaringClass();
+    }
+
+    @Override
+    public String getName() {
+        return target.getName();
+    }
+
+    @Override
+    public int getModifiers() {
+        return target.getModifiers();
+    }
+
+    @Override
+    public Class<?>[] getParameterTypes() {
+        return target.getParameterTypes();
+    }
+
+    @Override
+    public java.lang.reflect.Type[] getGenericParameterTypes() {
+        return target.getGenericParameterTypes();
+    }
+
+    @Override
+    public Class<?>[] getExceptionTypes() {
+        return target.getExceptionTypes();
+    }
+
+    @Override
+    public java.lang.reflect.Type[] getGenericExceptionTypes() {
+        return target.getGenericExceptionTypes();
+    }
+
+    @Override
+    public String toGenericString() {
+        return target.toGenericString();
+    }
+
+    @Override
+    public boolean isVarArgs() {
+        return target.isVarArgs();
+    }
+
+    @Override
+    public boolean isSynthetic() {
+        return target.isSynthetic();
+    }
+
+
+
+
+}

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedMethod.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedObject.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedObject.java?rev=1086146&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedObject.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedObject.java Mon Mar 28 08:04:08 2011
@@ -0,0 +1,244 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.xbean.finder;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static java.util.Arrays.asList;
+
+/**
+* @version $Rev$ $Date$
+*/
+public abstract class MetaAnnotatedObject<T> implements MetaAnnotated<T> {
+    protected final Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations = new HashMap<Class<? extends Annotation>, MetaAnnotation<?>>();
+    protected final T target;
+
+    MetaAnnotatedObject(T target, Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations) {
+        this.target = target;
+        this.annotations.putAll(annotations);
+    }
+
+    @Override
+    public T get() {
+        return target;
+    }
+
+    @Override
+    public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+        return annotations.containsKey(annotationClass);
+    }
+
+    @Override
+    public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+        MetaAnnotation<T> annotation = (MetaAnnotation<T>) annotations.get(annotationClass);
+        return (annotation == null) ? null : annotation.get();
+    }
+
+    @Override
+    public Annotation[] getAnnotations() {
+        Annotation[] annotations = new Annotation[this.annotations.size()];
+
+        int i = 0;
+        for (MetaAnnotation annotation : this.annotations.values()) {
+            annotations[i++] = annotation.get();
+        }
+
+        return annotations;
+    }
+
+    @Override
+    public Collection<MetaAnnotation<?>> getMetaAnnotations() {
+        return Collections.unmodifiableCollection(annotations.values());
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return get().equals(obj);
+    }
+
+    @Override
+    public int hashCode() {
+        return get().hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return get().toString();
+    }
+
+    
+    private static void unroll(Class<? extends Annotation> clazz, int depth, Map<Class<? extends Annotation>, MetaAnnotation<?>> found) {
+        if (!isMetaAnnotation(clazz)) return;
+
+        for (Annotation annotation : getDeclaredMetaAnnotations(clazz)) {
+            Class<? extends Annotation> type = annotation.annotationType();
+
+            MetaAnnotation existing = found.get(type);
+
+            if (existing != null) {
+
+                if (existing.getDepth() > depth) {
+
+                    // OVERWRITE
+
+                    found.put(type, new MetaAnnotation(annotation, depth, clazz));
+
+                    unroll(type, depth + 1, found);
+
+                } else if (existing.getDepth() < depth) {
+
+                    // IGNORE
+
+                    // ignore, what we have already is higher priority
+
+                } else {
+
+                    // CONFLICT
+
+                    // They are the same depth and therefore conflicting
+                    existing.getConflicts().add(new MetaAnnotation(annotation, depth, clazz));
+
+                }
+
+            } else {
+
+                // NEW
+
+                found.put(type, new MetaAnnotation(annotation, depth, clazz));
+
+                unroll(type, depth + 1, found);
+
+            }
+        }
+    }
+
+    private static boolean isMetaAnnotation(Class<? extends Annotation> clazz) {
+        for (Annotation annotation : clazz.getDeclaredAnnotations()) {
+            if (isMetatypeAnnotation(annotation.annotationType())) return true;
+        }
+
+        return false;
+    }
+
+    private static Collection<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> clazz) {
+
+        Map<Class, Annotation> map = new HashMap<Class, Annotation>();
+
+        // pull in the annotations declared on this annotation
+
+        for (Annotation annotation : clazz.getDeclaredAnnotations()) {
+            map.put(annotation.annotationType(), annotation);
+        }
+
+        List<Annotation[]> groups = new ArrayList<Annotation[]>();
+
+        Class<? extends Annotation> metatype = getMetatype(clazz);
+        if (metatype != null) {
+            try {
+                Class<?> def = clazz.getClassLoader().loadClass(clazz.getName() + "$$");
+
+                List<AnnotatedElement> elements = new ArrayList<AnnotatedElement>();
+
+                elements.addAll(asList(def.getDeclaredFields()));
+                elements.addAll(asList(def.getDeclaredConstructors()));
+                elements.addAll(asList(def.getDeclaredMethods()));
+
+                for (Method method : def.getDeclaredMethods()) {
+                    for (Annotation[] array : method.getParameterAnnotations()) {
+                        groups.add(array);
+                    }
+                }
+
+                for (Constructor constructor : def.getDeclaredConstructors()) {
+                    for (Annotation[] array : constructor.getParameterAnnotations()) {
+                        groups.add(array);
+                    }
+                }
+
+                for (AnnotatedElement element : elements) {
+                    groups.add(element.getDeclaredAnnotations());
+                }
+
+                for (Annotation[] annotations : groups) {
+                    if (contains(annotations, clazz)) {
+                        for (Annotation annotation : annotations) {
+                            map.put(annotation.annotationType(), annotation);
+                        }
+                    }
+                }
+            } catch (ClassNotFoundException e) {
+                // inner class is optional
+            }
+        }
+
+        map.remove(Target.class);
+        map.remove(Retention.class);
+        map.remove(Documented.class);
+        map.remove(metatype);
+        map.remove(clazz);
+
+        return map.values();
+    }
+
+    private static boolean contains(Annotation[] annotations, Class<? extends Annotation> clazz) {
+        for (Annotation annotation : annotations) {
+            if (clazz.equals(annotation.annotationType())) return true;
+        }
+        return false;
+    }
+
+    private static Class<? extends Annotation> getMetatype(Class<? extends Annotation> clazz) {
+        for (Annotation annotation : clazz.getDeclaredAnnotations()) {
+            Class<? extends Annotation> type = annotation.annotationType();
+
+            if (isMetatypeAnnotation(type)) return type;
+        }
+
+        return null;
+    }
+
+    private static boolean isMetatypeAnnotation(Class<? extends Annotation> type) {
+        return type.getSimpleName().equals("Metatype") && type.isAnnotationPresent(type);
+    }
+
+    protected static Map<Class<? extends Annotation>, MetaAnnotation<?>> unroll(Class<?> declaringClass, AnnotatedElement element) {
+        
+        Map<Class<? extends Annotation>, MetaAnnotation<?>> map = new HashMap<Class<? extends Annotation>, MetaAnnotation<?>>();
+
+        for (Annotation annotation : element.getDeclaredAnnotations()) {
+
+            map.put(annotation.annotationType(), new MetaAnnotation(annotation, 0, declaringClass));
+
+            unroll(annotation.annotationType(), 1, map);
+
+        }
+        
+        return map;
+    }
+}

Propchange: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java?rev=1086146&r1=1086145&r2=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java Mon Mar 28 08:04:08 2011
@@ -36,7 +36,7 @@ public class MetaAnnotation<T extends An
         this.declaringClass = declaringClass;
     }
 
-    public T getAnnotation() {
+    public T get() {
         return annotation;
     }
 

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java?rev=1086146&r1=1086145&r2=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java Mon Mar 28 08:04:08 2011
@@ -45,11 +45,11 @@ public class MetaAnnotatedClassTest exte
     public void test() throws Exception {
         AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(Square.class, Circle.class, Triangle.class, Fake.class, Store.class, Farm.class, None.class)).link();
 
-        Map<Class<?>, AnnotatedTarget<Class<?>>> map = new HashMap<Class<?>, AnnotatedTarget<Class<?>>>();
+        Map<Class<?>, Annotated<Class<?>>> map = new HashMap<Class<?>, Annotated<Class<?>>>();
 
-        List<AnnotatedTarget<Class<?>>> metas = finder.findMetaAnnotatedClasses(Color.class);
-        for (AnnotatedTarget<Class<?>> meta : metas) {
-            AnnotatedTarget<Class<?>> oldValue = map.put(meta.getTarget(), meta);
+        List<Annotated<Class<?>>> metas = finder.findMetaAnnotatedClasses(Color.class);
+        for (Annotated<Class<?>> meta : metas) {
+            Annotated<Class<?>> oldValue = map.put(meta.get(), meta);
             assertNull("no duplicates allowed", oldValue);
         }
 
@@ -59,7 +59,7 @@ public class MetaAnnotatedClassTest exte
         // Check the positive scenarios
 
         { // Circle
-            AnnotatedTarget<Class<?>> target = map.get(Circle.class);
+            Annotated<Class<?>> target = map.get(Circle.class);
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -70,7 +70,7 @@ public class MetaAnnotatedClassTest exte
         }
 
         { // Square
-            AnnotatedTarget<Class<?>> target = map.get(Square.class);
+            Annotated<Class<?>> target = map.get(Square.class);
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -86,7 +86,7 @@ public class MetaAnnotatedClassTest exte
         }
 
         { // Triangle
-            AnnotatedTarget<Class<?>> target = map.get(Triangle.class);
+            Annotated<Class<?>> target = map.get(Triangle.class);
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -107,10 +107,10 @@ public class MetaAnnotatedClassTest exte
         }
 
         { // Fake -- should not get more than we asked for
-            AnnotatedTarget<Class<?>> target = map.get(Fake.class);
+            Annotated<Class<?>> target = map.get(Fake.class);
             assertNull(target);
 
-            List<AnnotatedTarget<Class<?>>> list = finder.findMetaAnnotatedClasses(NotMeta.class);
+            List<Annotated<Class<?>>> list = finder.findMetaAnnotatedClasses(NotMeta.class);
             assertEquals(1, list.size());
 
             target = list.get(0);
@@ -124,7 +124,7 @@ public class MetaAnnotatedClassTest exte
 
 
         { // Circular - Egg wins
-            AnnotatedTarget<Class<?>> target = map.get(Store.class);
+            Annotated<Class<?>> target = map.get(Store.class);
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -145,7 +145,7 @@ public class MetaAnnotatedClassTest exte
         }
 
         { // Circular - Chicken wins
-            AnnotatedTarget<Class<?>> target = map.get(Farm.class);
+            Annotated<Class<?>> target = map.get(Farm.class);
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedFieldTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedFieldTest.java?rev=1086146&r1=1086145&r2=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedFieldTest.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedFieldTest.java Mon Mar 28 08:04:08 2011
@@ -40,11 +40,11 @@ public class MetaAnnotatedFieldTest exte
     public void test() throws Exception {
         AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(Square.class, Circle.class, Triangle.class, Oval.class, Store.class, Farm.class, None.class)).link();
 
-        Map<String, AnnotatedMember<Field>> map = new HashMap<String, AnnotatedMember<Field>>();
+        Map<String, Annotated<Field>> map = new HashMap<String, Annotated<Field>>();
 
-        List<AnnotatedMember<Field>> fields = finder.findMetaAnnotatedFields(Color.class);
-        for (AnnotatedMember<Field> field : fields) {
-            AnnotatedMember<Field> oldValue = map.put(field.getName(), field);
+        List<Annotated<Field>> fields = finder.findMetaAnnotatedFields(Color.class);
+        for (Annotated<Field> field : fields) {
+            Annotated<Field> oldValue = map.put(field.get().getName(), field);
             assertNull("no duplicates allowed", oldValue);
         }
 
@@ -53,7 +53,7 @@ public class MetaAnnotatedFieldTest exte
 
         // Check the positive scenarios
         {
-            AnnotatedTarget<Field> target = map.get("circle");
+            Annotated<Field> target = map.get("circle");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -72,7 +72,7 @@ public class MetaAnnotatedFieldTest exte
         }
 
         {
-            AnnotatedTarget<Field> target = map.get("square");
+            Annotated<Field> target = map.get("square");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -91,7 +91,7 @@ public class MetaAnnotatedFieldTest exte
         }
 
         {
-            AnnotatedTarget<Field> target = map.get("triangle");
+            Annotated<Field> target = map.get("triangle");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -115,7 +115,7 @@ public class MetaAnnotatedFieldTest exte
         }
 
         { // Circular - Egg wins
-            AnnotatedTarget<Field> target = map.get("store");
+            Annotated<Field> target = map.get("store");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -139,7 +139,7 @@ public class MetaAnnotatedFieldTest exte
         }
 
         { // Circular - Chicken wins
-            AnnotatedTarget<Field> target = map.get("farm");
+            Annotated<Field> target = map.get("farm");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodTest.java?rev=1086146&r1=1086145&r2=1086146&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodTest.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodTest.java Mon Mar 28 08:04:08 2011
@@ -40,11 +40,11 @@ public class MetaAnnotatedMethodTest ext
     public void test() throws Exception {
         AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(Square.class, Circle.class, Triangle.class, Oval.class, Store.class, Farm.class, None.class)).link();
 
-        Map<String, AnnotatedMethod<Method>> map = new HashMap<String, AnnotatedMethod<Method>>();
+        Map<String, Annotated<Method>> map = new HashMap<String, Annotated<Method>>();
 
-        List<AnnotatedMethod<Method>> methods = finder.findMetaAnnotatedMethods(Color.class);
-        for (AnnotatedMethod<Method> method : methods) {
-            AnnotatedMethod<Method> oldValue = map.put(method.getName(), method);
+        List<Annotated<Method>> methods = finder.findMetaAnnotatedMethods(Color.class);
+        for (Annotated<Method> method : methods) {
+            Annotated<Method> oldValue = map.put(method.get().getName(), method);
             assertNull("no duplicates allowed", oldValue);
         }
 
@@ -53,7 +53,7 @@ public class MetaAnnotatedMethodTest ext
 
         // Check the positive scenarios
         {
-            AnnotatedTarget<Method> target = map.get("circle");
+            Annotated<Method> target = map.get("circle");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -72,7 +72,7 @@ public class MetaAnnotatedMethodTest ext
         }
 
         {
-            AnnotatedTarget<Method> target = map.get("square");
+            Annotated<Method> target = map.get("square");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -91,7 +91,7 @@ public class MetaAnnotatedMethodTest ext
         }
 
         {
-            AnnotatedTarget<Method> target = map.get("triangle");
+            Annotated<Method> target = map.get("triangle");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -115,7 +115,7 @@ public class MetaAnnotatedMethodTest ext
         }
 
         { // Circular - Egg wins
-            AnnotatedTarget<Method> target = map.get("store");
+            Annotated<Method> target = map.get("store");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -139,7 +139,7 @@ public class MetaAnnotatedMethodTest ext
         }
 
         { // Circular - Chicken wins
-            AnnotatedTarget<Method> target = map.get("farm");
+            Annotated<Method> target = map.get("farm");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));



Mime
View raw message