[jboss-cvs] JBossAS SVN: r95063 - in projects/annotations/trunk: core/src/main/java/org/jboss/papaki/impl and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Oct 18 04:40:19 EDT 2009


Author: alesj
Date: 2009-10-18 04:40:18 -0400 (Sun, 18 Oct 2009)
New Revision: 95063

Added:
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerCreator.java
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ScanStrategy.java
   projects/annotations/trunk/maven/release.bat
   projects/annotations/trunk/maven/snapshot.bat
Modified:
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerFactory.java
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AbstractAnnotationScanner.java
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/ConfigurationImpl.java
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javalangreflect/JavaClass.java
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistclasspool/JavassistClassPool.java
   projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistinputstream/JavassistInputStream.java
Log:
[JBANN-41, JBANN-42]; use pre-existing Configuration, add Winz release files

Added: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerCreator.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerCreator.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerCreator.java	2009-10-18 08:40:18 UTC (rev 95063)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.papaki;
+
+/**
+ * Annotation scanner creator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface AnnotationScannerCreator
+{
+   /**
+    * Verify if we can actually use AnnotationScanner created by this creator.
+    */
+   void verify();
+
+   /**
+    * Create AnnotationScanner.
+    *
+    * @param configuration the configuration
+    * @return new AnnotationScanner
+    */
+   abstract AnnotationScanner create(Configuration configuration);
+}

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerFactory.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerFactory.java	2009-10-17 14:18:07 UTC (rev 95062)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/AnnotationScannerFactory.java	2009-10-18 08:40:18 UTC (rev 95063)
@@ -22,30 +22,37 @@
 
 package org.jboss.papaki;
 
-import org.jboss.papaki.javalangreflect.JavaClass;
-import org.jboss.papaki.javassistclasspool.JavassistClassPool;
-import org.jboss.papaki.javassistinputstream.JavassistInputStream;
-
 /**
  * An annotation scanner factory
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
 public class AnnotationScannerFactory
 {
-   /** Javassist using ClassPool */
+   /**
+    * Javassist using ClassPool
+    */
    public static final int JAVASSIST_CLASS_POOL = 0;
 
-   /** Javassist using InputStream */
+   /**
+    * Javassist using InputStream
+    */
    public static final int JAVASSIST_INPUT_STREAM = 1;
 
-   /** java.lang.reflect */
+   /**
+    * java.lang.reflect
+    */
    public static final int JAVA_LANG_REFLECT = 2;
 
-   /** Default strategy */
-   private static int defaultStrategy;
+   /**
+    * Default strategy
+    */
+   private static ScanStrategy defaultStrategy;
 
-   /** Is Javassist available */
-   private static boolean haveJavassist = false;
+   /**
+    * Is Javassist available
+    */
+   static boolean haveJavassist = false;
 
    static
    {
@@ -61,11 +68,11 @@
 
       if (haveJavassist)
       {
-         defaultStrategy = JAVASSIST_INPUT_STREAM;
+         defaultStrategy = ScanStrategy.JAVASSIST_INPUT_STREAM;
       }
       else
       {
-         defaultStrategy = JAVA_LANG_REFLECT;
+         defaultStrategy = ScanStrategy.JAVA_LANG_REFLECT;
       }
    }
 
@@ -78,48 +85,51 @@
 
    /**
     * Get the default strategy for annotation scanning
+    *
     * @return An instance of the annotation scanner
     */
    public static AnnotationScanner getDefault()
    {
-      return getStrategy(defaultStrategy);
+      return getStrategy(defaultStrategy.ordinal());
    }
 
    /**
+    * Get the default strategy for annotation scanning
+    *
+    * @param configuration the configuration
+    * @return An instance of the annotation scanner
+    */
+   public static AnnotationScanner getDefault(Configuration configuration)
+   {
+      return getStrategy(defaultStrategy.ordinal(), configuration);
+   }
+
+   /**
     * Get the specified strategy for annotation scanning
+    *
     * @param strategy The strategy
     * @return An instance of the annotation scanner
     */
    public static AnnotationScanner getStrategy(int strategy)
    {
-      if (strategy < 0 || strategy > 2)
+      return getStrategy(strategy, null);
+   }
+
+   /**
+    * Get the specified strategy for annotation scanning
+    *
+    * @param strategy The strategy
+    * @param configuration the configuration
+    * @return An instance of the annotation scanner
+    */
+   public static AnnotationScanner getStrategy(int strategy, Configuration configuration)
+   {
+      ScanStrategy[] strategies = ScanStrategy.values();
+      if (strategy < 0 || strategy > strategies.length - 1)
          throw new IllegalArgumentException("Unknown strategy key");
 
-      if (strategy == JAVASSIST_CLASS_POOL)
-      {
-         if (haveJavassist)
-         {
-            return new JavassistClassPool();
-         }
-         else
-         {
-            throw new IllegalArgumentException("Javassist not available");
-         }
-      }
-      else if (strategy == JAVASSIST_INPUT_STREAM)
-      {
-         if (haveJavassist)
-         {
-            return new JavassistInputStream();
-         }
-         else
-         {
-            throw new IllegalArgumentException("Javassist not available");
-         }
-      }
-      else
-      {
-         return new JavaClass();
-      }
+      ScanStrategy ss = strategies[strategy];
+      ss.verify(); // check if we can use this strategy
+      return ss.create(configuration);
    }
 }

Added: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ScanStrategy.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ScanStrategy.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/ScanStrategy.java	2009-10-18 08:40:18 UTC (rev 95063)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.papaki;
+
+import org.jboss.papaki.javalangreflect.JavaClass;
+import org.jboss.papaki.javassistclasspool.JavassistClassPool;
+import org.jboss.papaki.javassistinputstream.JavassistInputStream;
+
+/**
+ * Scan strategy.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public enum ScanStrategy implements AnnotationScannerCreator
+{
+   /** Javassist class pool  */
+   JAVASSIST_CLASS_POOL(new JavassistClassPoolScannerCreator()),
+   /** Javassist input stream  */
+   JAVASSIST_INPUT_STREAM(new JavassistInputStreamCreator()),
+   /** Plain JDK reflect  */
+   JAVA_LANG_REFLECT(new JavaClassScannerCreator());
+
+   private AnnotationScannerCreator creator;
+
+   /**
+    * Ctor.
+    *
+    * @param creator the creator
+    */
+   ScanStrategy(AnnotationScannerCreator creator)
+   {
+      this.creator = creator;
+   }
+
+   /**
+    * Do check.
+    */
+   private static void check()
+   {
+      if (!AnnotationScannerFactory.haveJavassist)
+         throw new IllegalArgumentException("Javassist not available.");
+   }
+
+   /**
+    * Verify.
+    */
+   public void verify()
+   {
+      creator.verify();
+   }
+
+   /**
+    * Get scanner.
+    *
+    * @param configuration the configuration
+    * @return new annotation scanner
+    */
+   public AnnotationScanner create(Configuration configuration)
+   {
+      return creator.create(configuration);
+   }
+
+   /**
+    * JCPSC
+    */
+   static class JavassistClassPoolScannerCreator implements AnnotationScannerCreator
+   {
+      /**
+       * Verify.
+       */
+      public void verify()
+      {
+         check();
+      }
+
+      /**
+       * Create AnnotationScanner.
+       *
+       * @param configuration the configuration
+       * @return new JavassistCP instance
+       */
+      public AnnotationScanner create(Configuration configuration)
+      {
+         return new JavassistClassPool(configuration);
+      }
+   }
+
+   /**
+    * JISC
+    */
+   static class JavassistInputStreamCreator implements AnnotationScannerCreator
+   {
+      /**
+       * Verify.
+       */
+      public void verify()
+      {
+         check();
+      }
+
+      /**
+       * Create AnnotationScanner.
+       *
+       * @param configuration the configuration
+       * @return new JavassistIS instance
+       */
+      public AnnotationScanner create(Configuration configuration)
+      {
+         return new JavassistInputStream(configuration);
+      }
+   }
+
+   /**
+    * JCSC
+    */
+   static class JavaClassScannerCreator implements AnnotationScannerCreator
+   {
+      /**
+       * Verify.
+       */
+      public void verify()
+      {
+      }
+
+      /**
+       * Create AnnotationScanner.
+       *
+       * @param configuration the configuration
+       * @return new JavaClass instance
+       */
+      public AnnotationScanner create(Configuration configuration)
+      {
+         return new JavaClass(configuration);
+      }
+   }
+}

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AbstractAnnotationScanner.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AbstractAnnotationScanner.java	2009-10-17 14:18:07 UTC (rev 95062)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/AbstractAnnotationScanner.java	2009-10-18 08:40:18 UTC (rev 95063)
@@ -48,42 +48,61 @@
 
 /**
  * An abstract annotation scanner - base class
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
 public abstract class AbstractAnnotationScanner implements AnnotationScanner
 {
    private Logger log;
-   private boolean trace; 
+   private boolean trace;
 
-   /** Name of the binary metadata */
+   /**
+    * Name of the binary metadata
+    */
    public static final String PAPAKI_METADATA_BINARY = "papaki.ser";
 
-   /** Configuration */
+   /**
+    * Configuration
+    */
    protected Configuration configuration;
 
    /**
     * Constructor
+    *
     * @param logger The logger name
     */
    public AbstractAnnotationScanner(String logger)
    {
       log = Logger.getLogger(logger);
       trace = log.isLoggable(Level.FINEST);
-
-      configuration = new ConfigurationImpl();
    }
 
    /**
     * Configure the scanner
+    *
     * @return The configuration
     */
    public Configuration configure()
    {
+      if (configuration == null)
+         configuration = new ConfigurationImpl();
+
       return configuration;
    }
 
    /**
+    * Set configuration.
+    *
+    * @param configuration the configuration
+    */
+   protected void setConfiguration(Configuration configuration)
+   {
+      this.configuration = configuration;
+   }
+
+   /**
     * Get all the class names
+    *
     * @param urls The urls to be scanned
     * @return The names
     */
@@ -146,6 +165,7 @@
 
    /**
     * Check a JAR file for metadata
+    *
     * @param jarFile The JAR file
     * @return The annotation repository implementation; <code>null</code> if no metadata is found
     */
@@ -189,6 +209,7 @@
 
    /**
     * Check a directory for metadata
+    *
     * @param directory The directory
     * @return The annotation repository implementation; <code>null</code> if no metadata is found
     */
@@ -232,64 +253,70 @@
 
    /**
     * Include class in the scan
+    *
     * @param modifiers The modifiers
     * @return True if include; otherwise false
     */
    protected boolean includeClass(int modifiers)
    {
-      return includeVisibility(configuration.getClassVisibility(), modifiers);
+      return includeVisibility(configure().getClassVisibility(), modifiers);
    }
 
    /**
     * Include field in the scan
+    *
     * @param modifiers The modifiers
     * @return True if include; otherwise false
     */
    protected boolean includeField(int modifiers)
    {
-      return includeVisibility(configuration.getFieldVisibility(), modifiers);
+      return includeVisibility(configure().getFieldVisibility(), modifiers);
    }
 
    /**
     * Include constructor in the scan
+    *
     * @param modifiers The modifiers
     * @return True if include; otherwise false
     */
    protected boolean includeConstructor(int modifiers)
    {
-      return includeVisibility(configuration.getConstructorVisibility(), modifiers);
+      return includeVisibility(configure().getConstructorVisibility(), modifiers);
    }
 
    /**
     * Include method in the scan
+    *
     * @param modifiers The modifiers
     * @return True if include; otherwise false
     */
    protected boolean includeMethod(int modifiers)
    {
-      return includeVisibility(configuration.getMethodVisibility(), modifiers);
+      return includeVisibility(configure().getMethodVisibility(), modifiers);
    }
 
    /**
     * Get the settings for an annotation repository
+    *
     * @return The settings
     */
    protected Settings getSettings()
    {
-      return new SettingsImpl(configuration.isClassLevel(),
-                              configuration.getClassVisibility(),
-                              configuration.isFieldLevel(),
-                              configuration.getFieldVisibility(),
-                              configuration.isConstructorLevel(),
-                              configuration.getConstructorVisibility(),
-                              configuration.isMethodLevel(),
-                              configuration.getMethodVisibility(),
-                              configuration.isParameterLevel());
+      return new SettingsImpl(configure().isClassLevel(),
+            configure().getClassVisibility(),
+            configure().isFieldLevel(),
+            configure().getFieldVisibility(),
+            configure().isConstructorLevel(),
+            configure().getConstructorVisibility(),
+            configure().isMethodLevel(),
+            configure().getMethodVisibility(),
+            configure().isParameterLevel());
    }
 
    /**
     * Include the specified visibility in the scan
-    * @param v The visibility
+    *
+    * @param v         The visibility
     * @param modifiers The modifiers for the class
     * @return True if include; otherwise false
     */
@@ -297,26 +324,26 @@
    {
       if (Modifier.isPublic(modifiers))
          return true;
-      
+
       boolean include = true;
-      
+
       if (Modifier.isPrivate(modifiers))
       {
          if (v == Visibility.PROTECTED ||
-             v == Visibility.PACKAGE ||
-             v == Visibility.PUBLIC)
+               v == Visibility.PACKAGE ||
+               v == Visibility.PUBLIC)
          {
             include = false;
          }
-      } 
+      }
       else if (Modifier.isProtected(modifiers))
       {
          if (v == Visibility.PACKAGE ||
-             v == Visibility.PUBLIC)
+               v == Visibility.PUBLIC)
          {
             include = false;
          }
-      } 
+      }
       else
       {
          if (v == Visibility.PUBLIC)
@@ -330,6 +357,7 @@
 
    /**
     * Scan
+    *
     * @param urls The URLs with class files
     * @return The map of annotations
     */
@@ -340,8 +368,9 @@
 
    /**
     * Scan using additional classloader to resolve annotation class definitions
+    *
     * @param urls The URLs with .class .files
-    * @param cls Additional class loaders
+    * @param cls  Additional class loaders
     * @return The annotation repository
     */
    public abstract AnnotationRepository scan(URL[] urls, ClassLoader... cls);

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/ConfigurationImpl.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/ConfigurationImpl.java	2009-10-17 14:18:07 UTC (rev 95062)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/impl/ConfigurationImpl.java	2009-10-18 08:40:18 UTC (rev 95063)
@@ -27,6 +27,7 @@
 
 /**
  * Represents a configuration of the annotation scanner
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
 public class ConfigurationImpl implements Configuration
@@ -60,6 +61,7 @@
 
    /**
     * Scan for annotations at class level - default is <code>true</code>
+    *
     * @param scan True if scanning should be performed; otherwise false
     * @return The configuration
     */
@@ -72,6 +74,7 @@
 
    /**
     * Is the class level enabled ?
+    *
     * @return True if enabled; otherwise false
     */
    public boolean isClassLevel()
@@ -81,6 +84,7 @@
 
    /**
     * Set the visibility for classes scanned - default is <code>PRIVATE</code>
+    *
     * @param v The visibility
     * @return The configuration
     */
@@ -93,6 +97,7 @@
 
    /**
     * Get the class visibility setting
+    *
     * @return The visibility
     */
    public Visibility getClassVisibility()
@@ -102,6 +107,7 @@
 
    /**
     * Scan for annotations at field level - default is <code>true</code>
+    *
     * @param scan True if scanning should be performed; otherwise false
     * @return The configuration
     */
@@ -114,6 +120,7 @@
 
    /**
     * Is the field level enabled ?
+    *
     * @return True if enabled; otherwise false
     */
    public boolean isFieldLevel()
@@ -123,6 +130,7 @@
 
    /**
     * Set the visibility for fields scanned - default is <code>PRIVATE</code>
+    *
     * @param v The visibility
     * @return The configuration
     */
@@ -135,6 +143,7 @@
 
    /**
     * Get the field visibility setting
+    *
     * @return The visibility
     */
    public Visibility getFieldVisibility()
@@ -144,6 +153,7 @@
 
    /**
     * Scan for annotations at constructor level - default is <code>true</code>
+    *
     * @param scan True if scanning should be performed; otherwise false
     * @return The configuration
     */
@@ -156,6 +166,7 @@
 
    /**
     * Is the constructor level enabled ?
+    *
     * @return True if enabled; otherwise false
     */
    public boolean isConstructorLevel()
@@ -165,6 +176,7 @@
 
    /**
     * Set the visibility for constructors scanned - default is <code>PRIVATE</code>
+    *
     * @param v The visibility
     * @return The configuration
     */
@@ -177,6 +189,7 @@
 
    /**
     * Get the constructor visibility setting
+    *
     * @return The visibility
     */
    public Visibility getConstructorVisibility()
@@ -186,6 +199,7 @@
 
    /**
     * Scan for annotations at method level - default is <code>true</code>
+    *
     * @param scan True if scanning should be performed; otherwise false
     * @return The configuration
     */
@@ -198,6 +212,7 @@
 
    /**
     * Is the method level enabled ?
+    *
     * @return True if enabled; otherwise false
     */
    public boolean isMethodLevel()
@@ -207,6 +222,7 @@
 
    /**
     * Set the visibility for methods scanned - default is <code>PRIVATE</code>
+    *
     * @param v The visibility
     * @return The configuration
     */
@@ -219,6 +235,7 @@
 
    /**
     * Get the method visibility setting
+    *
     * @return The visibility
     */
    public Visibility getMethodVisibility()
@@ -228,6 +245,7 @@
 
    /**
     * Scan for annotations at parameter level - default is <code>true</code>
+    *
     * @param scan True if scanning should be performed; otherwise false
     * @return The configuration
     */
@@ -240,6 +258,7 @@
 
    /**
     * Is the parameter level enabled ?
+    *
     * @return True if enabled; otherwise false
     */
    public boolean isParameterLevel()

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javalangreflect/JavaClass.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javalangreflect/JavaClass.java	2009-10-17 14:18:07 UTC (rev 95062)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javalangreflect/JavaClass.java	2009-10-18 08:40:18 UTC (rev 95063)
@@ -25,6 +25,7 @@
 import org.jboss.papaki.Annotation;
 import org.jboss.papaki.AnnotationRepository;
 import org.jboss.papaki.AnnotationType;
+import org.jboss.papaki.Configuration;
 import org.jboss.papaki.impl.AbstractAnnotationScanner;
 import org.jboss.papaki.impl.AnnotationRepositoryImpl;
 import org.jboss.papaki.impl.ClassInfo;
@@ -65,7 +66,19 @@
       super(JavaClass.class.getName());
    }
 
+
    /**
+    * Constructor
+    *
+    * @param configuration the configuration
+    */
+   public JavaClass(Configuration configuration)
+   {
+      this();
+      setConfiguration(configuration);
+   }
+
+   /**
     * Scan
     * @param urls The URLs with class files
     * @param cls Additional class loaders
@@ -142,7 +155,7 @@
                                  {
                                     sci = new ClassInfo(clz.getSuperclass().getName());
                                  }
-                                 
+
                                  sci.addChild(clz.getName());
 
                                  classInfo.put(clz.getSuperclass().getName(), sci);
@@ -161,14 +174,14 @@
                               {
                                  for (java.lang.annotation.Annotation annotation : classAnnotations)
                                  {
-                                    processAnnotation(annotation, 
-                                                      AnnotationType.CLASS, 
+                                    processAnnotation(annotation,
+                                                      AnnotationType.CLASS,
                                                       clz.getName(), null, null, -1,
                                                       ari, annotationToClasses, classInfo);
                                  }
                               }
                            }
-                           
+
                            if (!clz.isInterface())
                            {
                               if (configuration.isConstructorLevel())
@@ -191,20 +204,20 @@
                                              for (int i = 0; i < parameters.length; i++)
                                              {
                                                 parameterTypes[i] = parameters[i].getName();
-                                             
+
                                                 if (trace)
                                                    log.finest("Parameter=" + parameters[i].getName());
                                              }
                                           }
-                                       
-                                          java.lang.annotation.Annotation[] constructorAnnotations = 
+
+                                          java.lang.annotation.Annotation[] constructorAnnotations =
                                              constructor.getDeclaredAnnotations();
 
                                           if (constructorAnnotations != null)
                                           {
                                              for (java.lang.annotation.Annotation annotation : constructorAnnotations)
                                              {
-                                                processAnnotation(annotation, AnnotationType.CONSTRUCTOR, 
+                                                processAnnotation(annotation, AnnotationType.CONSTRUCTOR,
                                                                   clz.getName(), null, parameterTypes, -1,
                                                                   ari, annotationToClasses, classInfo);
                                              }
@@ -212,21 +225,21 @@
 
                                           if (parameterTypes != null && configuration.isParameterLevel())
                                           {
-                                             java.lang.annotation.Annotation[][] parameterAnnotations = 
+                                             java.lang.annotation.Annotation[][] parameterAnnotations =
                                                 constructor.getParameterAnnotations();
 
                                              for (int i = 0; i < parameterAnnotations.length; i++)
                                              {
                                                 for (int j = 0; j < parameterAnnotations[i].length; j++)
                                                 {
-                                                   java.lang.annotation.Annotation annotation = 
+                                                   java.lang.annotation.Annotation annotation =
                                                       parameterAnnotations[i][j];
 
-                                                   processAnnotation(annotation, 
+                                                   processAnnotation(annotation,
                                                                      AnnotationType.PARAMETER,
                                                                      clz.getName(), null, parameterTypes, i,
                                                                      ari, annotationToClasses, classInfo);
-                                                   
+
                                                 }
                                              }
                                           }
@@ -261,15 +274,15 @@
                                                 log.finest("Parameter=" + parameters[i].getName());
                                           }
                                        }
-                                 
-                                       java.lang.annotation.Annotation[] methodAnnotations = 
+
+                                       java.lang.annotation.Annotation[] methodAnnotations =
                                           method.getDeclaredAnnotations();
 
                                        if (methodAnnotations != null)
                                        {
                                           for (java.lang.annotation.Annotation annotation : methodAnnotations)
                                           {
-                                             processAnnotation(annotation, AnnotationType.METHOD, 
+                                             processAnnotation(annotation, AnnotationType.METHOD,
                                                                clz.getName(), method.getName(), parameterTypes, -1,
                                                                ari, annotationToClasses, classInfo);
                                           }
@@ -277,21 +290,21 @@
 
                                        if (parameterTypes != null && configuration.isParameterLevel())
                                        {
-                                          java.lang.annotation.Annotation[][] parameterAnnotations = 
+                                          java.lang.annotation.Annotation[][] parameterAnnotations =
                                              method.getParameterAnnotations();
 
                                           for (int i = 0; i < parameterAnnotations.length; i++)
                                           {
                                              for (int j = 0; j < parameterAnnotations[i].length; j++)
                                              {
-                                                java.lang.annotation.Annotation annotation = 
+                                                java.lang.annotation.Annotation annotation =
                                                    parameterAnnotations[i][j];
 
-                                                processAnnotation(annotation, 
+                                                processAnnotation(annotation,
                                                                   AnnotationType.PARAMETER,
                                                                   clz.getName(), method.getName(), parameterTypes, i,
                                                                   ari, annotationToClasses, classInfo);
-                                                
+
                                              }
                                           }
                                        }
@@ -311,17 +324,17 @@
                                     {
                                        if (trace)
                                           log.finest("Field=" + field.getName());
-                           
+
                                        if (includeField(field.getModifiers()))
                                        {
-                                          java.lang.annotation.Annotation[] fieldAnnotations = 
+                                          java.lang.annotation.Annotation[] fieldAnnotations =
                                              field.getDeclaredAnnotations();
 
                                           if (fieldAnnotations != null)
                                           {
                                              for (java.lang.annotation.Annotation annotation : fieldAnnotations)
                                              {
-                                                processAnnotation(annotation, AnnotationType.FIELD, 
+                                                processAnnotation(annotation, AnnotationType.FIELD,
                                                                   clz.getName(), field.getName(), null, -1,
                                                                   ari, annotationToClasses, classInfo);
                                              }
@@ -346,9 +359,9 @@
                                     {
                                        ici = new ClassInfo(interfaceName);
                                     }
-                                    
+
                                     ici.addChild(clz.getName());
-                                    
+
                                     classInfo.put(interfaceName, ici);
                                  }
                               }
@@ -393,7 +406,7 @@
                // Swallow
             }
          }
-         
+
          if (log.isLoggable(Level.FINE))
          {
             long end = System.currentTimeMillis();
@@ -403,7 +416,7 @@
             {
                numberOfAnnotations += l.size();
             }
-            
+
             log.fine(Arrays.toString(urls) + "," + (end - start) + "," + numberOfAnnotations);
          }
       }
@@ -439,8 +452,8 @@
     * @param annotationToClasses The annotation to classes mapping
     * @param classInfo The class information map
     */
-   private void processAnnotation(java.lang.annotation.Annotation annotation, 
-                                  AnnotationType type, String className, String memberName, 
+   private void processAnnotation(java.lang.annotation.Annotation annotation,
+                                  AnnotationType type, String className, String memberName,
                                   String[] parameterTypes, int parameterIndex,
                                   AnnotationRepositoryImpl ari,
                                   Map<String, Collection<String>> annotationToClasses,
@@ -448,7 +461,7 @@
    {
       Class annotationClass = annotation.annotationType();
       String acn = annotationClass.getName();
-                        
+
       Annotation a = new Annotation(acn,
                                     annotationClass.cast(annotation),
                                     type,

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistclasspool/JavassistClassPool.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistclasspool/JavassistClassPool.java	2009-10-17 14:18:07 UTC (rev 95062)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistclasspool/JavassistClassPool.java	2009-10-18 08:40:18 UTC (rev 95063)
@@ -23,6 +23,7 @@
 package org.jboss.papaki.javassistclasspool;
 
 import org.jboss.papaki.AnnotationRepository;
+import org.jboss.papaki.Configuration;
 import org.jboss.papaki.impl.AbstractJavassistAnnotationScanner;
 import org.jboss.papaki.impl.AnnotationRepositoryImpl;
 import org.jboss.papaki.impl.ClassInfo;
@@ -49,6 +50,7 @@
 
 /**
  * An annotation scanner using Javassist's ClassLoader
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
 public class JavassistClassPool extends AbstractJavassistAnnotationScanner
@@ -65,9 +67,21 @@
    }
 
    /**
+    * Constructor
+    *
+    * @param configuration the configuration
+    */
+   public JavassistClassPool(Configuration configuration)
+   {
+      super(JavassistClassPool.class.getName());
+      setConfiguration(configuration);
+   }
+
+   /**
     * Scan
+    *
     * @param urls The URLs with class files
-    * @param cls Additional class loaders
+    * @param cls  Additional class loaders
     * @return The map of annotations
     */
    public AnnotationRepository scan(URL[] urls, ClassLoader... cls)
@@ -118,7 +132,7 @@
                if (ari != null && ari.getSize() == 0)
                   continue;
 
-               List<String> classes = getClassNames(new URL[] {u});
+               List<String> classes = getClassNames(new URL[]{u});
                if (classes != null)
                {
                   for (String className : classes)
@@ -174,13 +188,13 @@
          if (log.isLoggable(Level.FINE))
          {
             long end = System.currentTimeMillis();
-         
+
             int numberOfAnnotations = 0;
             for (Collection<String> l : annotationToClasses.values())
             {
                numberOfAnnotations += l.size();
             }
-         
+
             log.fine(Arrays.toString(urls) + "," + (end - start) + "," + numberOfAnnotations);
          }
       }

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistinputstream/JavassistInputStream.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistinputstream/JavassistInputStream.java	2009-10-17 14:18:07 UTC (rev 95062)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/papaki/javassistinputstream/JavassistInputStream.java	2009-10-18 08:40:18 UTC (rev 95063)
@@ -23,6 +23,7 @@
 package org.jboss.papaki.javassistinputstream;
 
 import org.jboss.papaki.AnnotationRepository;
+import org.jboss.papaki.Configuration;
 import org.jboss.papaki.impl.AbstractJavassistAnnotationScanner;
 import org.jboss.papaki.impl.AnnotationRepositoryImpl;
 import org.jboss.papaki.impl.ClassInfo;
@@ -53,6 +54,7 @@
 
 /**
  * An annotation scanner using Javassist and InputStream
+ *
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
 public class JavassistInputStream extends AbstractJavassistAnnotationScanner
@@ -69,9 +71,21 @@
    }
 
    /**
+    * Constructor
+    *
+    * @param configuration the configuration
+    */
+   public JavassistInputStream(Configuration configuration)
+   {
+      this();
+      setConfiguration(configuration);
+   }
+
+   /**
     * Scan
+    *
     * @param urls The URLs with class files
-    * @param cls Additional class loaders
+    * @param cls  Additional class loaders
     * @return The map of annotations
     */
    public AnnotationRepository scan(URL[] urls, ClassLoader... cls)
@@ -118,7 +132,7 @@
                {
                   ari = getScan(jarFile);
                }
-               
+
                if (ari != null && ari.getSize() == 0)
                   continue;
 
@@ -158,7 +172,7 @@
                }
                else
                {
-                  List<String> classes = getClassNames(new URL[] {u});
+                  List<String> classes = getClassNames(new URL[]{u});
                   if (classes != null)
                   {
                      for (int i = 0; (isJava5 == null || isJava5.booleanValue()) && i < classes.size(); i++)

Added: projects/annotations/trunk/maven/release.bat
===================================================================
--- projects/annotations/trunk/maven/release.bat	                        (rev 0)
+++ projects/annotations/trunk/maven/release.bat	2009-10-18 08:40:18 UTC (rev 95063)
@@ -0,0 +1,3 @@
+ at echo off
+mvn deploy:deploy-file -Dfile=../target/papaki-core.jar -DpomFile=core/release.xml -Durl=dav:https://svn.jboss.org/repos/repository.jboss.org/maven2 -DrepositoryId=jboss-releases
+mvn deploy:deploy-file -Dfile=../target/papaki-indexer.jar -DpomFile=indexer/release.xml -Durl=dav:https://svn.jboss.org/repos/repository.jboss.org/maven2 -DrepositoryId=jboss-releases

Added: projects/annotations/trunk/maven/snapshot.bat
===================================================================
--- projects/annotations/trunk/maven/snapshot.bat	                        (rev 0)
+++ projects/annotations/trunk/maven/snapshot.bat	2009-10-18 08:40:18 UTC (rev 95063)
@@ -0,0 +1,3 @@
+ at echo off
+mvn deploy:deploy-file -Dfile=../target/papaki-core.jar -DpomFile=core/snapshot.xml -Durl=dav:https://snapshots.jboss.org/maven2 -DrepositoryId=snapshots.jboss.org
+mvn deploy:deploy-file -Dfile=../target/papaki-indexer.jar -DpomFile=indexer/snapshot.xml -Durl=dav:https://snapshots.jboss.org/maven2 -DrepositoryId=snapshots.jboss.org




More information about the jboss-cvs-commits mailing list