geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1085842 - in /geronimo/xbean/trunk/xbean-finder/src: main/java/org/apache/xbean/finder/ test/java/org/apache/xbean/finder/
Date Sun, 27 Mar 2011 00:42:03 GMT
Author: dblevins
Date: Sun Mar 27 00:42:02 2011
New Revision: 1085842

URL: http://svn.apache.org/viewvc?rev=1085842&view=rev
Log:
 XBEAN-165: Meta Annotation Support

Support for Meta Annotated Fields
Added an interface so we could bridge the gap between the old and new finders
Cleaned up the AnnotationFinder inner classes to be static, so the data returned from the findMetaAnnotatedFoo methods could be held indefinitely without causing the AnnotationFinder (and its asm data) to be held.

 XBEAN-166 : Class Name Filtering for Optimized Scanning
  XBEAN-171: RegexFilteredArchive supporting regular expressions to include/exclude classes from scanning
  XBEAN-172: PrefixFilteredArchive supports "startsWith" list of accepted prefixes
  XBEAN-173: PackageFilteredArchive supports strict list of accepted package names

Promoted the Filter stuff to be not classname specific


Added:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filter.java   (with props)
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IAnnotationFinder.java   (with props)
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java   (with props)
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java   (with props)
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedFieldTest.java
      - copied, changed from r1084874, 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
    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/AnnotationFinder.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFilter.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ExcludeIncludeFilter.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilterList.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilteredArchive.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filters.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IncludeExcludeFilter.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/PackageFilter.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/RegexFilter.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FilteredArchiveTest.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FiltersTest.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=1085842&r1=1085841&r2=1085842&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 Sun Mar 27 00:42:02 2011
@@ -23,10 +23,14 @@ package org.apache.xbean.finder;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -45,7 +49,7 @@ import org.objectweb.asm.signature.Signa
 /**
  * @version $Rev$ $Date$
  */
-public abstract class AbstractFinder {
+public abstract class AbstractFinder implements IAnnotationFinder {
     private final Map<String, List<Info>> annotated = new HashMap<String, List<Info>>();
     protected final Map<String, ClassInfo> classInfos = new HashMap<String, ClassInfo>();
     private final List<String> classesNotLoaded = new ArrayList<String>();
@@ -210,6 +214,41 @@ public abstract class AbstractFinder {
         return classes;
     }
 
+    @Override
+    public List<AnnotatedTarget<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation) {
+        List<Class<?>> classes = findAnnotatedClasses(annotation);
+        List<AnnotatedTarget<Class<?>>> list = new ArrayList<AnnotatedTarget<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();
+                }
+            });
+        }
+        return list;
+    }
+
     /**
      * Naive implementation - works extremelly slow O(n^3)
      *
@@ -297,6 +336,111 @@ public abstract class AbstractFinder {
         return methods;
     }
 
+    @Override
+    public List<AnnotatedMethod<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation) {
+        List<Method> methods = findAnnotatedMethods(annotation);
+        List<AnnotatedMethod<Method>> list = new ArrayList<AnnotatedMethod<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();
+                }
+            });
+        }
+        return list;
+    }
+
     public List<Constructor> findAnnotatedConstructors(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
         List<ClassInfo> seen = new ArrayList<ClassInfo>();
@@ -355,6 +499,79 @@ public abstract class AbstractFinder {
         return fields;
     }
 
+    @Override
+    public List<AnnotatedMember<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation) {
+        List<Field> fields = findAnnotatedFields(annotation);
+        List<AnnotatedMember<Field>> list = new ArrayList<AnnotatedMember<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();
+                }
+
+                
+            });
+        }
+
+        return list;
+    }
+
     public List<Class<?>> findClassesInPackage(String packageName, boolean recursive) {
         classesNotLoaded.clear();
         List<Class<?>> classes = new ArrayList<Class<?>>();

Modified: 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/AnnotatedTarget.java?rev=1085842&r1=1085841&r2=1085842&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/AnnotatedTarget.java Sun Mar 27 00:42:02 2011
@@ -22,7 +22,7 @@ import java.lang.reflect.GenericDeclarat
 /**
  * @version $Rev$ $Date$
  */
-public interface AnnotatedTarget<T> extends AnnotatedElement, GenericDeclaration {
+public interface AnnotatedTarget<T> extends AnnotatedElement {
 
     T getTarget();
 

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=1085842&r1=1085841&r2=1085842&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 Sun Mar 27 00:42:02 2011
@@ -41,7 +41,6 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
-import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -61,7 +60,7 @@ import java.util.Set;
  *
  * @version $Rev$ $Date$
  */
-public class AnnotationFinder {
+public class AnnotationFinder implements IAnnotationFinder {
 
     private final Set<Class<? extends Annotation>> metaroots = new HashSet<Class<? extends Annotation>>();
 
@@ -243,6 +242,7 @@ public class AnnotationFinder {
         }
     }
 
+    @Override
     public boolean isAnnotationPresent(Class<? extends Annotation> annotation) {
         List<Info> infos = annotated.get(annotation.getName());
         return infos != null && !infos.isEmpty();
@@ -261,11 +261,13 @@ public class AnnotationFinder {
      *
      * @return an unmodifiable live view of classes that could not be loaded in previous findAnnotated* call.
      */
+    @Override
     public List<String> getClassesNotLoaded() {
         return Collections.unmodifiableList(classesNotLoaded);
     }
 
-    public List<AnnotatedTarget<Package>> findAnnotatedPackages(Class<? extends Annotation> annotation) {
+    @Override
+    public List<Package> findAnnotatedPackages(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
         List<Package> packages = new ArrayList<Package>();
         List<Info> infos = getAnnotationInfos(annotation.getName());
@@ -283,9 +285,10 @@ public class AnnotationFinder {
                 }
             }
         }
-        return null;
+        return packages;
     }
 
+    @Override
     public List<Class<?>> findAnnotatedClasses(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
         List<Class<?>> classes = new ArrayList<Class<?>>();
@@ -307,6 +310,7 @@ public class AnnotationFinder {
         return classes;
     }
 
+    @Override
     public List<AnnotatedTarget<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
         Set<Class<?>> classes = findMetaAnnotatedClasses(annotation, new HashSet<Class<?>>());
@@ -314,7 +318,7 @@ public class AnnotationFinder {
         List<AnnotatedTarget<Class<?>>> list = new ArrayList<AnnotatedTarget<Class<?>>>();
 
         for (Class<?> clazz : classes) {
-            list.add(new MetaAnnotatedClass(clazz));
+            list.add(new MetaAnnotatedClass(clazz, unrollClass(clazz)));
         }
 
         return list;
@@ -353,7 +357,8 @@ public class AnnotationFinder {
      * @param annotation
      * @return list of directly or indirectly (inherited) annotated classes
      */
-    public List<AnnotatedTarget<Class<?>>> findInheritedAnnotatedClasses(Class<? extends Annotation> annotation) {
+    @Override
+    public List<Class<?>> findInheritedAnnotatedClasses(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
         List<Class<?>> classes = new ArrayList<Class<?>>();
         List<Info> infos = getAnnotationInfos(annotation.getName());
@@ -402,9 +407,10 @@ public class AnnotationFinder {
                 }
             }
         } while (annClassFound);
-        return null;
+        return classes;
     }
 
+    @Override
     public List<Method> findAnnotatedMethods(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
         List<ClassInfo> seen = new ArrayList<ClassInfo>();
@@ -434,6 +440,7 @@ public class AnnotationFinder {
         return methods;
     }
 
+    @Override
     public List<AnnotatedMethod<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
 
@@ -442,7 +449,7 @@ public class AnnotationFinder {
         List<AnnotatedMethod<Method>> targets = new ArrayList<AnnotatedMethod<Method>>();
 
         for (Method method : methods) {
-            targets.add(new MetaAnnotatedMethod(method));
+            targets.add(new MetaAnnotatedMethod(method, unrollMethod(method)));
         }
 
         return targets;
@@ -493,7 +500,68 @@ public class AnnotationFinder {
         return methods;
     }
 
-    public List<AnnotatedMethod<Constructor>> findAnnotatedConstructors(Class<? extends Annotation> annotation) {
+    @Override
+    public List<AnnotatedMember<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>>();
+
+        for (Field field : fields) {
+            targets.add(new MetaAnnotatedField(field, unrollField(field)));
+        }
+
+        return targets;
+    }
+
+    private Set<Field> findMetaAnnotatedFields(Class<? extends Annotation> annotation, Set<Field> fields, Set<String> seen) {
+        List<Info> infos = getAnnotationInfos(annotation.getName());
+
+        for (Info info : infos) {
+
+            String meta = info.getMetaAnnotationName();
+            if (meta != null) {
+                if (meta.equals(annotation.getName())) continue;
+                if (!seen.add(meta)) continue;
+
+
+                ClassInfo metaInfo = classInfos.get(meta);
+
+                Class<?> clazz;
+                try {
+                    clazz = metaInfo.get();
+                } catch (ClassNotFoundException e) {
+                    classesNotLoaded.add(metaInfo.getName());
+                    continue;
+                }
+
+                findMetaAnnotatedFields((Class<? extends Annotation>) clazz, fields, seen);
+
+            } else if (info instanceof FieldInfo) {
+
+                FieldInfo fieldInfo = (FieldInfo) info;
+
+                ClassInfo classInfo = fieldInfo.getDeclaringClass();
+
+                try {
+                    Class clazz = classInfo.get();
+                    for (Field field : clazz.getDeclaredFields()) {
+                        if (field.isAnnotationPresent(annotation)) {
+                            fields.add(field);
+                        }
+                    }
+                } catch (ClassNotFoundException e) {
+                    classesNotLoaded.add(classInfo.getName());
+                }
+            }
+        }
+
+        return fields;
+    }
+
+    @Override
+    public List<Constructor> findAnnotatedConstructors(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
         List<ClassInfo> seen = new ArrayList<ClassInfo>();
         List<Constructor> constructors = new ArrayList<Constructor>();
@@ -519,10 +587,11 @@ public class AnnotationFinder {
                 }
             }
         }
-        return null;
+        return constructors;
     }
 
-    public List<AnnotatedMember<Field>> findAnnotatedFields(Class<? extends Annotation> annotation) {
+    @Override
+    public List<Field> findAnnotatedFields(Class<? extends Annotation> annotation) {
         classesNotLoaded.clear();
         List<ClassInfo> seen = new ArrayList<ClassInfo>();
         List<Field> fields = new ArrayList<Field>();
@@ -548,9 +617,10 @@ public class AnnotationFinder {
                 }
             }
         }
-        return null;
+        return fields;
     }
 
+    @Override
     public List<Class<?>> findClassesInPackage(String packageName, boolean recursive) {
         classesNotLoaded.clear();
         List<Class<?>> classes = new ArrayList<Class<?>>();
@@ -568,6 +638,7 @@ public class AnnotationFinder {
         return classes;
     }
 
+    @Override
     public <T> List<Class<? extends T>> findSubclasses(Class<T> clazz) {
         if (clazz == null) throw new NullPointerException("class cannot be null");
 
@@ -627,6 +698,7 @@ public class AnnotationFinder {
         return classes;
     }
 
+    @Override
     public <T> List<Class<? extends T>> findImplementations(Class<T> clazz) {
         if (clazz == null) throw new NullPointerException("class cannot be null");
         if (!clazz.isInterface()) new IllegalArgumentException("class must be an interface");
@@ -1064,12 +1136,14 @@ public class AnnotationFinder {
         private final String name;
         private final String type;
         private final ClassInfo declaringClass;
+        private Field field;
 
         public FieldInfo(ClassInfo info, Field field) {
             super(field);
             this.declaringClass = info;
             this.name = field.getName();
             this.type = field.getType().getName();
+            this.field = field;
         }
 
         public FieldInfo(ClassInfo declaringClass, String name, String type) {
@@ -1093,6 +1167,41 @@ public class AnnotationFinder {
         public String toString() {
             return declaringClass + "#" + name;
         }
+        
+        @Override
+        public String getMetaAnnotationName() {
+            return declaringClass.getMetaAnnotationName();
+        }
+
+        @Override
+        public Annotation[] getDeclaredAnnotations() {
+            super.getDeclaredAnnotations();
+            try {
+                return ((AnnotatedElement) get()).getDeclaredAnnotations();
+            } catch (ClassNotFoundException e) {
+                return super.getDeclaredAnnotations();
+            }
+        }
+
+        public Member get() throws ClassNotFoundException {
+            if (field == null) {
+                field = toField();
+            }
+
+            return field;
+        }
+
+        private Field toField() throws ClassNotFoundException {
+
+            Class<?> clazz = this.declaringClass.get();
+
+            try {
+                return clazz.getDeclaredField(name);
+            } catch (NoSuchFieldException e) {
+                throw new IllegalStateException(name, e);
+            }
+
+        }
     }
 
     public class AnnotationInfo extends Annotatable implements Info {
@@ -1362,163 +1471,170 @@ public class AnnotationFinder {
 
     }
 
-    /**
-     * @version $Rev$ $Date$
-     */
-    public abstract class MetaAnnotatedTarget<T> implements AnnotatedTarget<T> {
-        protected final Map<Class<? extends Annotation>, MetaAnnotation> found = new HashMap<Class<? extends Annotation>, MetaAnnotation>();
-        protected final T target;
+    private void unroll(Class<? extends Annotation> clazz, int depth, Map<Class<? extends Annotation>, MetaAnnotation<?>> found) {
+        if (!isMetaAnnotation(clazz)) return;
 
-        public MetaAnnotatedTarget(T target) {
-            this.target = target;
-        }
+        for (Annotation annotation : getDeclaredMetaAnnotations(clazz)) {
+            Class<? extends Annotation> type = annotation.annotationType();
 
-        @Override
-        public T getTarget() {
-            return target;
-        }
+            MetaAnnotation existing = found.get(type);
 
-        @Override
-        public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
-            return found.containsKey(annotationClass);
-        }
+            if (existing != null) {
 
-        @Override
-        public TypeVariable<?>[] getTypeParameters() {
-            return ((Class<?>) getTarget()).getTypeParameters();
-        }
+                if (existing.getDepth() > depth) {
 
-        @Override
-        public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
-            MetaAnnotation<T> annotation = found.get(annotationClass);
-            return (annotation == null) ? null : annotation.getAnnotation();
-        }
-
-        @Override
-        public Annotation[] getAnnotations() {
-            Annotation[] annotations = new Annotation[found.size()];
+                    // OVERWRITE
 
-            int i = 0;
-            for (MetaAnnotation annotation : found.values()) {
-                annotations[i++] = annotation.getAnnotation();
-            }
+                    found.put(type, new MetaAnnotation(annotation, depth, clazz));
 
-            return annotations;
-        }
+                    unroll(type, depth + 1, found);
 
-        protected void unroll(Class<? extends Annotation> clazz, int depth) {
-            if (!isMetaAnnotation(clazz)) return;
+                } else if (existing.getDepth() < depth) {
 
-            for (Annotation annotation : getDeclaredMetaAnnotations(clazz)) {
-                Class<? extends Annotation> type = annotation.annotationType();
+                    // IGNORE
 
-                MetaAnnotation existing = found.get(type);
+                    // ignore, what we have already is higher priority
 
-                if (existing != null) {
-                    if (existing.getDepth() > depth) {
-//                        System.out.println("OVERWRITE " + type);
-                        //overwrite
-                        found.put(type, new MetaAnnotation(annotation, depth, clazz));
-                        unroll(type, depth + 1);
-                    } else if (existing.getDepth() < depth) {
-//                        System.out.println("IGNORE " + type);
-                        // ignore, what we have already is higher priority
-                    } else {
-//                        System.out.println("CONFLICT " + type);
-                        // They are the same depth and therefore conflicting
-                        existing.getConflicts().add(new MetaAnnotation(annotation, depth, clazz));
-                    }
                 } else {
-//                    System.out.println("NEW " + type);
-                    found.put(type, new MetaAnnotation(annotation, depth, clazz));
-                    unroll(type, depth + 1);
+
+                    // 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())) {
 
-        private Collection<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> clazz) {
-            Map<Class, Annotation> map = new HashMap<Class, Annotation>();
+            if (!clazz.getName().equals(info.getMetaAnnotationName())) continue;
 
-            for (Annotation annotation : clazz.getDeclaredAnnotations()) {
+            for (Annotation annotation : info.getDeclaredAnnotations()) {
                 map.put(annotation.annotationType(), annotation);
             }
 
-            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);
 
-            Class[] invalid = {
-                    Target.class,
-                    Retention.class,
-                    Documented.class,
-                    clazz
-            };
+        for (Class<? extends Annotation> metaroot : metaroots) {
+            map.remove(metaroot);
+        }
 
-            for (Class c : invalid) {
-                map.remove(c);
-            }
+        return map.values();
+    }
 
-            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;
         }
 
-        private boolean isMetaAnnotation(Class<? extends Annotation> clazz) {
-            if (!clazz.isAnnotation()) return false;
+        return false;
+    }
 
-            for (Annotation annotation : clazz.getDeclaredAnnotations()) {
-                if (metaroots.contains(annotation.annotationType())) return true;
-            }
+    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;
+    }
 
-            return false;
+    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 class MetaAnnotation<T extends Annotation> {
-        private final Class<?> declaringClass;
-        private final T annotation;
-        private final int depth;
+    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;
 
-        private final List<MetaAnnotation<T>> conflicts = new ArrayList<MetaAnnotation<T>>();
+        public MetaAnnotatedTarget(T target, Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations) {
+            this.target = target;
+            this.annotations.putAll(annotations);
+        }
 
-        private MetaAnnotation(T annotation, int depth, Class<?> declaringClass) {
-            this.annotation = annotation;
-            this.depth = depth;
-            this.declaringClass = declaringClass;
+        @Override
+        public T getTarget() {
+            return target;
         }
 
-        public T getAnnotation() {
-            return annotation;
+        @Override
+        public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+            return annotations.containsKey(annotationClass);
         }
 
-        public int getDepth() {
-            return depth;
+        @Override
+        public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+            MetaAnnotation<T> annotation = (MetaAnnotation<T>) annotations.get(annotationClass);
+            return (annotation == null) ? null : annotation.getAnnotation();
         }
 
-        public Class<?> getDeclaringClass() {
-            return declaringClass;
+        @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;
         }
 
-        public List<MetaAnnotation<T>> getConflicts() {
-            return conflicts;
+        @Override
+        public Collection<MetaAnnotation<?>> getMetaAnnotations() {
+            return Collections.unmodifiableCollection(annotations.values());
         }
     }
 
-    private class MetaAnnotatedClass extends MetaAnnotatedTarget<Class<?>> {
+    private static class MetaAnnotatedClass extends MetaAnnotatedTarget<Class<?>> {
 
-        private MetaAnnotatedClass(Class<?> clazz) {
-            super(clazz);
-            for (Annotation annotation : getTarget().getDeclaredAnnotations()) {
-                found.put(annotation.annotationType(), new MetaAnnotation(annotation, 0, getTarget()));
-                unroll(annotation.annotationType(), 1);
-            }
+        private MetaAnnotatedClass(Class<?> clazz, Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations) {
+            super(clazz, annotations);
         }
 
         @Override
@@ -1528,33 +1644,42 @@ public class AnnotationFinder {
     }
 
 
-    private class MetaAnnotatedField extends MetaAnnotatedTarget<Field> {
+    private static class MetaAnnotatedField extends MetaAnnotatedTarget<Field> implements AnnotatedMember<Field>{
 
-        private MetaAnnotatedField(Field target) {
-            super(target);
-            for (Annotation annotation : target.getDeclaredAnnotations()) {
-                found.put(annotation.annotationType(), new MetaAnnotation(annotation, 0, target.getDeclaringClass()));
-                unroll(annotation.annotationType(), 1);
-            }
+        private MetaAnnotatedField(Field target, Map<Class<? extends Annotation>, MetaAnnotation<?>> annotations) {
+            super(target, annotations);
         }
 
         @Override
         public Annotation[] getDeclaredAnnotations() {
             return getTarget().getDeclaredAnnotations();
         }
-    }
 
-    private class MetaAnnotatedMethod extends MetaAnnotatedTarget<Method> implements AnnotatedMethod<Method> {
+        @Override
+        public Class<?> getDeclaringClass() {
+            return getTarget().getDeclaringClass();
+        }
 
-        private Method target;
+        @Override
+        public String getName() {
+            return getTarget().getName();
+        }
 
-        private MetaAnnotatedMethod(Method target) {
-            super(target);
-            for (Annotation annotation : target.getDeclaredAnnotations()) {
-                found.put(annotation.annotationType(), new MetaAnnotation(annotation, 0, target.getDeclaringClass()));
-                unroll(annotation.annotationType(), 1);
-            }
+        @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
@@ -1583,11 +1708,6 @@ public class AnnotationFinder {
         }
 
         @Override
-        public TypeVariable<Method>[] getTypeParameters() {
-            return getTarget().getTypeParameters();
-        }
-
-        @Override
         public Class<?>[] getParameterTypes() {
             return getTarget().getParameterTypes();
         }

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFilter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFilter.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFilter.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFilter.java Sun Mar 27 00:42:02 2011
@@ -19,7 +19,7 @@ package org.apache.xbean.finder;
 /**
  * @version $Rev$ $Date$
  */
-public class ClassFilter implements FilteredArchive.Filter {
+public class ClassFilter implements Filter {
 
     private final String name;
 
@@ -29,8 +29,8 @@ public class ClassFilter implements Filt
     }
 
     @Override
-    public boolean accept(String className) {
-        return name.equals(className);
+    public boolean accept(String name) {
+        return this.name.equals(name);
     }
 
     @Override

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ExcludeIncludeFilter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ExcludeIncludeFilter.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ExcludeIncludeFilter.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ExcludeIncludeFilter.java Sun Mar 27 00:42:02 2011
@@ -20,19 +20,19 @@ package org.apache.xbean.finder;
  * First, all Exclude directives are evaluated; if any match, the className is denied unless it also matches an Include directive.
  * Any classNames which do not match any Include or Exclude directives are permitted.
  */
-public class ExcludeIncludeFilter implements FilteredArchive.Filter {
+public class ExcludeIncludeFilter implements Filter {
 
-    private final FilteredArchive.Filter include;
-    private final FilteredArchive.Filter exclude;
+    private final Filter include;
+    private final Filter exclude;
 
-    public ExcludeIncludeFilter(FilteredArchive.Filter include, FilteredArchive.Filter exclude) {
+    public ExcludeIncludeFilter(Filter include, Filter exclude) {
         this.include = include;
         this.exclude = exclude;
     }
 
     @Override
-    public boolean accept(String className) {
-        if (exclude.accept(className)) return include.accept(className);
+    public boolean accept(String name) {
+        if (exclude.accept(name)) return include.accept(name);
         return true;
     }
 }
\ No newline at end of file

Added: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filter.java?rev=1085842&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filter.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filter.java Sun Mar 27 00:42:02 2011
@@ -0,0 +1,24 @@
+/**
+ * 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;
+
+/**
+* @version $Rev$ $Date$
+*/
+public interface Filter {
+    boolean accept(String name);
+}

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

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilterList.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilterList.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilterList.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilterList.java Sun Mar 27 00:42:02 2011
@@ -23,30 +23,30 @@ import java.util.List;
 /**
  * @version $Rev$ $Date$
  */
-public class FilterList implements FilteredArchive.Filter {
+public class FilterList implements Filter {
 
-    private final List<FilteredArchive.Filter> filters = new ArrayList<FilteredArchive.Filter>();
+    private final List<Filter> filters = new ArrayList<Filter>();
 
-    public FilterList(FilteredArchive.Filter... filters) {
+    public FilterList(Filter... filters) {
         this(Arrays.asList(filters));
     }
 
-    public FilterList(Iterable<FilteredArchive.Filter> filters) {
-        for (FilteredArchive.Filter filter : filters) {
+    public FilterList(Iterable<Filter> filters) {
+        for (Filter filter : filters) {
             this.filters.add(filter);
         }
     }
 
     @Override
-    public boolean accept(String className) {
-        for (FilteredArchive.Filter filter : filters) {
-            if (filter.accept(className)) return true;
+    public boolean accept(String name) {
+        for (Filter filter : filters) {
+            if (filter.accept(name)) return true;
         }
 
         return false;
     }
 
-    public List<FilteredArchive.Filter> getFilters() {
+    public List<Filter> getFilters() {
         return filters;
     }
 }

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilteredArchive.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilteredArchive.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilteredArchive.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/FilteredArchive.java Sun Mar 27 00:42:02 2011
@@ -35,10 +35,6 @@ public class FilteredArchive implements 
         this.filter = filter;
     }
 
-    public static interface Filter {
-        boolean accept(String className);
-    }
-
     @Override
     public InputStream getBytecode(String className) throws IOException, ClassNotFoundException {
         return archive.getBytecode(className);

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filters.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filters.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filters.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/Filters.java Sun Mar 27 00:42:02 2011
@@ -27,15 +27,15 @@ import java.util.Set;
  * @version $Rev$ $Date$
  */
 public class Filters {
-    private static final FilteredArchive.Filter NONE = new FilteredArchive.Filter() {
+    private static final Filter NONE = new Filter() {
         @Override
-        public boolean accept(String className) {
+        public boolean accept(String name) {
             return false;
         }
     };
 
-    public static FilteredArchive.Filter packages(String... packages) {
-        List<FilteredArchive.Filter> filters = new ArrayList<FilteredArchive.Filter>();
+    public static Filter packages(String... packages) {
+        List<Filter> filters = new ArrayList<Filter>();
         for (String s : packages) {
             filters.add(new PackageFilter(s));
         }
@@ -43,8 +43,8 @@ public class Filters {
         return optimize(filters);
     }
 
-    public static FilteredArchive.Filter classes(String... classes) {
-        List<FilteredArchive.Filter> filters = new ArrayList<FilteredArchive.Filter>();
+    public static Filter classes(String... classes) {
+        List<Filter> filters = new ArrayList<Filter>();
         for (String s : classes) {
             filters.add(new ClassFilter(s));
         }
@@ -52,8 +52,8 @@ public class Filters {
         return optimize(filters);
     }
 
-    public static FilteredArchive.Filter patterns(String... patterns) {
-        List<FilteredArchive.Filter> filters = new ArrayList<FilteredArchive.Filter>();
+    public static Filter patterns(String... patterns) {
+        List<Filter> filters = new ArrayList<Filter>();
         for (String s : patterns) {
             filters.add(new RegexFilter(s));
         }
@@ -62,21 +62,21 @@ public class Filters {
     }
 
 
-    public static FilteredArchive.Filter optimize(FilteredArchive.Filter... filters) {
+    public static Filter optimize(Filter... filters) {
         return optimize(Arrays.asList(filters));
     }
 
-    public static FilteredArchive.Filter optimize(List<FilteredArchive.Filter>... filterss) {
-        Set<FilteredArchive.Filter> unwrapped = new LinkedHashSet<FilteredArchive.Filter>();
+    public static Filter optimize(List<Filter>... filterss) {
+        Set<Filter> unwrapped = new LinkedHashSet<Filter>();
 
-        for (List<FilteredArchive.Filter> filters : filterss) {
+        for (List<Filter> filters : filterss) {
             unwrap(filters, unwrapped);
         }
 
         if (unwrapped.size() > 1) {
-            Iterator<FilteredArchive.Filter> iterator = unwrapped.iterator();
+            Iterator<Filter> iterator = unwrapped.iterator();
             while (iterator.hasNext()) {
-                FilteredArchive.Filter filter = iterator.next();
+                Filter filter = iterator.next();
                 if (filter == NONE) iterator.remove();
             }
         }
@@ -86,8 +86,8 @@ public class Filters {
         return new FilterList(unwrapped);
     }
 
-    private static void unwrap(List<FilteredArchive.Filter> filters, Set<FilteredArchive.Filter> unwrapped) {
-        for (FilteredArchive.Filter filter : filters) {
+    private static void unwrap(List<Filter> filters, Set<Filter> unwrapped) {
+        for (Filter filter : filters) {
             if (filter instanceof FilterList) {
                 FilterList filterList = (FilterList) filter;
                 unwrap(filterList.getFilters(), unwrapped);

Added: 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=1085842&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IAnnotationFinder.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IAnnotationFinder.java Sun Mar 27 00:42:02 2011
@@ -0,0 +1,57 @@
+/**
+ * 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;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * Temporary interface to bridge the gap between the two finder impls
+ * @version $Rev$ $Date$
+ */
+public interface IAnnotationFinder {
+    boolean isAnnotationPresent(Class<? extends Annotation> annotation);
+
+    List<String> getClassesNotLoaded();
+
+    List<Package> findAnnotatedPackages(Class<? extends Annotation> annotation);
+
+    List<Class<?>> findAnnotatedClasses(Class<? extends Annotation> annotation);
+
+    List<Class<?>> findInheritedAnnotatedClasses(Class<? extends Annotation> annotation);
+
+    List<Method> findAnnotatedMethods(Class<? extends Annotation> annotation);
+
+    List<Constructor> findAnnotatedConstructors(Class<? extends Annotation> annotation);
+
+    List<Field> findAnnotatedFields(Class<? extends Annotation> annotation);
+
+    List<Class<?>> findClassesInPackage(String packageName, boolean recursive);
+
+    <T> List<Class<? extends T>> findSubclasses(Class<T> clazz);
+
+    <T> List<Class<? extends T>> findImplementations(Class<T> clazz);
+
+    List<AnnotatedMethod<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation);
+
+    List<AnnotatedMember<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation);
+
+    List<AnnotatedTarget<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation);
+}

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

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IncludeExcludeFilter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IncludeExcludeFilter.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IncludeExcludeFilter.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/IncludeExcludeFilter.java Sun Mar 27 00:42:02 2011
@@ -21,19 +21,19 @@ package org.apache.xbean.finder;
  * Next, all Exclude directives are evaluated. If any matches, the className is rejected.
  * Last, any classNames which do not match an Include or a Exclude directive are denied by default.
  */
-public class IncludeExcludeFilter implements FilteredArchive.Filter {
+public class IncludeExcludeFilter implements Filter {
 
-    private FilteredArchive.Filter include;
-    private FilteredArchive.Filter exclude;
+    private Filter include;
+    private Filter exclude;
 
-    public IncludeExcludeFilter(FilteredArchive.Filter include, FilteredArchive.Filter exclude) {
+    public IncludeExcludeFilter(Filter include, Filter exclude) {
         this.include = include;
         this.exclude = exclude;
     }
 
     @Override
-    public boolean accept(String className) {
-        if (include.accept(className)) return !exclude.accept(className);
+    public boolean accept(String name) {
+        if (include.accept(name)) return !exclude.accept(name);
         return false;
     }
 }

Added: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java?rev=1085842&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotated.java Sun Mar 27 00:42:02 2011
@@ -0,0 +1,27 @@
+/**
+ * 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.util.Collection;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface MetaAnnotated {
+
+    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/MetaAnnotation.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java?rev=1085842&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java Sun Mar 27 00:42:02 2011
@@ -0,0 +1,54 @@
+/**
+ * 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.util.ArrayList;
+import java.util.List;
+
+/**
+* @version $Rev$ $Date$
+*/
+public class MetaAnnotation<T extends Annotation> {
+    private final Class<?> declaringClass;
+    private final T annotation;
+    private final int depth;
+
+    private final List<MetaAnnotation<T>> conflicts = new ArrayList<MetaAnnotation<T>>();
+
+    MetaAnnotation(T annotation, int depth, Class<?> declaringClass) {
+        this.annotation = annotation;
+        this.depth = depth;
+        this.declaringClass = declaringClass;
+    }
+
+    public T getAnnotation() {
+        return annotation;
+    }
+
+    public int getDepth() {
+        return depth;
+    }
+
+    public Class<?> getDeclaringClass() {
+        return declaringClass;
+    }
+
+    public List<MetaAnnotation<T>> getConflicts() {
+        return conflicts;
+    }
+}

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

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/PackageFilter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/PackageFilter.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/PackageFilter.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/PackageFilter.java Sun Mar 27 00:42:02 2011
@@ -19,7 +19,7 @@ package org.apache.xbean.finder;
 /**
  * @version $Rev$ $Date$
  */
-public class PackageFilter implements FilteredArchive.Filter {
+public class PackageFilter implements Filter {
 
     private final String packageName;
 
@@ -30,8 +30,8 @@ public class PackageFilter implements Fi
     }
 
     @Override
-    public boolean accept(String className) {
-        return className.startsWith(packageName);
+    public boolean accept(String name) {
+        return name.startsWith(packageName);
     }
 
     @Override

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/RegexFilter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/RegexFilter.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/RegexFilter.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/RegexFilter.java Sun Mar 27 00:42:02 2011
@@ -21,7 +21,7 @@ import java.util.regex.Pattern;
 /**
  * @version $Rev$ $Date$
  */
-public class RegexFilter implements FilteredArchive.Filter {
+public class RegexFilter implements Filter {
 
     private final Pattern pattern;
 
@@ -35,8 +35,8 @@ public class RegexFilter implements Filt
     }
 
     @Override
-    public boolean accept(String className) {
-        return pattern.matcher(className).matches();
+    public boolean accept(String name) {
+        return pattern.matcher(name).matches();
     }
 
     @Override

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FilteredArchiveTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FilteredArchiveTest.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FilteredArchiveTest.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FilteredArchiveTest.java Sun Mar 27 00:42:02 2011
@@ -61,28 +61,28 @@ public class FilteredArchiveTest extends
         assertEquals(i + " items were the same", expected.hasNext(), actual.hasNext());
     }
 
-    public static class Nothing implements FilteredArchive.Filter {
+    public static class Nothing implements Filter {
 
         @Override
-        public boolean accept(String className) {
+        public boolean accept(String name) {
             return true;
         }
     }
 
-    public static class All implements FilteredArchive.Filter {
+    public static class All implements Filter {
 
         @Override
-        public boolean accept(String className) {
+        public boolean accept(String name) {
             return false;
         }
     }
 
-    public static class Half implements FilteredArchive.Filter {
+    public static class Half implements Filter {
 
         private boolean accept;
 
         @Override
-        public boolean accept(String className) {
+        public boolean accept(String name) {
             return accept = !accept;
         }
     }

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FiltersTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FiltersTest.java?rev=1085842&r1=1085841&r2=1085842&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FiltersTest.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/FiltersTest.java Sun Mar 27 00:42:02 2011
@@ -27,7 +27,7 @@ public class FiltersTest extends TestCas
     }
 
     public void testPackages() throws Exception {
-        FilteredArchive.Filter filter = Filters.packages("org.foo", "org.bar");
+        Filter filter = Filters.packages("org.foo", "org.bar");
 
         assertTrue(filter.accept("org.foo.Red"));
         assertTrue(filter.accept("org.bar.Orange"));
@@ -39,7 +39,7 @@ public class FiltersTest extends TestCas
     }
 
     public void testClasses() throws Exception {
-        FilteredArchive.Filter filter = Filters.classes("org.foo.Red", "org.foo.Blue");
+        Filter filter = Filters.classes("org.foo.Red", "org.foo.Blue");
 
         assertTrue(filter.accept("org.foo.Red"));
         assertTrue(filter.accept("org.foo.Blue"));
@@ -50,7 +50,7 @@ public class FiltersTest extends TestCas
     }
 
     public void testPatterns() throws Exception {
-        FilteredArchive.Filter filter = Filters.patterns("org\\.foo\\..*", ".*\\.Blue");
+        Filter filter = Filters.patterns("org\\.foo\\..*", ".*\\.Blue");
 
         assertTrue(filter.accept("org.foo.Red"));
         assertTrue(filter.accept("org.foo.Blue"));
@@ -89,7 +89,7 @@ public class FiltersTest extends TestCas
     }
 
     public void testIncludeExclude() {
-        FilteredArchive.Filter filter = new IncludeExcludeFilter(Filters.packages("org.foo", "org.bar"), Filters.packages("org.foo.util"));
+        Filter filter = new IncludeExcludeFilter(Filters.packages("org.foo", "org.bar"), Filters.packages("org.foo.util"));
 
         assertTrue(filter.accept("org.foo.Red"));
         assertTrue(filter.accept("org.bar.Red"));
@@ -99,7 +99,7 @@ public class FiltersTest extends TestCas
     }
 
     public void testExcludeInclude() {
-        FilteredArchive.Filter filter = new ExcludeIncludeFilter(Filters.packages("org.foo.util"), Filters.packages("org.foo", "org.bar"));
+        Filter filter = new ExcludeIncludeFilter(Filters.packages("org.foo.util"), Filters.packages("org.foo", "org.bar"));
 
         assertFalse(filter.accept("org.foo.Red"));
         assertFalse(filter.accept("org.bar.Red"));

Copied: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedFieldTest.java (from r1084874, 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/MetaAnnotatedFieldTest.java?p2=geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedFieldTest.java&p1=geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodTest.java&r1=1084874&r2=1085842&rev=1085842&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/MetaAnnotatedFieldTest.java Sun Mar 27 00:42:02 2011
@@ -22,28 +22,28 @@ import java.lang.annotation.Annotation;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
-import java.lang.reflect.Method;
+import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 /**
  * @version $Rev$ $Date$
  */
-public class MetaAnnotatedMethodTest extends TestCase {
+public class MetaAnnotatedFieldTest extends TestCase {
 
     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, AnnotatedMember<Field>> map = new HashMap<String, AnnotatedMember<Field>>();
 
-        List<AnnotatedMethod<Method>> methods = finder.findMetaAnnotatedMethods(Color.class);
-        for (AnnotatedMethod<Method> method : methods) {
-            AnnotatedMethod<Method> oldValue = map.put(method.getName(), method);
+        List<AnnotatedMember<Field>> fields = finder.findMetaAnnotatedFields(Color.class);
+        for (AnnotatedMember<Field> field : fields) {
+            AnnotatedMember<Field> oldValue = map.put(field.getName(), field);
             assertNull("no duplicates allowed", oldValue);
         }
 
@@ -52,7 +52,7 @@ public class MetaAnnotatedMethodTest ext
 
         // Check the positive scenarios
         {
-            AnnotatedTarget<Method> target = map.get("circle");
+            AnnotatedTarget<Field> target = map.get("circle");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -71,7 +71,7 @@ public class MetaAnnotatedMethodTest ext
         }
 
         {
-            AnnotatedTarget<Method> target = map.get("square");
+            AnnotatedTarget<Field> target = map.get("square");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -90,7 +90,7 @@ public class MetaAnnotatedMethodTest ext
         }
 
         {
-            AnnotatedTarget<Method> target = map.get("triangle");
+            AnnotatedTarget<Field> target = map.get("triangle");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -114,7 +114,7 @@ public class MetaAnnotatedMethodTest ext
         }
 
         { // Circular - Egg wins
-            AnnotatedTarget<Method> target = map.get("store");
+            AnnotatedTarget<Field> target = map.get("store");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -138,7 +138,7 @@ public class MetaAnnotatedMethodTest ext
         }
 
         { // Circular - Chicken wins
-            AnnotatedTarget<Method> target = map.get("farm");
+            AnnotatedTarget<Field> target = map.get("farm");
             assertNotNull(target);
 
             assertTrue(target.isAnnotationPresent(Color.class));
@@ -178,33 +178,33 @@ public class MetaAnnotatedMethodTest ext
     public @interface Metatype {
     }
 
-    @Target({METHOD})
+    @Target({FIELD})
     @Retention(RUNTIME)
     public static @interface Color {
         String value () default "";
     }
 
     @Metatype
-    @Target({METHOD})
+    @Target({FIELD})
     @Retention(RUNTIME)
     public static @interface Red {
-        public interface $ {
+        public class $ {
 
             @Red
             @Color("red")  // one level deep
-            public void method();
+            private Object field;
         }
     }
 
     @Metatype
-    @Target({METHOD})
+    @Target({FIELD})
     @Retention(RUNTIME)
     public static @interface Crimson {
-        public interface $ {
+        public class $ {
 
             @Crimson
             @Red  // two levels deep
-            public void method();
+            private Object field;
         }
     }
 
@@ -215,110 +215,110 @@ public class MetaAnnotatedMethodTest ext
     // annotations in the path are not strictly part
     // of the archive
     @Metatype
-    @Target({METHOD})
+    @Target({FIELD})
     @Retention(RUNTIME)
     public static @interface Green {
-        public interface $ {
+        public class $ {
 
             @Green
             @Color("green")  // two levels deep
-            public void method();
+            private Object field;
         }
     }
     
     @Metatype
-    @Target({METHOD})
+    @Target({FIELD})
     @Retention(RUNTIME)
     public static @interface DarkGreen {
-        public interface $ {
+        public class $ {
 
             @DarkGreen
             @Green
-            public void method();
+            private Object field;
         }
     }
 
     
     @Metatype
-    @Target({METHOD})
+    @Target({FIELD})
     @Retention(RUNTIME)
     public static @interface Forrest {
-        public interface $ {
+        public class $ {
 
             @Forrest
             @DarkGreen
-            public void method();
+            private Object field;
         }
     }
 
     @Metatype
-    @Target({METHOD})
+    @Target({FIELD})
     @Retention(RUNTIME)
     public static @interface Chicken {
-        public interface $ {
+        public class $ {
 
             @Chicken
             @Color("chicken")
             @Egg
-            public void method();
+            private Object field;
         }
     }
 
     @Metatype
-    @Target({METHOD})
+    @Target({FIELD})
     @Retention(RUNTIME)
     public static @interface Egg {
-        public interface $ {
+        public class $ {
 
             @Egg
             @Color("egg")
             @Chicken
-            public void method();
+            private Object field;
         }
     }
 
     public static class Square {
 
         @Red // -> @Color
-        public void square(String s, int i){}
+        private Object square;
     }
 
     public static class Circle {
 
         @Red // will be covered up by @Color
         @Color("white")
-        public void circle(int i){}
+        private Object circle;
     }
 
     public static class Triangle {
 
         @Crimson // -> @Red -> @Color
-        public void triangle(boolean... b){}
+        private Object triangle;
     }
 
     public static class Oval {
 
         @Forrest // -> @Green -> @Color
-        public void oval(boolean... b){}
+        private Object oval;
     }
 
     // always good to have a fake in there
     public static class None {
 
-        public void none(List<String> l){}
+        private Object none;
     }
 
     public static class Store {
 
         @Egg
-        public void store(){}
+        private Object store;
 
     }
 
     public static class Farm {
 
         @Chicken
-        public void farm(){}
+        private Object farm;
 
     }
 



Mime
View raw message