[jboss-cvs] JBossAS SVN: r93166 - in projects/annotations/trunk/core/src/main/java/org/jboss/annotations: impl and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 3 10:12:16 EDT 2009


Author: jesper.pedersen
Date: 2009-09-03 10:12:16 -0400 (Thu, 03 Sep 2009)
New Revision: 93166

Modified:
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Settings.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/SettingsImpl.java
Log:
[JBANN-13] Add configuration to the AnnotationScanner (Part 2)

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Settings.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Settings.java	2009-09-03 14:07:33 UTC (rev 93165)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/Settings.java	2009-09-03 14:12:16 UTC (rev 93166)
@@ -77,4 +77,32 @@
     * @return The visibility
     */
    public Visibility getMethodVisibility();
+
+   /**
+    * Fold annotations on to classes that extends/implements the class
+    * where the annotation is located - default: true
+    * @param fold True if folding should be performed; otherwise false
+    * @return The settings
+    */
+   public Settings foldAnnotations(boolean fold);
+
+   /**
+    * Is folding annotations enabled ?
+    * @return True if enabled; otherwise false
+    */
+   public boolean isFoldAnnotations();
+
+   /**
+    * Include abstract classes in the result of hasAnnotation/getAnnotation -
+    * default: false
+    * @param include True if abstract classes should be included; otherwise false
+    * @return The settings
+    */
+   public Settings includeAbstract(boolean include);
+
+   /**
+    * Is abstrac classes included in the result of hasAnnotation/getAnnotation
+    * @return True if included; otherwise false
+    */
+   public boolean isIncludeAbstract();
 }

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java	2009-09-03 14:07:33 UTC (rev 93165)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java	2009-09-03 14:12:16 UTC (rev 93166)
@@ -213,14 +213,17 @@
 
          if (as != null && as.size() > 0)
          {
-            if (!ci.isAbstract() || ci.isInterface())
+            if (!ci.isAbstract() || ci.isInterface() || settings.isIncludeAbstract())
             {
                l.addAll(as);
             }
 
-            Collection<Annotation> childAnnotations = foldAnnotations(as, ci);
-            if (childAnnotations != null)
-               l.addAll(childAnnotations);
+            if (settings.isFoldAnnotations())
+            {
+               Collection<Annotation> childAnnotations = foldAnnotations(as, ci);
+               if (childAnnotations != null)
+                  l.addAll(childAnnotations);
+            }
          }
       }
 
@@ -249,7 +252,7 @@
                ClassInfo chdi = classInfo.get(childClass);
                if (chdi != null)
                {
-                  if (!chdi.isAbstract() || chdi.isInterface())
+                  if (!chdi.isAbstract() || chdi.isInterface() || settings.isIncludeAbstract())
                   {
                      for (Annotation a : annotations)
                      {
@@ -260,9 +263,12 @@
                      }
                   }
 
-                  Collection<Annotation> childAnnotations = foldAnnotations(annotations, chdi);
-                  if (childAnnotations != null)
-                     result.addAll(childAnnotations);
+                  if (settings.isFoldAnnotations())
+                  {
+                     Collection<Annotation> childAnnotations = foldAnnotations(annotations, chdi);
+                     if (childAnnotations != null)
+                        result.addAll(childAnnotations);
+                  }
                }
             }
 

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/SettingsImpl.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/SettingsImpl.java	2009-09-03 14:07:33 UTC (rev 93165)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/SettingsImpl.java	2009-09-03 14:12:16 UTC (rev 93166)
@@ -42,6 +42,8 @@
    private Visibility constructorVisibility;
    private boolean methodLevel;
    private Visibility methodVisibility;
+   private boolean foldAnnotations;
+   private boolean includeAbstract;
 
    /**
     * Constructor
@@ -71,6 +73,8 @@
       this.constructorVisibility = constructorVisibility;
       this.methodLevel = methodLevel;
       this.methodVisibility = methodVisibility;
+      this.foldAnnotations = true;
+      this.includeAbstract = false;
    }
 
    /**
@@ -144,4 +148,48 @@
    {
       return methodVisibility;
    }
+
+   /**
+    * Fold annotations on to classes that extends/implements the class
+    * where the annotation is located
+    * @param fold True if folding should be performed; otherwise false
+    * @return The settings
+    */
+   public Settings foldAnnotations(boolean fold)
+   {
+      this.foldAnnotations = fold;
+
+      return this;
+   }
+
+   /**
+    * Is folding annotations enabled ?
+    * @return True if enabled; otherwise false
+    */
+   public boolean isFoldAnnotations()
+   {
+      return foldAnnotations;
+   }
+
+   /**
+    * Include abstract classes in the result of hasAnnotation/getAnnotation -
+    * default: false
+    * @param include True if abstract classes should be included; otherwise false
+    * @return The settings
+    */
+   public Settings includeAbstract(boolean include)
+   {
+      this.includeAbstract = include;
+
+      return this;
+   }
+
+   /**
+    * Is abstrac classes included in the result of hasAnnotation/getAnnotation
+    * @return True if included; otherwise false
+    */
+   public boolean isIncludeAbstract()
+   {
+      return includeAbstract;
+   }
 }




More information about the jboss-cvs-commits mailing list