geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1212074 - in /geronimo/xbean/trunk/xbean-finder/src: main/java/org/apache/xbean/finder/ test/java/org/apache/xbean/finder/
Date Thu, 08 Dec 2011 19:58:19 GMT
Author: dblevins
Date: Thu Dec  8 19:58:19 2011
New Revision: 1212074

URL: http://svn.apache.org/viewvc?rev=1212074&view=rev
Log:
XBEAN-197: Alternate annotations can serve as @Metatype
XBEAN-196: Meta Annotation Support for Method and Constructor Parameters

Added:
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorParametersTest.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorTest.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodParametersTest.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/RootMetaAnnotatedClassTest.java
      - copied, changed from r1211606, geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java
Modified:
    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/MetaAnnotatedClass.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedConstructor.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedField.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedMethod.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedObject.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotation.java

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=1212074&r1=1212073&r2=1212074&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 Thu Dec  8 19:58:19 2011
@@ -30,7 +30,6 @@ import org.objectweb.asm.FieldVisitor;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Type;
 import org.objectweb.asm.commons.EmptyVisitor;
-import org.objectweb.asm.signature.SignatureReader;
 import org.objectweb.asm.signature.SignatureVisitor;
 
 import java.io.IOException;
@@ -139,13 +138,24 @@ public class AnnotationFinder implements
     private void resolveAnnotations(List<String> scanned) {
 
         // Get a list of the annotations that exist before we start
-        List<String> annotations = new ArrayList<String>(annotated.keySet());
+        final List<String> annotations = new ArrayList<String>(annotated.keySet());
 
         for (String annotation : annotations) {
             if (scanned.contains(annotation)) continue;
             readClassDef(annotation);
         }
 
+//        for (ClassInfo classInfo : classInfos.values()) {
+//            for (AnnotationInfo annotationInfo : classInfo.getAnnotations()) {
+//                for (AnnotationInfo info : annotationInfo.getAnnotations()) {
+//                    final String annotation = info.getName();
+//
+//                    if (hasName(annotation, "Metaroot") && !scanned.contains(annotation)) {
+//                        readClassDef(annotation);
+//                    }
+//                }
+//            }
+//        }
         for (ClassInfo classInfo : classInfos.values()) {
             if (isMetaRoot(classInfo)) {
                 try {
@@ -172,8 +182,22 @@ public class AnnotationFinder implements
     private boolean isMetaRoot(ClassInfo classInfo) {
         if (!classInfo.isAnnotation()) return false;
 
-        String name = classInfo.getName();
-        if (!name.equals("Metatype") && !name.endsWith(".Metatype") && !name.endsWith("$Metatype")) return false;
+        if (isSelfAnnotated(classInfo, "Metatype")) return true;
+
+        for (AnnotationInfo annotationInfo : classInfo.getAnnotations()) {
+            final ClassInfo annotation = classInfos.get(annotationInfo.getName());
+            if (annotation == null) return false;
+            if (isSelfAnnotated(annotation, "Metaroot")) return true;
+        }
+
+        return false;
+    }
+
+    private boolean isSelfAnnotated(ClassInfo classInfo, String metatype) {
+        if (!classInfo.isAnnotation()) return false;
+
+        final String name = classInfo.getName();
+        if (!hasName(name, metatype)) return false;
 
         for (AnnotationInfo info : classInfo.getAnnotations()) {
             if (info.getName().equals(name)) return true;
@@ -182,6 +206,10 @@ public class AnnotationFinder implements
         return true;
     }
 
+    private boolean hasName(String className, String simpleName) {
+        return className.equals(simpleName) || className.endsWith("." + simpleName) || className.endsWith("$" + simpleName);
+    }
+
     private void linkParent(ClassInfo classInfo) {
         if (classInfo.superType == null) return;
         if (classInfo.superType.equals("java.lang.Object")) return;

Modified: 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=1212074&r1=1212073&r2=1212074&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedClass.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedClass.java Thu Dec  8 19:58:19 2011
@@ -32,7 +32,7 @@ import java.security.ProtectionDomain;
 public class MetaAnnotatedClass<T> extends MetaAnnotatedObject<Class<T>> {
 
     public MetaAnnotatedClass(Class<T> clazz) {
-        super(clazz, unroll(clazz, clazz));
+        super(clazz, unroll(clazz));
     }
 
     public Annotation[] getDeclaredAnnotations() {
@@ -257,19 +257,19 @@ public class MetaAnnotatedClass<T> exten
             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);
@@ -281,7 +281,7 @@ public class MetaAnnotatedClass<T> exten
             b[i] = to(a[i]);
         }
         return b;
-    } 
+    }
 
     private MetaAnnotatedField[] to(Field[] a) {
         MetaAnnotatedField[] b = new MetaAnnotatedField[a.length];
@@ -289,10 +289,10 @@ public class MetaAnnotatedClass<T> exten
             b[i] = new MetaAnnotatedField(a[i]);
         }
         return b;
-    } 
+    }
 
     private MetaAnnotatedField to(Field field) {
         return new MetaAnnotatedField(field);
     }
-    
-}
+
+}
\ No newline at end of file

Modified: 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=1212074&r1=1212073&r2=1212074&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedConstructor.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedConstructor.java Thu Dec  8 19:58:19 2011
@@ -24,8 +24,11 @@ import java.lang.reflect.Constructor;
  */
 public class MetaAnnotatedConstructor<T> extends MetaAnnotatedObject<Constructor<T>> implements AnnotatedMethod<Constructor<T>> {
 
+    private Annotation[][] parameterAnnotations;
+
     public MetaAnnotatedConstructor(Constructor<T> target) {
-        super(target, unroll(target.getDeclaringClass(), target));
+        super(target, unroll(target));
+        this.parameterAnnotations = unrollParameters(target.getParameterAnnotations());
     }
 
     public Annotation[] getDeclaredAnnotations() {
@@ -33,7 +36,7 @@ public class MetaAnnotatedConstructor<T>
     }
 
     public Annotation[][] getParameterAnnotations() {
-        return get().getParameterAnnotations();
+        return parameterAnnotations;
     }
 
     public Class<?> getDeclaringClass() {

Modified: 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=1212074&r1=1212073&r2=1212074&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedField.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedField.java Thu Dec  8 19:58:19 2011
@@ -25,7 +25,7 @@ import java.lang.reflect.Field;
 public class MetaAnnotatedField extends MetaAnnotatedObject<Field> implements AnnotatedMember<Field> {
 
     public MetaAnnotatedField(Field field) {
-        super(field, unroll(field.getDeclaringClass(), field));
+        super(field, unroll(field));
     }
 
     public Annotation[] getDeclaredAnnotations() {
@@ -47,4 +47,5 @@ public class MetaAnnotatedField extends 
     public boolean isSynthetic() {
         return get().isSynthetic();
     }
+
 }

Modified: 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=1212074&r1=1212073&r2=1212074&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedMethod.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedMethod.java Thu Dec  8 19:58:19 2011
@@ -24,8 +24,12 @@ import java.lang.reflect.Method;
 */
 public class MetaAnnotatedMethod extends MetaAnnotatedObject<Method> implements AnnotatedMethod<Method> {
 
+    private final Annotation[][] parameterAnnotations;
+
     public MetaAnnotatedMethod(Method method) {
-        super(method, unroll(method.getDeclaringClass(), method));
+        super(method, unroll(method));
+
+        this.parameterAnnotations = unrollParameters(method.getParameterAnnotations());
     }
 
     public Annotation[] getDeclaredAnnotations() {
@@ -33,7 +37,7 @@ public class MetaAnnotatedMethod extends
     }
 
     public Annotation[][] getParameterAnnotations() {
-        return target.getParameterAnnotations();
+        return parameterAnnotations;
     }
 
     public Class<?> getDeclaringClass() {
@@ -75,8 +79,4 @@ public class MetaAnnotatedMethod extends
     public boolean isSynthetic() {
         return target.isSynthetic();
     }
-
-
-
-
-}
+}
\ No newline at end of file

Modified: 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=1212074&r1=1212073&r2=1212074&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedObject.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/MetaAnnotatedObject.java Thu Dec  8 19:58:19 2011
@@ -18,6 +18,7 @@ package org.apache.xbean.finder;
 
 import java.lang.annotation.Annotation;
 import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 import java.lang.reflect.AnnotatedElement;
@@ -87,7 +88,7 @@ public abstract class MetaAnnotatedObjec
         return get().toString();
     }
 
-    
+
     private static void unroll(Class<? extends Annotation> clazz, int depth, Map<Class<? extends Annotation>, MetaAnnotation<?>> found) {
         if (!isMetaAnnotation(clazz)) return;
 
@@ -102,7 +103,7 @@ public abstract class MetaAnnotatedObjec
 
                     // OVERWRITE
 
-                    found.put(type, new MetaAnnotation(annotation, depth, clazz));
+                    found.put(type, new MetaAnnotation(annotation, depth));
 
                     unroll(type, depth + 1, found);
 
@@ -117,7 +118,7 @@ public abstract class MetaAnnotatedObjec
                     // CONFLICT
 
                     // They are the same depth and therefore conflicting
-                    existing.getConflicts().add(new MetaAnnotation(annotation, depth, clazz));
+                    existing.getConflicts().add(new MetaAnnotation(annotation, depth));
 
                 }
 
@@ -125,7 +126,7 @@ public abstract class MetaAnnotatedObjec
 
                 // NEW
 
-                found.put(type, new MetaAnnotation(annotation, depth, clazz));
+                found.put(type, new MetaAnnotation(annotation, depth));
 
                 unroll(type, depth + 1, found);
 
@@ -219,21 +220,63 @@ public abstract class MetaAnnotatedObjec
     }
 
     private static boolean isMetatypeAnnotation(Class<? extends Annotation> type) {
-        return type.getSimpleName().equals("Metatype") && type.isAnnotationPresent(type);
+        if (isSelfAnnotated(type, "Metatype")) return true;
+
+        for (Annotation annotation : type.getAnnotations()) {
+            if (isSelfAnnotated(annotation.annotationType(), "Metaroot")) return true;
+        }
+
+        return false;
+    }
+
+    private static boolean isSelfAnnotated(Class<? extends Annotation> type, String name) {
+        return type.isAnnotationPresent(type) && type.getSimpleName().equals(name) && validTarget(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<?>>();
+    private static boolean validTarget(Class<? extends Annotation> type) {
+        final Target target = type.getAnnotation(Target.class);
 
-        for (Annotation annotation : element.getDeclaredAnnotations()) {
+        if (target == null) return false;
 
-            map.put(annotation.annotationType(), new MetaAnnotation(annotation, 0, declaringClass));
+        final ElementType[] targets = target.value();
+
+        return targets.length == 1 && targets[0] == ElementType.ANNOTATION_TYPE;
+    }
+
+    protected static Map<Class<? extends Annotation>, MetaAnnotation<?>> unroll(AnnotatedElement element) {
+        return unroll(element.getDeclaredAnnotations());
+    }
+
+    protected static Map<Class<? extends Annotation>, MetaAnnotation<?>> unroll(Annotation[] annotations) {
+        final Map<Class<? extends Annotation>, MetaAnnotation<?>> map = new HashMap<Class<? extends Annotation>, MetaAnnotation<?>>();
+
+        for (Annotation annotation : annotations) {
+
+            map.put(annotation.annotationType(), new MetaAnnotation(annotation, 0));
 
             unroll(annotation.annotationType(), 1, map);
 
         }
-        
+
         return map;
     }
+
+    protected Annotation[][] unrollParameters(Annotation[][] parameterAnnotations) {
+        final Annotation[][] unrolledParameters = new Annotation[parameterAnnotations.length][];
+
+        int i = 0;
+        for (Annotation[] annotations : parameterAnnotations) {
+            final Map<Class<? extends Annotation>, MetaAnnotation<?>> map = unroll(annotations);
+
+            int j = 0;
+
+            final Annotation[] unrolled = new Annotation[map.size()];
+            for (MetaAnnotation<?> metaAnnotation : map.values()) {
+                unrolled[j++] = metaAnnotation.get();
+            }
+
+            unrolledParameters[i++] = unrolled;
+        }
+        return unrolledParameters;
+    }
 }

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=1212074&r1=1212073&r2=1212074&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 Thu Dec  8 19:58:19 2011
@@ -24,16 +24,14 @@ 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) {
+    MetaAnnotation(T annotation, int depth) {
         this.annotation = annotation;
         this.depth = depth;
-        this.declaringClass = declaringClass;
     }
 
     public T get() {
@@ -44,10 +42,6 @@ public class MetaAnnotation<T extends An
         return depth;
     }
 
-    public Class<?> getDeclaringClass() {
-        return declaringClass;
-    }
-
     public List<MetaAnnotation<T>> getConflicts() {
         return conflicts;
     }

Added: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorParametersTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorParametersTest.java?rev=1212074&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorParametersTest.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorParametersTest.java Thu Dec  8 19:58:19 2011
@@ -0,0 +1,294 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MetaAnnotatedConstructorParametersTest extends TestCase {
+
+    public void test() throws Exception {
+
+        final Class<?>[] classes = new Class[]{Square.class, Circle.class, Triangle.class, Oval.class, Store.class, Farm.class, None.class};
+
+        final Map<String, Annotated<Constructor>> map = new HashMap<String, Annotated<Constructor>>();
+
+        for (Class<?> clazz : classes) {
+            final MetaAnnotatedClass<?> annotatedClass = new MetaAnnotatedClass(clazz);
+
+            for (MetaAnnotatedConstructor method : annotatedClass.getConstructors()) {
+                map.put(annotatedClass.getSimpleName().toLowerCase(), method);
+            }
+        }
+
+        // Check the positive scenarios
+        {
+            Annotation[] annotations = getAnnotations(map, "circle");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Red.class, annotations));
+
+            assertEquals("white", get(Color.class, annotations).value());
+
+            assertEquals(2, annotations.length);
+        }
+
+        {
+            Annotation[] annotations = getAnnotations(map, "square");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Red.class, annotations));
+
+            assertEquals("red", get(Color.class, annotations).value());
+
+            assertEquals(2, annotations.length);
+        }
+
+        {
+            Annotation[] annotations = getAnnotations(map, "triangle");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Red.class, annotations));
+            assertTrue(contains(Crimson.class, annotations));
+
+            assertEquals("red", get(Color.class, annotations).value());
+
+            assertEquals(3, annotations.length);
+        }
+
+
+        { // Circular - Egg wins
+            Annotation[] annotations = getAnnotations(map, "store");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Egg.class, annotations));
+            assertTrue(contains(Chicken.class, annotations));
+
+            assertEquals("egg", get(Color.class, annotations).value());
+
+            assertEquals(3, annotations.length);
+        }
+
+
+        { // Circular - Chicken wins
+            Annotation[] annotations = getAnnotations(map, "farm");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Egg.class, annotations));
+            assertTrue(contains(Chicken.class, annotations));
+
+            assertEquals("chicken", get(Color.class, annotations).value());
+
+            assertEquals(3, annotations.length);
+        }
+
+    }
+
+    private Annotation[] getAnnotations(Map<String, Annotated<Constructor>> map, String key) {
+        final MetaAnnotatedConstructor constructor = (MetaAnnotatedConstructor) map.get(key);
+
+        assertNotNull(constructor);
+
+        return constructor.getParameterAnnotations()[0];
+    }
+
+    public <T extends Annotation> T get(Class<T> type, Annotation[] annotations) {
+        for (Annotation annotation : annotations) {
+            if (annotation.annotationType() == type) return (T) annotation;
+        }
+        return null;
+    }
+
+    private boolean contains(Class<? extends Annotation> type, Annotation[] annotations) {
+        return get(type, annotations) != null;
+    }
+
+    // 100% your own annotations, even the @Metatype annotation
+    // Any annotation called @Metatype and annotated with itself works
+    @Metatype
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ANNOTATION_TYPE)
+    public @interface Metatype {
+    }
+
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Color {
+        String value() default "";
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Red {
+        public interface $ {
+
+            // one level deep
+            public void method(
+                    @Red
+                    @Color("red")
+                    Object object);
+        }
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Crimson {
+        public interface $ {
+
+            // two levels deep
+            public void method(
+                    @Crimson
+                    @Red
+                    Object object);
+        }
+    }
+
+    // Green is intentionally not used in the classes
+    // passed directly to the finder to ensure that
+    // the finder is capable of following the path to
+    // the root annotation even when some of the
+    // annotations in the path are not strictly part
+    // of the archive
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Green {
+        public interface $ {
+
+            // two levels deep
+            public void method(
+                    @Green
+                    @Color("green")
+                    Object object);
+        }
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface DarkGreen {
+        public interface $ {
+
+            public void method(
+                    @DarkGreen
+                    @Green
+                    Object object);
+        }
+    }
+
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Forrest {
+        public interface $ {
+
+            public void method(
+                    @Forrest
+                    @DarkGreen
+                    Object object);
+        }
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Chicken {
+        public interface $ {
+
+            public void method(
+                    @Chicken
+                    @Color("chicken")
+                    @Egg
+                    Object object);
+        }
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Egg {
+        public interface $ {
+
+            public void method(
+                    @Egg
+                    @Color("egg")
+                    @Chicken
+                    Object object);
+        }
+    }
+
+    public static class Square {
+
+        public Square(@Red Object object) {
+        }
+    }
+
+    public static class Circle {
+
+        public Circle(@Red @Color("white") Object object) {
+        }
+    }
+
+    public static class Triangle {
+
+        public Triangle(@Crimson Object object) {
+        }
+    }
+
+    public static class Oval {
+
+        public Oval(@Forrest Object object) {
+        }
+    }
+
+    // always good to have a fake in there
+    public static class None {
+
+        public None(Object object) {
+        }
+    }
+
+    public static class Store {
+
+        public Store(@Egg Object object) {
+        }
+    }
+
+    public static class Farm {
+
+        public Farm(@Chicken Object object) {
+        }
+    }
+
+}
\ No newline at end of file

Added: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorTest.java?rev=1212074&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorTest.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedConstructorTest.java Thu Dec  8 19:58:19 2011
@@ -0,0 +1,332 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Constructor;
+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.CONSTRUCTOR;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MetaAnnotatedConstructorTest extends TestCase {
+
+    public void test() throws Exception {
+
+        final Class<?>[] classes = new Class[]{Square.class, Circle.class, Triangle.class, Oval.class, Store.class, Farm.class, None.class};
+
+        final Map<String, Annotated<Constructor>> map = new HashMap<String, Annotated<Constructor>>();
+
+        for (Class<?> clazz : classes) {
+            final MetaAnnotatedClass<?> annotatedClass = new MetaAnnotatedClass(clazz);
+
+            for (MetaAnnotatedConstructor constructor : annotatedClass.getConstructors()) {
+                map.put(annotatedClass.getSimpleName().toLowerCase(), constructor);
+            }
+        }
+
+        // Check the positive scenarios
+        {
+            final java.lang.reflect.AnnotatedElement element = map.get("circle");
+            assertNotNull(element);
+
+            assertTrue(element.isAnnotationPresent(Color.class));
+            assertTrue(element.getAnnotation(Color.class) != null);
+            assertTrue(contains(Color.class, element.getDeclaredAnnotations()));
+            assertTrue(contains(Color.class, element.getAnnotations()));
+            assertEquals("white", element.getAnnotation(Color.class).value());
+
+            assertTrue(element.isAnnotationPresent(Red.class));
+            assertTrue(element.getAnnotation(Red.class) != null);
+            assertTrue(contains(Red.class, element.getDeclaredAnnotations()));
+            assertTrue(contains(Red.class, element.getAnnotations()));
+
+            assertEquals(2, element.getDeclaredAnnotations().length);
+            assertEquals(2, element.getAnnotations().length);
+        }
+
+        {
+            final java.lang.reflect.AnnotatedElement target = map.get("square");
+            assertNotNull(target);
+
+            assertTrue(target.isAnnotationPresent(Color.class));
+            assertTrue(target.getAnnotation(Color.class) != null);
+            assertTrue(!contains(Color.class, target.getDeclaredAnnotations()));
+            assertTrue(contains(Color.class, target.getAnnotations()));
+            assertEquals("red", target.getAnnotation(Color.class).value());
+
+            assertTrue(target.isAnnotationPresent(Red.class));
+            assertTrue(target.getAnnotation(Red.class) != null);
+            assertTrue(contains(Red.class, target.getDeclaredAnnotations()));
+            assertTrue(contains(Red.class, target.getAnnotations()));
+
+            assertEquals(1, target.getDeclaredAnnotations().length);
+            assertEquals(2, target.getAnnotations().length);
+        }
+
+        {
+            final java.lang.reflect.AnnotatedElement annotated = map.get("triangle");
+            assertNotNull(annotated);
+
+            assertTrue(annotated.isAnnotationPresent(Color.class));
+            assertTrue(annotated.getAnnotation(Color.class) != null);
+            assertTrue(!contains(Color.class, annotated.getDeclaredAnnotations()));
+            assertTrue(contains(Color.class, annotated.getAnnotations()));
+            assertEquals("red", annotated.getAnnotation(Color.class).value());
+
+            assertTrue(annotated.isAnnotationPresent(Red.class));
+            assertTrue(annotated.getAnnotation(Red.class) != null);
+            assertTrue(!contains(Red.class, annotated.getDeclaredAnnotations()));
+            assertTrue(contains(Red.class, annotated.getAnnotations()));
+
+            assertTrue(annotated.isAnnotationPresent(Crimson.class));
+            assertTrue(annotated.getAnnotation(Crimson.class) != null);
+            assertTrue(contains(Crimson.class, annotated.getDeclaredAnnotations()));
+            assertTrue(contains(Crimson.class, annotated.getAnnotations()));
+
+            assertEquals(1, annotated.getDeclaredAnnotations().length);
+            assertEquals(3, annotated.getAnnotations().length);
+        }
+
+        { // Circular - Egg wins
+            final java.lang.reflect.AnnotatedElement annotated = map.get("store");
+            assertNotNull(annotated);
+
+            assertTrue(annotated.isAnnotationPresent(Color.class));
+            assertTrue(annotated.getAnnotation(Color.class) != null);
+            assertTrue(!contains(Color.class, annotated.getDeclaredAnnotations()));
+            assertTrue(contains(Color.class, annotated.getAnnotations()));
+            assertEquals("egg", annotated.getAnnotation(Color.class).value());
+
+            assertTrue(annotated.isAnnotationPresent(Egg.class));
+            assertTrue(annotated.getAnnotation(Egg.class) != null);
+            assertTrue(contains(Egg.class, annotated.getDeclaredAnnotations()));
+            assertTrue(contains(Egg.class, annotated.getAnnotations()));
+
+            assertTrue(annotated.isAnnotationPresent(Chicken.class));
+            assertTrue(annotated.getAnnotation(Chicken.class) != null);
+            assertTrue(!contains(Chicken.class, annotated.getDeclaredAnnotations()));
+            assertTrue(contains(Chicken.class, annotated.getAnnotations()));
+
+            assertEquals(1, annotated.getDeclaredAnnotations().length);
+            assertEquals(3, annotated.getAnnotations().length);
+        }
+
+        { // Circular - Chicken wins
+            final java.lang.reflect.AnnotatedElement annotated = map.get("farm");
+            assertNotNull(annotated);
+
+            assertTrue(annotated.isAnnotationPresent(Color.class));
+            assertTrue(annotated.getAnnotation(Color.class) != null);
+            assertTrue(!contains(Color.class, annotated.getDeclaredAnnotations()));
+            assertTrue(contains(Color.class, annotated.getAnnotations()));
+            assertEquals("chicken", annotated.getAnnotation(Color.class).value());
+
+            assertTrue(annotated.isAnnotationPresent(Egg.class));
+            assertTrue(annotated.getAnnotation(Egg.class) != null);
+            assertTrue(!contains(Egg.class, annotated.getDeclaredAnnotations()));
+            assertTrue(contains(Egg.class, annotated.getAnnotations()));
+
+            assertTrue(annotated.isAnnotationPresent(Chicken.class));
+            assertTrue(annotated.getAnnotation(Chicken.class) != null);
+            assertTrue(contains(Chicken.class, annotated.getDeclaredAnnotations()));
+            assertTrue(contains(Chicken.class, annotated.getAnnotations()));
+
+            assertEquals(1, annotated.getDeclaredAnnotations().length);
+            assertEquals(3, annotated.getAnnotations().length);
+        }
+
+    }
+
+    private boolean contains(Class<? extends Annotation> type, Annotation[] annotations) {
+        for (Annotation annotation : annotations) {
+            if (type.isAssignableFrom(annotation.annotationType())) return true;
+        }
+        return false;
+    }
+
+    // 100% your own annotations, even the @Metatype annotation
+    // Any annotation called @Metatype and annotated with itself works
+    @Metatype
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ANNOTATION_TYPE)
+    public @interface Metatype {
+    }
+
+    @Target({CONSTRUCTOR})
+    @Retention(RUNTIME)
+    public static @interface Color {
+        String value() default "";
+    }
+
+    @Metatype
+    @Target({CONSTRUCTOR})
+    @Retention(RUNTIME)
+    public static @interface Red {
+        public class $ {
+
+            @Red
+            @Color("red")  // one level deep
+            public $(){}
+        }
+    }
+
+    @Metatype
+    @Target({CONSTRUCTOR})
+    @Retention(RUNTIME)
+    public static @interface Crimson {
+        public class $ {
+
+            @Crimson
+            @Red  // two levels deep
+            public $(){}
+        }
+    }
+
+    // Green is intentionally not used in the classes
+    // passed directly to the finder to ensure that
+    // the finder is capable of following the path to
+    // the root annotation even when some of the
+    // annotations in the path are not strictly part
+    // of the archive
+    @Metatype
+    @Target({CONSTRUCTOR})
+    @Retention(RUNTIME)
+    public static @interface Green {
+        public class $ {
+
+            @Green
+            @Color("green")  // two levels deep
+            public $(){}
+        }
+    }
+
+    @Metatype
+    @Target({CONSTRUCTOR})
+    @Retention(RUNTIME)
+    public static @interface DarkGreen {
+        public class $ {
+
+            @DarkGreen
+            @Green
+            public $(){}
+        }
+    }
+
+
+    @Metatype
+    @Target({CONSTRUCTOR})
+    @Retention(RUNTIME)
+    public static @interface Forrest {
+        public class $ {
+
+            @Forrest
+            @DarkGreen
+            public $(){}
+        }
+    }
+
+    @Metatype
+    @Target({CONSTRUCTOR})
+    @Retention(RUNTIME)
+    public static @interface Chicken {
+        public class $ {
+
+            @Chicken
+            @Color("chicken")
+            @Egg
+            public $(){}
+        }
+    }
+
+    @Metatype
+    @Target({CONSTRUCTOR})
+    @Retention(RUNTIME)
+    public static @interface Egg {
+        public class $ {
+
+            @Egg
+            @Color("egg")
+            @Chicken
+            public $(){}
+        }
+    }
+
+    public static class Square {
+
+        @Red // -> @Color
+        public Square(String s, int i) {
+        }
+    }
+
+    public static class Circle {
+
+        @Red // will be covered up by @Color
+        @Color("white")
+        public Circle(int i) {
+        }
+    }
+
+    public static class Triangle {
+
+        @Crimson // -> @Red -> @Color
+        public Triangle(boolean... b) {
+        }
+    }
+
+    public static class Oval {
+
+        @Forrest // -> @Green -> @Color
+        public Oval(boolean... b) {
+        }
+    }
+
+    // always good to have a fake in there
+    public static class None {
+
+        public None(List<String> l) {
+        }
+    }
+
+    public static class Store {
+
+        @Egg
+        public Store() {
+        }
+
+    }
+
+    public static class Farm {
+
+        @Chicken
+        public Farm() {
+        }
+
+    }
+
+}
\ No newline at end of file

Added: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodParametersTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodParametersTest.java?rev=1212074&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodParametersTest.java (added)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedMethodParametersTest.java Thu Dec  8 19:58:19 2011
@@ -0,0 +1,298 @@
+/*
+ * 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 junit.framework.TestCase;
+
+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.util.HashMap;
+import java.util.Map;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MetaAnnotatedMethodParametersTest extends TestCase {
+
+    public void test() throws Exception {
+
+        final Class<?>[] classes = new Class[]{Square.class, Circle.class, Triangle.class, Oval.class, Store.class, Farm.class, None.class};
+
+        final Map<String, Annotated<Method>> map = new HashMap<String, Annotated<Method>>();
+
+        for (Class<?> clazz : classes) {
+            final MetaAnnotatedClass<?> annotatedClass = new MetaAnnotatedClass(clazz);
+
+            for (MetaAnnotatedMethod method : annotatedClass.getMethods()) {
+                map.put(method.getName(), method);
+            }
+        }
+
+        // Check the positive scenarios
+        {
+            Annotation[] annotations = getAnnotations(map, "circle");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Red.class, annotations));
+
+            assertEquals("white", get(Color.class, annotations).value());
+
+            assertEquals(2, annotations.length);
+        }
+
+        {
+            Annotation[] annotations = getAnnotations(map, "square");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Red.class, annotations));
+
+            assertEquals("red", get(Color.class, annotations).value());
+
+            assertEquals(2, annotations.length);
+        }
+
+        {
+            Annotation[] annotations = getAnnotations(map, "triangle");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Red.class, annotations));
+            assertTrue(contains(Crimson.class, annotations));
+
+            assertEquals("red", get(Color.class, annotations).value());
+
+            assertEquals(3, annotations.length);
+        }
+
+
+        { // Circular - Egg wins
+            Annotation[] annotations = getAnnotations(map, "store");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Egg.class, annotations));
+            assertTrue(contains(Chicken.class, annotations));
+
+            assertEquals("egg", get(Color.class, annotations).value());
+
+            assertEquals(3, annotations.length);
+        }
+
+
+        { // Circular - Chicken wins
+            Annotation[] annotations = getAnnotations(map, "farm");
+
+            assertTrue(contains(Color.class, annotations));
+            assertTrue(contains(Egg.class, annotations));
+            assertTrue(contains(Chicken.class, annotations));
+
+            assertEquals("chicken", get(Color.class, annotations).value());
+
+            assertEquals(3, annotations.length);
+        }
+
+    }
+
+    private Annotation[] getAnnotations(Map<String, Annotated<Method>> map, String key) {
+        final MetaAnnotatedMethod method = (MetaAnnotatedMethod) map.get(key);
+
+        assertNotNull(method);
+
+        return method.getParameterAnnotations()[0];
+    }
+
+    public <T extends Annotation> T get(Class<T> type, Annotation[] annotations) {
+        for (Annotation annotation : annotations) {
+            if (annotation.annotationType() == type) return (T) annotation;
+        }
+        return null;
+    }
+
+    private boolean contains(Class<? extends Annotation> type, Annotation[] annotations) {
+        return get(type, annotations) != null;
+    }
+
+    // 100% your own annotations, even the @Metatype annotation
+    // Any annotation called @Metatype and annotated with itself works
+    @Metatype
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ANNOTATION_TYPE)
+    public @interface Metatype {
+    }
+
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Color {
+        String value() default "";
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Red {
+        public interface $ {
+
+            // one level deep
+            public void method(
+                    @Red
+                    @Color("red")
+                    Object object);
+        }
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Crimson {
+        public interface $ {
+
+            // two levels deep
+            public void method(
+                    @Crimson
+                    @Red
+                    Object object);
+        }
+    }
+
+    // Green is intentionally not used in the classes
+    // passed directly to the finder to ensure that
+    // the finder is capable of following the path to
+    // the root annotation even when some of the
+    // annotations in the path are not strictly part
+    // of the archive
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Green {
+        public interface $ {
+
+            // two levels deep
+            public void method(
+                    @Green
+                    @Color("green")
+                    Object object);
+        }
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface DarkGreen {
+        public interface $ {
+
+            public void method(
+                    @DarkGreen
+                    @Green
+                    Object object);
+        }
+    }
+
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Forrest {
+        public interface $ {
+
+            public void method(
+                    @Forrest
+                    @DarkGreen
+                    Object object);
+        }
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Chicken {
+        public interface $ {
+
+            public void method(
+                    @Chicken
+                    @Color("chicken")
+                    @Egg
+                    Object object);
+        }
+    }
+
+    @Metatype
+    @Target({PARAMETER})
+    @Retention(RUNTIME)
+    public static @interface Egg {
+        public interface $ {
+
+            public void method(
+                    @Egg
+                    @Color("egg")
+                    @Chicken
+                    Object object);
+        }
+    }
+
+    public static class Square {
+
+        public void square(@Red Object object) {
+        }
+    }
+
+    public static class Circle {
+
+        public void circle(@Red @Color("white") Object object) {
+        }
+    }
+
+    public static class Triangle {
+
+        public void triangle(@Crimson Object object) {
+        }
+    }
+
+    public static class Oval {
+
+        public void oval(@Forrest Object object) {
+        }
+    }
+
+    // always good to have a fake in there
+    public static class None {
+
+        public void none(Object object) {
+        }
+    }
+
+    public static class Store {
+
+
+        public void store(@Egg Object object) {
+        }
+
+    }
+
+    public static class Farm {
+
+
+        public void farm(@Chicken Object object) {
+        }
+
+    }
+
+}
\ No newline at end of file

Copied: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/RootMetaAnnotatedClassTest.java (from r1211606, 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/RootMetaAnnotatedClassTest.java?p2=geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/RootMetaAnnotatedClassTest.java&p1=geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java&r1=1211606&r2=1212074&rev=1212074&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/RootMetaAnnotatedClassTest.java Thu Dec  8 19:58:19 2011
@@ -40,9 +40,12 @@ import static java.lang.annotation.Reten
  *
  * @version $Rev$ $Date$
  */
-public class MetaAnnotatedClassTest extends TestCase {
+public class RootMetaAnnotatedClassTest extends TestCase {
 
     public void test() throws Exception {
+
+    }
+    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<?>, Annotated<Class<?>>> map = new HashMap<Class<?>, Annotated<Class<?>>>();
@@ -181,10 +184,16 @@ public class MetaAnnotatedClassTest exte
 
     // 100% your own annotations, even the @Metatype annotation
     // Any annotation called @Metatype and annotated with itself works
-    @Metatype
+    @Metaroot
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ANNOTATION_TYPE)
+    public @interface Metaroot {
+    }
+
+    @Metaroot
     @Retention(RetentionPolicy.RUNTIME)
     @Target(ANNOTATION_TYPE)
-    public @interface Metatype {
+    public @interface Stereotype {
     }
 
     @Target(value = {TYPE})
@@ -193,7 +202,7 @@ public class MetaAnnotatedClassTest exte
         String value() default "";
     }
 
-    @Metatype
+    @Stereotype
     @Color("red")
     // one level deep
     @Target(value = {TYPE})
@@ -201,7 +210,7 @@ public class MetaAnnotatedClassTest exte
     public static @interface Red {
     }
 
-    @Metatype
+    @Stereotype
     @Red
     // two levels deep
     @Target(value = {TYPE})
@@ -215,7 +224,7 @@ public class MetaAnnotatedClassTest exte
     public static @interface NotMeta {
     }
 
-    @Metatype
+    @Stereotype
     @Color("egg")
     @Chicken
     // Circular
@@ -225,7 +234,7 @@ public class MetaAnnotatedClassTest exte
     }
 
 
-    @Metatype
+    @Stereotype
     @Color("chicken")
     @Egg
     // Circular



Mime
View raw message