geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1086845 - in /geronimo/xbean/trunk/xbean-finder/src: main/java/org/apache/xbean/finder/AnnotationFinder.java main/java/org/apache/xbean/finder/MetaAnnotatedObject.java test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java
Date Wed, 30 Mar 2011 05:39:12 GMT
Author: dblevins
Date: Wed Mar 30 05:39:12 2011
New Revision: 1086845

URL: http://svn.apache.org/viewvc?rev=1086845&view=rev
Log:
XBEAN-165: Meta Annotation Support
Don't return the meta-annotation classes just like we don't return meta-annotation fields
or methods in	findMetaAnnotatedFields or findMetaAnnotatedMethods

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/MetaAnnotatedObject.java
    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
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java?rev=1086845&r1=1086844&r2=1086845&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
Wed Mar 30 05:39:12 2011
@@ -317,12 +317,27 @@ public class AnnotationFinder implements
         List<Annotated<Class<?>>> list = new ArrayList<Annotated<Class<?>>>();
 
         for (Class<?> clazz : classes) {
+            if (Annotation.class.isAssignableFrom(clazz) && isMetaAnnotation((Class<?
extends Annotation>) clazz)) continue;
             list.add(new MetaAnnotatedClass(clazz));
         }
 
         return list;
     }
 
+    private static boolean isMetaAnnotation(Class<? extends Annotation> clazz) {
+        for (Annotation annotation : clazz.getDeclaredAnnotations()) {
+            if (isMetatypeAnnotation(annotation.annotationType())) return true;
+        }
+
+        return false;
+    }
+
+    private static boolean isMetatypeAnnotation(Class<? extends Annotation> type) {
+        return type.getSimpleName().equals("Metatype") && type.isAnnotationPresent(type);
+    }
+
+
+
     private Set<Class<?>> findMetaAnnotatedClasses(Class<? extends Annotation>
annotation, Set<Class<?>> classes) {
         List<Info> infos = getAnnotationInfos(annotation.getName());
         for (Info info : infos) {

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=1086845&r1=1086844&r2=1086845&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
Wed Mar 30 05:39:12 2011
@@ -138,14 +138,6 @@ public abstract class MetaAnnotatedObjec
         }
     }
 
-    private static boolean isMetaAnnotation(Class<? extends Annotation> clazz) {
-        for (Annotation annotation : clazz.getDeclaredAnnotations()) {
-            if (isMetatypeAnnotation(annotation.annotationType())) return true;
-        }
-
-        return false;
-    }
-
     private static Collection<Annotation> getDeclaredMetaAnnotations(Class<? extends
Annotation> clazz) {
 
         Map<Class, Annotation> map = new HashMap<Class, Annotation>();
@@ -223,6 +215,14 @@ public abstract class MetaAnnotatedObjec
         return null;
     }
 
+    private static boolean isMetaAnnotation(Class<? extends Annotation> clazz) {
+        for (Annotation annotation : clazz.getDeclaredAnnotations()) {
+            if (isMetatypeAnnotation(annotation.annotationType())) return true;
+        }
+
+        return false;
+    }
+
     private static boolean isMetatypeAnnotation(Class<? extends Annotation> type) {
         return type.getSimpleName().equals("Metatype") && type.isAnnotationPresent(type);
     }

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java?rev=1086845&r1=1086844&r2=1086845&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/MetaAnnotatedClassTest.java
Wed Mar 30 05:39:12 2011
@@ -53,6 +53,10 @@ public class MetaAnnotatedClassTest exte
             assertNull("no duplicates allowed", oldValue);
         }
 
+        // MetaAnnotation classes themselves are not included
+        assertNull(map.get(Red.class));
+        assertNull(map.get(Crimson.class));
+
         // Check the negative scenario
         assertFalse(map.containsKey(None.class));
 



Mime
View raw message