[jboss-cvs] JBossAS SVN: r92985 - in projects/annotations/trunk: core/src/main/java/org/jboss/annotations and 14 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 28 17:37:32 EDT 2009


Author: jesper.pedersen
Date: 2009-08-28 17:37:32 -0400 (Fri, 28 Aug 2009)
New Revision: 92985

Added:
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InheritanceTests.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javalangreflect/unit/InheritanceTestCase.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javassistclasspool/unit/InheritanceTestCase.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javassistinputstream/unit/InheritanceTestCase.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/AbstractTest.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/Test.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/package.html
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/BaseTest.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/Test.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/package.html
Removed:
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/Scan.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ScanClass.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLLoader.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLSaver.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/
Modified:
   projects/annotations/trunk/core/build.xml
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationRepository.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractJavassistAnnotationScanner.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/ClassInfo.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javalangreflect/JavaClass.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javassistclasspool/JavassistClassPool.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javassistinputstream/JavassistInputStream.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/BinaryLoader.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassTests.java
   projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InterfaceTests.java
   projects/annotations/trunk/doc/userguide/en/modules/ant.xml
   projects/annotations/trunk/doc/userguide/en/modules/troubleshooting.xml
   projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/IndexerTask.java
   projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/Main.java
Log:
[JBANN-3] Support inheritance (Part 2)

Modified: projects/annotations/trunk/core/build.xml
===================================================================
--- projects/annotations/trunk/core/build.xml	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/build.xml	2009-08-28 21:37:32 UTC (rev 92985)
@@ -71,6 +71,8 @@
     </copy>
 
     <mkdir dir="${build.core.dir}/testjars" />
+
+    <!-- Class based tests --> 
     <jar destfile="${build.core.dir}/testjars/classabstract.jar"
          basedir="${build.core.dir}/test"
          includes="**/common/**, **/classabstract/**"/>
@@ -101,6 +103,16 @@
     <jar destfile="${build.core.dir}/testjars/classfield.jar"
          basedir="${build.core.dir}/test"
          includes="**/common/**, **/classfield/**"/>
+
+    <!-- Inheritance based tests --> 
+    <jar destfile="${build.core.dir}/testjars/inheritanceclassabstract.jar"
+         basedir="${build.core.dir}/test"
+         includes="**/common/**, **/inheritanceclassabstract/**"/>
+    <jar destfile="${build.core.dir}/testjars/inheritanceclassclass.jar"
+         basedir="${build.core.dir}/test"
+         includes="**/common/**, **/inheritanceclassclass/**"/>
+
+    <!-- Interface based tests --> 
     <jar destfile="${build.core.dir}/testjars/interfaceempty.jar"
          basedir="${build.core.dir}/test"
          includes="**/common/**, **/interfaceempty/**"/>
@@ -123,6 +135,7 @@
              classname="org.jboss.annotations.indexer.IndexerTask"
              classpathref="core.lib.path.id"/>
 
+    <!-- Class based tests --> 
     <indexer input="${build.core.dir}/testjars/classabstract.jar"/>
     <indexer input="${build.core.dir}/testjars/classconstructor.jar"/>
     <indexer input="${build.core.dir}/testjars/classconstructorwithparameter.jar"/>
@@ -133,6 +146,12 @@
     <indexer input="${build.core.dir}/testjars/classmethod.jar"/>
     <indexer input="${build.core.dir}/testjars/classmethodwithparameter.jar"/>
     <indexer input="${build.core.dir}/testjars/classfield.jar"/>
+
+    <!-- Inheritance based tests --> 
+    <indexer input="${build.core.dir}/testjars/inheritanceclassabstract.jar"/>
+    <indexer input="${build.core.dir}/testjars/inheritanceclassclass.jar"/>
+
+    <!-- Interface based tests --> 
     <indexer input="${build.core.dir}/testjars/interfaceempty.jar"/>
     <indexer input="${build.core.dir}/testjars/interfacelevel.jar"/>
     <indexer input="${build.core.dir}/testjars/interfacemethod.jar"/>

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationRepository.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationRepository.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/AnnotationRepository.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -22,6 +22,7 @@
 
 package org.jboss.annotations;
 
+import java.io.Serializable;
 import java.util.Collection;
 import java.util.Set;
 
@@ -29,7 +30,7 @@
  * An annotation repository
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
-public interface AnnotationRepository
+public interface AnnotationRepository extends Serializable
 {
    /**
     * Get the available annotation keys

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -27,7 +27,6 @@
 import org.jboss.annotations.util.BinaryLoader;
 import org.jboss.annotations.util.ClassScanner;
 import org.jboss.annotations.util.JarScanner;
-import org.jboss.annotations.util.XMLLoader;
 
 import java.io.File;
 import java.io.IOException;
@@ -52,9 +51,6 @@
    /** Name of the binary metadata */
    public static final String JBOSS_ANNOTATION_BINARY = "jboss-annotation.ser";
 
-   /** Name of the XML metadata */
-   public static final String JBOSS_ANNOTATION_XML = "jboss-annotation.xml";
-
    /**
     * Constructor
     * @param logger The logger name
@@ -127,14 +123,13 @@
    /**
     * Check a JAR file for metadata
     * @param jarFile The JAR file
-    * @return The scan definition; <code>null</code> if no metadata is found
+    * @return The annotation repository implementation; <code>null</code> if no metadata is found
     */
-   protected Scan getScan(JarFile jarFile)
+   protected AnnotationRepositoryImpl getScan(JarFile jarFile)
    {
-      Scan result = null;
+      AnnotationRepositoryImpl result = null;
 
       InputStream binaryIS = null;
-      InputStream xmlIS = null;
 
       try
       {
@@ -144,16 +139,6 @@
             binaryIS = jarFile.getInputStream(binary);
             result = BinaryLoader.loadJBossAnnotation(binaryIS);
          }
-
-         if (result == null)
-         {
-            JarEntry xml = jarFile.getJarEntry("META-INF/" + JBOSS_ANNOTATION_XML);
-            if (xml != null)
-            {
-               xmlIS = jarFile.getInputStream(xml);
-               result = XMLLoader.loadJBossAnnotation(xmlIS);
-            }
-         }
       }
       catch (Throwable t)
       {
@@ -173,18 +158,6 @@
                // Ignore
             }
          }
-
-         if (xmlIS != null)
-         {
-            try
-            {
-               xmlIS.close();
-            }
-            catch (IOException ioe)
-            {
-               // Ignore
-            }
-         }
       }
 
       return result;

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractJavassistAnnotationScanner.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractJavassistAnnotationScanner.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractJavassistAnnotationScanner.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -62,12 +62,12 @@
    /**
     * Process class
     * @param ctClass The class
-    * @param scanClass The scan class structure; <code>null</code> if no information about the class
+    * @param ari The annotation repository loaded from metadata; <code>null</code> if no information
     * @param annotationToClasses The annotation to classes mapping
     * @param classInfo The class information map
     * @exception NotFoundException Thrown if the class types cant be resolved
     */
-   protected void processClass(CtClass ctClass, ScanClass scanClass, 
+   protected void processClass(CtClass ctClass, AnnotationRepositoryImpl ari, 
                                Map<String, Collection<String>> annotationToClasses,
                                Map<String, ClassInfo> classInfo)
       throws NotFoundException
@@ -75,33 +75,40 @@
       if (trace)
          log.finest("Class=" + ctClass.getName());
 
+      if (ari != null && !ari.shouldBeScanned(ctClass.getName()))
+         return;
+
       // Class information
-      ClassInfo ci = classInfo.get(ctClass.getName());
-      if (ci == null)
+      ClassInfo ci = null;
+      if (ari == null)
       {
-         ci = new ClassInfo(ctClass.getName());
-      }
-
-      if (ctClass.getSuperclass() != null && !ctClass.getSuperclass().getName().startsWith("java."))
-      {
-         ci.setSuperClassName(ctClass.getSuperclass().getName());
-
-         ClassInfo sci = classInfo.get(ctClass.getSuperclass().getName());
-         if (sci == null)
+         ci = classInfo.get(ctClass.getName());
+         if (ci == null)
          {
-            sci = new ClassInfo(ctClass.getSuperclass().getName());
+            ci = new ClassInfo(ctClass.getName());
          }
 
-         sci.addChild(ctClass.getName());
+         if (ctClass.getSuperclass() != null && !ctClass.getSuperclass().getName().startsWith("java."))
+         {
+            ci.setSuperClassName(ctClass.getSuperclass().getName());
 
-         classInfo.put(ctClass.getSuperclass().getName(), sci);
-      }
+            ClassInfo sci = classInfo.get(ctClass.getSuperclass().getName());
+            if (sci == null)
+            {
+               sci = new ClassInfo(ctClass.getSuperclass().getName());
+            }
 
-      ci.setInterface(ctClass.isInterface());
-      ci.setAbstract(Modifier.isAbstract(ctClass.getModifiers()));
+            sci.addChild(ctClass.getName());
 
-      classInfo.put(ctClass.getName(), ci);
+            classInfo.put(ctClass.getSuperclass().getName(), sci);
+         }
+         
+         ci.setInterface(ctClass.isInterface());
+         ci.setAbstract(Modifier.isAbstract(ctClass.getModifiers()));
 
+         classInfo.put(ctClass.getName(), ci);
+      }
+
       // Class level annotations
       Object[] classAnnotations = ctClass.getAvailableAnnotations();
                         
@@ -112,7 +119,7 @@
             processAnnotation(annotation, 
                               AnnotationType.CLASS, 
                               ctClass.getName(), null, null,
-                              annotationToClasses, classInfo);
+                              ari, annotationToClasses, classInfo);
          }
       }
 
@@ -141,18 +148,15 @@
                   }
                }
 
-               if (scanClass == null || scanClass.hasConstructor(parameterTypes))
+               Object[] constructorAnnotations = constructor.getAvailableAnnotations();
+               if (constructorAnnotations != null)
                {
-                  Object[] constructorAnnotations = constructor.getAvailableAnnotations();
-                  if (constructorAnnotations != null)
+                  for (Object annotation : constructorAnnotations)
                   {
-                     for (Object annotation : constructorAnnotations)
-                     {
-                        processAnnotation(annotation,
-                                          AnnotationType.CONSTRUCTOR, 
-                                          ctClass.getName(), null, parameterTypes,
-                                          annotationToClasses, classInfo);
-                     }
+                     processAnnotation(annotation,
+                                       AnnotationType.CONSTRUCTOR, 
+                                       ctClass.getName(), null, parameterTypes,
+                                       ari, annotationToClasses, classInfo);
                   }
                }
             }
@@ -182,18 +186,15 @@
                }
             }
 
-            if (scanClass == null || scanClass.hasMethod(method.getName(), parameterTypes))
+            Object[] methodAnnotations = method.getAvailableAnnotations();
+            if (methodAnnotations != null)
             {
-               Object[] methodAnnotations = method.getAvailableAnnotations();
-               if (methodAnnotations != null)
+               for (Object annotation : methodAnnotations)
                {
-                  for (Object annotation : methodAnnotations)
-                  {
-                     processAnnotation(annotation, 
-                                       AnnotationType.METHOD,
-                                       ctClass.getName(), method.getName(), parameterTypes,
-                                       annotationToClasses, classInfo);
-                  }
+                  processAnnotation(annotation, 
+                                    AnnotationType.METHOD,
+                                    ctClass.getName(), method.getName(), parameterTypes,
+                                    ari, annotationToClasses, classInfo);
                }
             }
          }
@@ -210,18 +211,15 @@
                if (trace)
                   log.finest("Field=" + field.getName());
             
-               if (scanClass == null || scanClass.hasField(field.getName()))
+               Object[] fieldAnnotations = field.getAvailableAnnotations();
+               if (fieldAnnotations != null)
                {
-                  Object[] fieldAnnotations = field.getAvailableAnnotations();
-                  if (fieldAnnotations != null)
+                  for (Object annotation : fieldAnnotations)
                   {
-                     for (Object annotation : fieldAnnotations)
-                     {
-                        processAnnotation(annotation, 
-                                          AnnotationType.FIELD,
-                                          ctClass.getName(), field.getName(), null,
-                                          annotationToClasses, classInfo);
-                     }
+                     processAnnotation(annotation, 
+                                       AnnotationType.FIELD,
+                                       ctClass.getName(), field.getName(), null,
+                                       ari, annotationToClasses, classInfo);
                   }
                }
             }
@@ -229,24 +227,27 @@
       }
 
       // Interfaces
-      CtClass[] interfaces = ctClass.getInterfaces();
-      if (interfaces != null)
+      if (ari == null)
       {
-         for (CtClass interfaceClass : interfaces)
+         CtClass[] interfaces = ctClass.getInterfaces();
+         if (interfaces != null)
          {
-            if (!interfaceClass.getName().startsWith("java."))
+            for (CtClass interfaceClass : interfaces)
             {
-               ci.addInterface(interfaceClass.getName());
+               if (!interfaceClass.getName().startsWith("java."))
+               {
+                  ci.addInterface(interfaceClass.getName());
 
-               ClassInfo sci = classInfo.get(interfaceClass.getName());
-               if (sci == null)
-               {
-                  sci = new ClassInfo(interfaceClass.getName());
-               }
+                  ClassInfo sci = classInfo.get(interfaceClass.getName());
+                  if (sci == null)
+                  {
+                     sci = new ClassInfo(interfaceClass.getName());
+                  }
                
-               sci.addChild(ctClass.getName());
+                  sci.addChild(ctClass.getName());
                         
-               classInfo.put(interfaceClass.getName(), sci);
+                  classInfo.put(interfaceClass.getName(), sci);
+               }
             }
          }
       }
@@ -259,11 +260,13 @@
     * @param className The class name
     * @param memberName The member name
     * @param parameterTypes The parameter types
+    * @param ari The annotation repository implementation loaded from metadata
     * @param annotationToClasses The annotation to classes mapping
     * @param classInfo The class information map
     */
    protected void processAnnotation(Object annotation, 
                                     AnnotationType type, String className, String memberName, String[] parameterTypes,
+                                    AnnotationRepositoryImpl ari,
                                     Map<String, Collection<String>> annotationToClasses,
                                     Map<String, ClassInfo> classInfo)
    {
@@ -278,15 +281,22 @@
       if (trace)
          log.finest("Annotation=" + a);
 
-      Collection<String> l = annotationToClasses.get(acn);
-      if (l == null)
-         l = new HashSet<String>();
+      if (ari != null)
+      {
+         ari.registerAnnotation(className, acn, a);
+      }
+      else
+      {
+         Collection<String> l = annotationToClasses.get(acn);
+         if (l == null)
+            l = new HashSet<String>();
 
-      l.add(className);
+         l.add(className);
 
-      annotationToClasses.put(acn, l);
+         annotationToClasses.put(acn, l);
 
-      ClassInfo ci = classInfo.get(className);
-      ci.addAnnotation(acn, a);
+         ClassInfo ci = classInfo.get(className);
+         ci.addAnnotation(acn, a);
+      }
    }
 }

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-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -44,6 +44,9 @@
    private static Logger log = Logger.getLogger(AnnotationRepositoryImpl.class.getName());
    private static boolean trace = log.isLoggable(Level.FINEST);
 
+   /** Serial version UID */
+   private static final long serialVersionUID = 1L;
+
    /** The annotation to classes mapping */
    private ConcurrentMap<String, Collection<String>> annotationToClasses;
 
@@ -102,17 +105,51 @@
 
       Collection<String> classes = annotationToClasses.get(annotation);
       
-      if (classes == null)
-         return false;
+      if (classes != null)
+      {
+         for (String clz : classes)
+         {
+            ClassInfo ci = classInfo.get(clz);
 
-      for (String clz : classes)
+            boolean result = checkForConcreateClassOrInterface(ci);
+
+            if (result)
+               return true;
+         }
+      }
+
+      return false;
+   }
+
+   /**
+    * Check if a concreate class or an interface can be found in 
+    * the inheritance hierarchy
+    * @param ci The class information
+    * @return True if found; otherwise false
+    */
+   private boolean checkForConcreateClassOrInterface(ClassInfo ci)
+   {
+      if (ci != null)
       {
-         ClassInfo ci = classInfo.get(clz);
-
          if (!ci.isAbstract() || ci.isInterface())
          {
             return true;
          }
+         else
+         {
+            if (ci.getChildren() != null)
+            {
+               for (String child : ci.getChildren())
+               {
+                  ClassInfo chd = classInfo.get(child);
+                  
+                  boolean result = checkForConcreateClassOrInterface(chd);
+
+                  if (result)
+                     return true;
+               }
+            }
+         }
       }
 
       return false;
@@ -153,10 +190,10 @@
       for (String clz : classes)
       {
          ClassInfo ci = classInfo.get(clz);
+         Collection<Annotation> as = ci.getAnnotations(annotation);
 
          if (!ci.isAbstract() || ci.isInterface())
          {
-            Collection<Annotation> as = ci.getAnnotations(annotation);
             if (as != null && as.size() > 0)
             {
                l.addAll(as);
@@ -205,6 +242,26 @@
                }
             }
          }
+         else
+         {
+            if (ci.getChildren() != null)
+            {
+               for (String childClass : ci.getChildren())
+               {
+                  ClassInfo chdi = classInfo.get(childClass);
+                  if (chdi != null && as != null)
+                  {
+                     for (Annotation a : as)
+                     {
+                        Annotation na = new Annotation(a.getAnnotationClassName(), a.getAnnotation(),
+                                                       a.getType(), chdi.getClassName(), 
+                                                       a.getMemberName(), a.getParameterTypes());
+                        l.add(na);
+                     }
+                  }
+               }
+            }
+         }
       }
 
       if (l.size() == 0)
@@ -246,6 +303,44 @@
    }
 
    /**
+    * Should the class in question be scanned ?
+    * @param clz The fully qualified class name
+    * @return True if the class should be scanned; otherwise false
+    */
+   public boolean shouldBeScanned(String clz)
+   {
+      if (clz == null)
+         throw new IllegalArgumentException("Clz is null");
+
+      if (annotationToClasses != null)
+      {
+         for (Collection<String> c : annotationToClasses.values())
+         {
+            if (c.contains(clz))
+               return true;
+         }
+      }
+
+      return false;
+   }
+
+   /**
+    * Register an annotation on a class
+    * @param clz The fully qualified class name
+    * @param key The fully qualified class name for the annotation
+    * @param a The annotation
+    */
+   public void registerAnnotation(String clz, String key, Annotation a)
+   {
+      ClassInfo ci = classInfo.get(clz);
+      
+      if (ci != null)
+      {
+         ci.addAnnotation(key, a);
+      }
+   }
+
+   /**
     * String representation
     * @return The string
     */

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ClassInfo.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ClassInfo.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ClassInfo.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -24,6 +24,7 @@
 
 import org.jboss.annotations.Annotation;
 
+import java.io.Serializable;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -33,8 +34,11 @@
  * Represents information about a class
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
-public class ClassInfo
+public class ClassInfo implements Serializable
 {
+   /** Serial version UID */
+   private static final long serialVersionUID = 1L;
+
    /** The class name */
    private String className;
 
@@ -51,7 +55,7 @@
    private boolean isAbstract;
 
    /** The annotations */
-   private Map<String, Collection<Annotation>> annotations;
+   private transient Map<String, Collection<Annotation>> annotations;
 
    /** The children */
    private Collection<String> children;

Deleted: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/Scan.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/Scan.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/Scan.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -1,107 +0,0 @@
-/*
- * 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.annotations.impl;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * A class that represents which classes that should be scanned
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class Scan implements Serializable
-{
-   /** Serial version UID */
-   private static final long serialVersionUID = 1L;
-
-   /** Exclude all classes */
-   private boolean excludeAll;
-
-   /** The data */
-   private Map<String, ScanClass> data;
-   
-   /**
-    * Constructor
-    * @param excludeAll Exclude all classes
-    * @param data The data - fully qualified class name and ScanClass instance
-    */
-   public Scan(boolean excludeAll, Map<String, ScanClass> data)
-   {
-      if (data == null)
-         throw new IllegalArgumentException("Data is null");
-
-      this.excludeAll = excludeAll;
-      this.data = data;
-   }
-
-   /**
-    * Is exclude all
-    * @return True if all classes should be excluded; otherwise false
-    */
-   public boolean isExcludeAll()
-   {
-      return excludeAll;
-   }
-
-   /**
-    * Should the specified class be scanned ?
-    * @param clz The fully qualified class name
-    * @return True if the scanning should include the class; otherwise false
-    */
-   public boolean hasClass(String clz)
-   {
-      if (clz == null)
-         throw new IllegalArgumentException("Clz is null");
-
-      return data.containsKey(clz);
-   }
-
-   /**
-    * Get the scan class data
-    * @param clz The fully qualified class name
-    * @return The data; <code>null</null> if the class is not found
-    */
-   public ScanClass getClass(String clz)
-   {
-      if (clz == null)
-         throw new IllegalArgumentException("Clz is null");
-
-      return data.get(clz);
-   }
-
-   /**
-    * String representation
-    * @return The string
-    */
-   public String toString()
-   {
-      StringBuilder sb = new StringBuilder(Scan.class.getName());
-
-      sb = sb.append("{");
-      sb = sb.append("ExcludeAll=" + excludeAll + ",");
-      sb = sb.append("Data=" + data);
-      sb = sb.append("}");
-
-      return sb.toString();
-   }
-}

Deleted: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ScanClass.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ScanClass.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ScanClass.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -1,212 +0,0 @@
-/*
- * 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.annotations.impl;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Represents a class that should be scanned
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class ScanClass implements Serializable
-{
-   /** Serial version UID */
-   private static final long serialVersionUID = 1L;
-
-   /** The class name */
-   private String className;
-
-   /** Fields */
-   private Set<String> fields;
-
-   /** Constructor parameters */
-   private List<String[]> constructors;
-
-   /** Methods */
-   private Map<String, List<String[]>> methods;
-
-   /**
-    * Constructor
-    * @param className The fuly qualified class name
-    */
-   public ScanClass(String className)
-   {
-      this.className = className;
-      this.fields = null;
-      this.constructors = null;
-      this.methods = null;
-   }
-
-   /**
-    * Get the class name
-    * @return The class name
-    */
-   public String getClassName()
-   {
-      return className;
-   }
-
-   /**
-    * Add a field
-    * @param name The field name
-    */
-   public void addField(String name)
-   {
-      if (fields == null)
-         fields = new HashSet<String>();
-
-      fields.add(name);
-   }
-
-   /**
-    * Has field
-    * @param name The field name
-    * @return True if the field should be scanned; otherwise false
-    */
-   public boolean hasField(String name)
-   {
-      return fields.contains(name);
-   }
-
-   /**
-    * Add a constructor
-    * @param parameters The parameters; <code>null</code> for default constructor
-    */
-   public void addConstructor(String[] parameters)
-   {
-      if (constructors == null)
-         constructors = new ArrayList<String[]>();
-
-      if (parameters == null)
-      {
-         parameters = new String[0];
-      }
-
-      constructors.add(parameters);
-   }
-
-   /**
-    * Has constructor
-    * @param parameters The parameters; <code>null</code> for default constructor
-    * @return True if the constructor should be scanned; otherwise false
-    */
-   public boolean hasConstructor(String[] parameters)
-   {
-      if (constructors == null)
-         return false;
-
-      if (parameters == null)
-      {
-         parameters = new String[0];
-      }
-
-      boolean found = false;
-      for (int i = 0; !found && i < constructors.size(); i++)
-      {
-         String[] current = constructors.get(i);
-         found = Arrays.equals(current, parameters);
-      }
-
-      return found;
-   }
-
-   /**
-    * Add a method
-    * @param name The method name
-    * @param parameters The parameters; <code>null</code> for none
-    */
-   public void addMethod(String name, String[] parameters)
-   {
-      if (methods == null)
-         methods = new HashMap<String, List<String[]>>();
-
-      List<String[]> l = methods.get(name);
-      if (l == null)
-         l = new ArrayList<String[]>();
-
-      if (parameters == null)
-      {
-         parameters = new String[0];
-      }
-
-      l.add(parameters);
-
-      methods.put(name, l);
-   }
-
-   /**
-    * Has method
-    * @param name The method name
-    * @param parameters The parameters; <code>null</code> for none
-    * @return True if the method should be scanned; otherwise false
-    */
-   public boolean hasMethod(String name, String[] parameters)
-   {
-      if (methods == null)
-         return false;
-
-      List<String[]> l = methods.get(name);
-
-      if (l == null)
-         return false;
-
-      if (parameters == null)
-      {
-         parameters = new String[0];
-      }
-
-      boolean found = false;
-      for (int i = 0; !found && i < l.size(); i++)
-      {
-         String[] current = l.get(i);
-         found = Arrays.equals(current, parameters);
-      }
-
-      return found;
-   }
-
-   /**
-    * String representation
-    * @return The string
-    */
-   public String toString()
-   {
-      StringBuilder sb = new StringBuilder(ScanClass.class.getName());
-
-      sb = sb.append("{");
-      sb = sb.append("ClassName=" + className + ",");
-      sb = sb.append("Fields=" + fields + ",");
-      sb = sb.append("Constructors=" + constructors + ",");
-      sb = sb.append("Methods=" + methods);
-      sb = sb.append("}");
-
-      return sb.toString();
-   }
-}

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javalangreflect/JavaClass.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javalangreflect/JavaClass.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javalangreflect/JavaClass.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -28,8 +28,6 @@
 import org.jboss.annotations.impl.AbstractAnnotationScanner;
 import org.jboss.annotations.impl.AnnotationRepositoryImpl;
 import org.jboss.annotations.impl.ClassInfo;
-import org.jboss.annotations.impl.Scan;
-import org.jboss.annotations.impl.ScanClass;
 
 import java.io.Closeable;
 import java.io.File;
@@ -77,6 +75,7 @@
    {
       Map<String, Collection<String>> annotationToClasses = new HashMap<String, Collection<String>>();
       Map<String, ClassInfo> classInfo = new HashMap<String, ClassInfo>();
+      AnnotationRepositoryImpl ari = null;
 
       long start = 0;
       if (log.isLoggable(Level.FINE))
@@ -94,9 +93,9 @@
                File jarFile = new File(u.toURI());
                jar = new JarFile(jarFile);
                
-               Scan scan = getScan(jar);
+               ari = getScan(jar);
 
-               if (scan != null && scan.isExcludeAll())
+               if (ari != null && ari.getSize() == 0)
                   continue;
 
                List<String> classes = getClassNames(new URL[] {u});
@@ -108,42 +107,42 @@
                      {
                         Class clz = Class.forName(className, false, cl);
 
-                        ScanClass scanClass = null;
-                        if (scan != null)
-                           scanClass = scan.getClass(clz.getName());
-
                         if (trace)
                            log.finest("Class=" + clz.getName());
 
                         if (!clz.isAnnotation())
                         {
                            // Class information
-                           ClassInfo ci = classInfo.get(clz.getName());
-                           if (ci == null)
+                           ClassInfo ci = null;
+                           if (ari == null)
                            {
-                              ci = new ClassInfo(clz.getName());
-                           }
+                              ci = classInfo.get(clz.getName());
+                              if (ci == null)
+                              {
+                                 ci = new ClassInfo(clz.getName());
+                              }
 
-                           if (clz.getSuperclass() != null && !clz.getSuperclass().getName().startsWith("java."))
-                           {
-                              ci.setSuperClassName(clz.getSuperclass().getName());
+                              if (clz.getSuperclass() != null && !clz.getSuperclass().getName().startsWith("java."))
+                              {
+                                 ci.setSuperClassName(clz.getSuperclass().getName());
                               
-                              ClassInfo sci = classInfo.get(clz.getSuperclass().getName());
-                              if (sci == null)
-                              {
-                                 sci = new ClassInfo(clz.getSuperclass().getName());
+                                 ClassInfo sci = classInfo.get(clz.getSuperclass().getName());
+                                 if (sci == null)
+                                 {
+                                    sci = new ClassInfo(clz.getSuperclass().getName());
+                                 }
+                                 
+                                 sci.addChild(clz.getName());
+
+                                 classInfo.put(clz.getSuperclass().getName(), sci);
                               }
 
-                              sci.addChild(clz.getName());
+                              ci.setInterface(clz.isInterface());
+                              ci.setAbstract(Modifier.isAbstract(clz.getModifiers()));
 
-                              classInfo.put(clz.getSuperclass().getName(), sci);
+                              classInfo.put(clz.getName(), ci);
                            }
 
-                           ci.setInterface(clz.isInterface());
-                           ci.setAbstract(Modifier.isAbstract(clz.getModifiers()));
-
-                           classInfo.put(clz.getName(), ci);
-
                            java.lang.annotation.Annotation[] classAnnotations = clz.getAnnotations();
                            if (classAnnotations != null)
                            {
@@ -152,7 +151,7 @@
                                  processAnnotation(annotation, 
                                                    AnnotationType.CLASS, 
                                                    clz.getName(), null, null,
-                                                   annotationToClasses, classInfo);
+                                                   ari, annotationToClasses, classInfo);
                               }
                            }
                            
@@ -180,19 +179,16 @@
                                        }
                                     }
 
-                                    if (scanClass == null || scanClass.hasConstructor(parameterTypes))
+                                    java.lang.annotation.Annotation[] constructorAnnotations = 
+                                       constructor.getDeclaredAnnotations();
+
+                                    if (constructorAnnotations != null)
                                     {
-                                       java.lang.annotation.Annotation[] constructorAnnotations = 
-                                          constructor.getDeclaredAnnotations();
-
-                                       if (constructorAnnotations != null)
+                                       for (java.lang.annotation.Annotation annotation : constructorAnnotations)
                                        {
-                                          for (java.lang.annotation.Annotation annotation : constructorAnnotations)
-                                          {
-                                             processAnnotation(annotation, AnnotationType.CONSTRUCTOR, 
-                                                               clz.getName(), null, parameterTypes,
-                                                               annotationToClasses, classInfo);
-                                          }
+                                          processAnnotation(annotation, AnnotationType.CONSTRUCTOR, 
+                                                            clz.getName(), null, parameterTypes,
+                                                            ari, annotationToClasses, classInfo);
                                        }
                                     }
                                  }
@@ -221,19 +217,16 @@
                                     }
                                  }
                                  
-                                 if (scanClass == null || scanClass.hasMethod(method.getName(), parameterTypes))
+                                 java.lang.annotation.Annotation[] methodAnnotations = 
+                                    method.getDeclaredAnnotations();
+
+                                 if (methodAnnotations != null)
                                  {
-                                    java.lang.annotation.Annotation[] methodAnnotations = 
-                                       method.getDeclaredAnnotations();
-
-                                    if (methodAnnotations != null)
+                                    for (java.lang.annotation.Annotation annotation : methodAnnotations)
                                     {
-                                       for (java.lang.annotation.Annotation annotation : methodAnnotations)
-                                       {
-                                          processAnnotation(annotation, AnnotationType.METHOD, 
-                                                            clz.getName(), method.getName(), parameterTypes,
-                                                            annotationToClasses, classInfo);
-                                       }
+                                       processAnnotation(annotation, AnnotationType.METHOD, 
+                                                         clz.getName(), method.getName(), parameterTypes,
+                                                         ari, annotationToClasses, classInfo);
                                     }
                                  }
                               }
@@ -249,19 +242,16 @@
                                     if (trace)
                                        log.finest("Field=" + field.getName());
                            
-                                    if (scanClass == null || scanClass.hasField(field.getName()))
+                                    java.lang.annotation.Annotation[] fieldAnnotations = 
+                                       field.getDeclaredAnnotations();
+
+                                    if (fieldAnnotations != null)
                                     {
-                                       java.lang.annotation.Annotation[] fieldAnnotations = 
-                                          field.getDeclaredAnnotations();
-
-                                       if (fieldAnnotations != null)
+                                       for (java.lang.annotation.Annotation annotation : fieldAnnotations)
                                        {
-                                          for (java.lang.annotation.Annotation annotation : fieldAnnotations)
-                                          {
-                                             processAnnotation(annotation, AnnotationType.FIELD, 
-                                                               clz.getName(), field.getName(), null,
-                                                               annotationToClasses, classInfo);
-                                          }
+                                          processAnnotation(annotation, AnnotationType.FIELD, 
+                                                            clz.getName(), field.getName(), null,
+                                                            ari, annotationToClasses, classInfo);
                                        }
                                     }
                                  }
@@ -346,10 +336,20 @@
 
       if (trace)
       {
-         log.finest("AnnotationToClasses=" + annotationToClasses);
-         log.finest("ClassInfo=" + classInfo);
+         if (ari != null)
+         {
+            log.finest("ARI=" + ari);
+         }
+         else
+         {
+            log.finest("AnnotationToClasses=" + annotationToClasses);
+            log.finest("ClassInfo=" + classInfo);
+         }
       }
 
+      if (ari != null)
+         return ari;
+
       return new AnnotationRepositoryImpl(annotationToClasses, classInfo);
    }
 
@@ -360,11 +360,13 @@
     * @param className The class name
     * @param memberName The member name
     * @param parameterTypes The parameter types
+    * @param ari The annotation repository implementation loaded from metadata
     * @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, String[] parameterTypes,
+                                  AnnotationRepositoryImpl ari,
                                   Map<String, Collection<String>> annotationToClasses,
                                   Map<String, ClassInfo> classInfo)
    {
@@ -379,15 +381,22 @@
       if (trace)
          log.finest("Annotation=" + a);
 
-      Collection<String> l = annotationToClasses.get(acn);
-      if (l == null)
-         l = new HashSet<String>();
+      if (ari != null)
+      {
+         ari.registerAnnotation(className, acn, a);
+      }
+      else
+      {
+         Collection<String> l = annotationToClasses.get(acn);
+         if (l == null)
+            l = new HashSet<String>();
 
-      l.add(className);
+         l.add(className);
 
-      annotationToClasses.put(acn, l);
+         annotationToClasses.put(acn, l);
 
-      ClassInfo ci = classInfo.get(className);
-      ci.addAnnotation(acn, a);
+         ClassInfo ci = classInfo.get(className);
+         ci.addAnnotation(acn, a);
+      }
    }
 }

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javassistclasspool/JavassistClassPool.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javassistclasspool/JavassistClassPool.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javassistclasspool/JavassistClassPool.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -26,8 +26,6 @@
 import org.jboss.annotations.impl.AbstractJavassistAnnotationScanner;
 import org.jboss.annotations.impl.AnnotationRepositoryImpl;
 import org.jboss.annotations.impl.ClassInfo;
-import org.jboss.annotations.impl.Scan;
-import org.jboss.annotations.impl.ScanClass;
 
 import java.io.Closeable;
 import java.io.File;
@@ -76,6 +74,7 @@
    {
       Map<String, Collection<String>> annotationToClasses = new HashMap<String, Collection<String>>();
       Map<String, ClassInfo> classInfo = new HashMap<String, ClassInfo>();
+      AnnotationRepositoryImpl ari = null;
 
       long start = 0;
       if (log.isLoggable(Level.FINE))
@@ -104,9 +103,9 @@
                File jarFile = new File(u.toURI());
                jar = new JarFile(jarFile);
                   
-               Scan scan = getScan(jar);
+               ari = getScan(jar);
 
-               if (scan != null && scan.isExcludeAll())
+               if (ari != null && ari.getSize() == 0)
                   continue;
 
                List<String> classes = getClassNames(new URL[] {u});
@@ -120,15 +119,7 @@
 
                         if (ctClass.getClassFile2().getMajorVersion() >= ClassFile.JAVA_5 && !ctClass.isAnnotation())
                         {
-                           if (scan == null || scan.hasClass(ctClass.getName()))
-                           {
-                              ScanClass scanClass = null;
-
-                              if (scan != null)
-                                 scanClass = scan.getClass(ctClass.getName());
-
-                              processClass(ctClass, scanClass, annotationToClasses, classInfo);
-                           }
+                           processClass(ctClass, ari, annotationToClasses, classInfo);
                         }
                      }
                      catch (NotFoundException nfe)
@@ -186,10 +177,20 @@
 
       if (trace)
       {
-         log.finest("AnnotationToClasses=" + annotationToClasses);
-         log.finest("ClassInfo=" + classInfo);
+         if (ari != null)
+         {
+            log.finest("ARI=" + ari);
+         }
+         else
+         {
+            log.finest("AnnotationToClasses=" + annotationToClasses);
+            log.finest("ClassInfo=" + classInfo);
+         }
       }
 
+      if (ari != null)
+         return ari;
+
       return new AnnotationRepositoryImpl(annotationToClasses, classInfo);
    }
 }

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javassistinputstream/JavassistInputStream.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javassistinputstream/JavassistInputStream.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/javassistinputstream/JavassistInputStream.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -26,8 +26,6 @@
 import org.jboss.annotations.impl.AbstractJavassistAnnotationScanner;
 import org.jboss.annotations.impl.AnnotationRepositoryImpl;
 import org.jboss.annotations.impl.ClassInfo;
-import org.jboss.annotations.impl.Scan;
-import org.jboss.annotations.impl.ScanClass;
 
 import java.io.Closeable;
 import java.io.File;
@@ -77,6 +75,7 @@
    {
       Map<String, Collection<String>> annotationToClasses = new HashMap<String, Collection<String>>();
       Map<String, ClassInfo> classInfo = new HashMap<String, ClassInfo>();
+      AnnotationRepositoryImpl ari = null;
 
       long start = 0;
       if (log.isLoggable(Level.FINE))
@@ -105,9 +104,9 @@
                File jarFile = new File(u.toURI());
                jar = new JarFile(jarFile);
 
-               Scan scan = getScan(jar);
+               ari = getScan(jar);
 
-               if (scan != null && scan.isExcludeAll())
+               if (ari != null && ari.getSize() == 0)
                   continue;
 
                Enumeration<JarEntry> entries = jar.entries();
@@ -138,15 +137,7 @@
 
                      if (isJava5.booleanValue() && !ctClass.isAnnotation())
                      {
-                        if (scan == null || scan.hasClass(ctClass.getName()))
-                        {
-                           ScanClass scanClass = null;
-
-                           if (scan != null)
-                              scanClass = scan.getClass(ctClass.getName());
-
-                           processClass(ctClass, scanClass, annotationToClasses, classInfo);
-                        }
+                        processClass(ctClass, ari, annotationToClasses, classInfo);
                      }
                   }
                }
@@ -199,10 +190,20 @@
 
       if (trace)
       {
-         log.finest("AnnotationToClasses=" + annotationToClasses);
-         log.finest("ClassInfo=" + classInfo);
+         if (ari != null)
+         {
+            log.finest("ARI=" + ari);
+         }
+         else
+         {
+            log.finest("AnnotationToClasses=" + annotationToClasses);
+            log.finest("ClassInfo=" + classInfo);
+         }
       }
 
+      if (ari != null)
+         return ari;
+
       return new AnnotationRepositoryImpl(annotationToClasses, classInfo);
    }
 }

Modified: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/BinaryLoader.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/BinaryLoader.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/BinaryLoader.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -22,7 +22,7 @@
 
 package org.jboss.annotations.util;
 
-import org.jboss.annotations.impl.Scan;
+import org.jboss.annotations.impl.AnnotationRepositoryImpl;
 
 import java.io.InputStream;
 import java.io.ObjectInputStream;
@@ -45,21 +45,21 @@
    }
 
    /**
-    * Loads the internal representation of the jboss-annotation.xml file
+    * Loads the internal representation of the jboss-annotation.ser file
     * @param is The input stream for the binary file
-    * @return The scanning representation; <code>null</code> if no representation
-    *         can be created
+    * @return The initial annotation repository implementation representation; 
+    *         <code>null</code> if no representation can be created
     */
-   public static Scan loadJBossAnnotation(InputStream is)
+   public static AnnotationRepositoryImpl loadJBossAnnotation(InputStream is)
    {
-      Scan result = null;
+      AnnotationRepositoryImpl result = null;
 
       try
       {
          GZIPInputStream gis = new GZIPInputStream(is);
          ObjectInputStream ois = new ObjectInputStream(gis);
 
-         result = (Scan)ois.readObject();
+         result = (AnnotationRepositoryImpl)ois.readObject();
       }
       catch (Throwable t)
       {

Deleted: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLLoader.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLLoader.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLLoader.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -1,259 +0,0 @@
-/*
- * 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.annotations.util;
-
-import org.jboss.annotations.impl.Scan;
-import org.jboss.annotations.impl.ScanClass;
-import org.jboss.annotations.xml.ClassType;
-import org.jboss.annotations.xml.ConstructorType;
-import org.jboss.annotations.xml.FieldType;
-import org.jboss.annotations.xml.JbossAnnotation;
-import org.jboss.annotations.xml.MethodType;
-import org.jboss.annotations.xml.ParameterType;
-import org.jboss.annotations.xml.ScanType;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * The XML loader class
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class XMLLoader
-{
-   private static Logger log = Logger.getLogger(XMLLoader.class.getName());
-   private static boolean trace = log.isLoggable(Level.FINEST);
-
-   /**
-    * Constructor
-    */
-   private XMLLoader()
-   {
-   }
-
-   /**
-    * Loads a jboss-annotation.xml and transforms it into the internal
-    * scanning representation
-    * @param is The input stream for the XML file
-    * @return The scanning representation; <code>null</code> if no representation
-    *         can be created
-    */
-   public static Scan loadJBossAnnotation(InputStream is)
-   {
-      Scan result = null;
-
-      try
-      {
-         Map<String, ScanClass> data = new HashMap<String, ScanClass>();
-
-         JbossAnnotation ja = createModel(is);
-
-         boolean excludeAll = ja.isExcludeAll();
-
-         if (ja.getScan() != null)
-         {
-            List<ClassType> lCt = ja.getScan().getClazz();
-            for (ClassType ct : lCt)
-            {
-               ScanClass sc = new ScanClass(ct.getName());
-
-               for (FieldType ft : ct.getField())
-               {
-                  sc.addField(ft.getValue());
-               }
-
-               for (ConstructorType con : ct.getConstructor())
-               {
-                  String[] parameters = null;
-
-                  if (con.getParameter().size() > 0)
-                  {
-                     parameters = new String[con.getParameter().size()];
-                     for (int i = 0; i < con.getParameter().size(); i++)
-                     {
-                        ParameterType pt = con.getParameter().get(i);
-                        parameters[i] = pt.getValue();
-                     }
-                  }
-
-                  sc.addConstructor(parameters);
-               }
-
-               for (MethodType mt : ct.getMethod())
-               {
-                  String[] parameters = null;
-
-                  if (mt.getParameter().size() > 0)
-                  {
-                     parameters = new String[mt.getParameter().size()];
-                     for (int i = 0; i < mt.getParameter().size(); i++)
-                     {
-                        ParameterType pt = mt.getParameter().get(i);
-                        parameters[i] = pt.getValue();
-                     }
-                  }
-
-                  sc.addMethod(mt.getName(), parameters);
-               }
-
-               data.put(sc.getClassName(), sc);
-            }
-         }
-
-         result = new Scan(excludeAll, data);
-      }
-      catch (Throwable t)
-      {
-         if (trace)
-            log.finest(t.getMessage());
-      }
-
-      if (trace)
-         log.finest("Scan=" + result);
-
-      return result;
-   }
-
-   /**
-    * Create the XML model
-    * @param is The input stream
-    * @return The model
-    */
-   private static JbossAnnotation createModel(InputStream is)
-   {
-      try
-      {
-         JbossAnnotation result = new JbossAnnotation();
-
-         DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-         Document doc = builder.parse(is);
-
-         NodeList toplevel = doc.getElementsByTagName("jboss-annotation");
-         if (toplevel != null && toplevel.getLength() > 0)
-         {
-            Element root = (Element)toplevel.item(0);
-
-            if (root.hasAttribute("exclude-all"))
-            {
-               Attr a = root.getAttributeNode("exclude-all");
-               result.setExcludeAll(Boolean.valueOf(a.getValue()));
-            }
-
-            NodeList nl = root.getElementsByTagName("scan");
-            if (nl != null && nl.getLength() > 0)
-            {
-               Element scan = (Element)nl.item(0);
-
-               ScanType scanType = new ScanType();
-               result.setScan(scanType);
-
-               NodeList classes = scan.getElementsByTagName("class");
-               for (int i = 0; i < classes.getLength(); i++)
-               {
-                  Element clazz = (Element)classes.item(i);
-
-                  ClassType classType = new ClassType();
-                  Attr className = clazz.getAttributeNode("name");
-                  classType.setName(className.getValue());
-
-                  scanType.getClazz().add(classType);
-
-                  NodeList fields = clazz.getElementsByTagName("field");
-                  for (int j = 0; j < fields.getLength(); j++)
-                  {
-                     Element field = (Element)fields.item(j);
-                     
-                     FieldType fieldType = new FieldType();
-                     fieldType.setValue(field.getTextContent());
-
-                     classType.getField().add(fieldType);
-                  }
-
-                  NodeList constructors = clazz.getElementsByTagName("constructor");
-                  for (int j = 0; j < constructors.getLength(); j++)
-                  {
-                     Element constructor = (Element)constructors.item(j);
-                     
-                     ConstructorType constructorType = new ConstructorType();
-
-                     NodeList parameters = constructor.getElementsByTagName("parameter");
-                     for (int k = 0; k < parameters.getLength(); k++)
-                     {
-                        Element parameter = (Element)parameters.item(k);
-
-                        ParameterType parameterType = new ParameterType();
-                        parameterType.setValue(parameter.getTextContent());
-                        constructorType.getParameter().add(parameterType);
-                     }
-
-                     classType.getConstructor().add(constructorType);
-                  }
-
-                  NodeList methods = clazz.getElementsByTagName("method");
-                  for (int j = 0; j < methods.getLength(); j++)
-                  {
-                     Element method = (Element)methods.item(j);
-                     
-                     MethodType methodType = new MethodType();
-
-                     Attr methodName = method.getAttributeNode("name");
-                     methodType.setName(methodName.getValue());
-
-                     NodeList parameters = method.getElementsByTagName("parameter");
-                     for (int k = 0; k < parameters.getLength(); k++)
-                     {
-                        Element parameter = (Element)parameters.item(k);
-
-                        ParameterType parameterType = new ParameterType();
-                        parameterType.setValue(parameter.getTextContent());
-                        methodType.getParameter().add(parameterType);
-                     }
-
-                     classType.getMethod().add(methodType);
-                  }
-               }
-            }
-         }
-
-         return result;
-      }
-      catch (Throwable t)
-      {
-         log.log(Level.SEVERE, t.getMessage(), t);
-      }
-
-      return null;
-   }
-}

Deleted: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLSaver.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLSaver.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLSaver.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -1,56 +0,0 @@
-/*
- * 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.annotations.util;
-
-import org.jboss.annotations.xml.JbossAnnotation;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.logging.Logger;
-
-/**
- * The XML saver class
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class XMLSaver
-{
-   private static Logger log = Logger.getLogger(XMLSaver.class.getName());
-
-   /**
-    * Constructor
-    */
-   private XMLSaver()
-   {
-   }
-
-   /**
-    * Writes the XML model to a writer
-    * @param root The root of the XML model
-    * @param writer The writer
-    * @exception IOException Thrown if an error occurs
-    */
-   public static void save(JbossAnnotation root, Writer writer) throws IOException
-   {
-      writer.write(root.toXML());
-   }
-}

Modified: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassTests.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassTests.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/ClassTests.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -124,6 +124,7 @@
       assertTrue("Size=" + l.size(), l.size() == 1);
 
       Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
       assertNotNull(annotation.getAnnotation());
       assertTrue(annotation.getType() == AnnotationType.CLASS);
       assertEquals("org.jboss.annotations.test.tests.classlevel.Test", annotation.getClassName());
@@ -151,6 +152,7 @@
       assertTrue("Size=" + l.size(), l.size() == 1);
 
       Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
       assertNotNull(annotation.getAnnotation());
       assertTrue(annotation.getType() == AnnotationType.CONSTRUCTOR);
       assertEquals("org.jboss.annotations.test.tests.classconstructor.Test", annotation.getClassName());
@@ -178,6 +180,7 @@
       assertTrue("Size=" + l.size(), l.size() == 1);
 
       Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
       assertNotNull(annotation.getAnnotation());
       assertTrue(annotation.getType() == AnnotationType.CONSTRUCTOR);
       assertEquals("org.jboss.annotations.test.tests.classconstructorwithparameter.Test", annotation.getClassName());
@@ -205,6 +208,7 @@
       assertTrue("Size=" + l.size(), l.size() == 1);
 
       Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
       assertNotNull(annotation.getAnnotation());
       assertTrue(annotation.getType() == AnnotationType.METHOD);
       assertEquals("org.jboss.annotations.test.tests.classmethod.Test", annotation.getClassName());
@@ -232,6 +236,7 @@
       assertTrue("Size=" + l.size(), l.size() == 1);
 
       Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
       assertNotNull(annotation.getAnnotation());
       assertTrue(annotation.getType() == AnnotationType.METHOD);
       assertEquals("org.jboss.annotations.test.tests.classmethodwithparameter.Test", annotation.getClassName());
@@ -259,6 +264,7 @@
       assertTrue("Size=" + l.size(), l.size() == 1);
 
       Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
       assertNotNull(annotation.getAnnotation());
       assertTrue(annotation.getType() == AnnotationType.FIELD);
       assertEquals("org.jboss.annotations.test.tests.classfield.Test", annotation.getClassName());
@@ -289,6 +295,7 @@
       {
          if ("org.jboss.annotations.test.tests.classinterface.Test".equals(annotation.getClassName()))
          {
+            assertNotNull(annotation.getAnnotationClassName());
             assertNotNull(annotation.getAnnotation());
             assertTrue(annotation.getType() == AnnotationType.CLASS);
             assertNull(annotation.getMemberName());
@@ -296,6 +303,7 @@
          }
          else if ("org.jboss.annotations.test.tests.classinterface.ITest".equals(annotation.getClassName()))
          {
+            assertNotNull(annotation.getAnnotationClassName());
             assertNotNull(annotation.getAnnotation());
             assertTrue(annotation.getType() == AnnotationType.CLASS);
             assertNull(annotation.getMemberName());
@@ -331,6 +339,7 @@
       {
          if ("org.jboss.annotations.test.tests.classinterfacemethod.Test".equals(annotation.getClassName()))
          {
+            assertNotNull(annotation.getAnnotationClassName());
             assertNotNull(annotation.getAnnotation());
             assertTrue(annotation.getType() == AnnotationType.METHOD);
             assertEquals("myMethod", annotation.getMemberName());
@@ -338,6 +347,7 @@
          }
          else if ("org.jboss.annotations.test.tests.classinterfacemethod.ITest".equals(annotation.getClassName()))
          {
+            assertNotNull(annotation.getAnnotationClassName());
             assertNotNull(annotation.getAnnotation());
             assertTrue(annotation.getType() == AnnotationType.METHOD);
             assertEquals("myMethod", annotation.getMemberName());

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InheritanceTests.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InheritanceTests.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InheritanceTests.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,140 @@
+/*
+ * 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.annotations.test;
+
+import org.jboss.annotations.Annotation;
+import org.jboss.annotations.AnnotationRepository;
+import org.jboss.annotations.AnnotationScanner;
+import org.jboss.annotations.AnnotationType;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.logging.Logger;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test for annotations in inheritance scenarios
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+public abstract class InheritanceTests extends AnnotationTests
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static Logger log = Logger.getLogger(InheritanceTests.class.getName());
+
+   /** The scanner instance */
+   protected static AnnotationScanner scanner = null;
+
+   // --------------------------------------------------------------------------------||
+   // Tests --------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Defined
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testDefined() throws Throwable
+   {
+      assertNotNull(scanner);
+   }
+
+   /**
+    * Abstract base class
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testAbstractBaseClass() throws Throwable
+   {
+      URL archive = getURL("inheritanceclassabstract.jar");
+      AnnotationRepository ar = scanner.scan(new URL[] {archive});
+
+      assertNotNull(ar);
+
+      assertTrue(ar.hasAnnotation(Deprecated.class));
+
+      Collection<Annotation> l = ar.getAnnotation(Deprecated.class);
+
+      assertNotNull(l);
+      assertTrue("Size=" + l.size(), l.size() == 1);
+
+      Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
+      assertNotNull(annotation.getAnnotation());
+      assertTrue(annotation.getType() == AnnotationType.CLASS);
+      assertEquals("org.jboss.annotations.test.tests.inheritanceclassabstract.Test", annotation.getClassName());
+      assertNull(annotation.getMemberName());
+      assertNull(annotation.getParameterTypes());
+   }
+
+   /**
+    * Base class
+    * @throws Throwable throwable exception 
+    */
+   @Test
+   public void testBaseClass() throws Throwable
+   {
+      URL archive = getURL("inheritanceclassclass.jar");
+      AnnotationRepository ar = scanner.scan(new URL[] {archive});
+
+      assertNotNull(ar);
+
+      assertTrue(ar.hasAnnotation(Deprecated.class));
+
+      Collection<Annotation> l = ar.getAnnotation(Deprecated.class);
+
+      assertNotNull(l);
+      assertTrue("Size=" + l.size(), l.size() == 2);
+
+      for (Annotation annotation : l)
+      {
+         if ("org.jboss.annotations.test.tests.inheritanceclassclass.BaseTest".equals(annotation.getClassName()))
+         {
+            assertNotNull(annotation.getAnnotationClassName());
+            assertNotNull(annotation.getAnnotation());
+            assertTrue(annotation.getType() == AnnotationType.CLASS);
+            assertNull(annotation.getMemberName());
+            assertNull(annotation.getParameterTypes());
+         }
+         else if ("org.jboss.annotations.test.tests.inheritanceclassclass.Test".equals(annotation.getClassName()))
+         {
+            assertNotNull(annotation.getAnnotationClassName());
+            assertNotNull(annotation.getAnnotation());
+            assertTrue(annotation.getType() == AnnotationType.CLASS);
+            assertNull(annotation.getMemberName());
+            assertNull(annotation.getParameterTypes());
+         }
+         else
+         {
+            fail("Unknown annotation location");
+         }
+      }
+   }
+}

Modified: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InterfaceTests.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InterfaceTests.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/InterfaceTests.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -104,6 +104,7 @@
       assertTrue("Size=" + l.size(), l.size() == 1);
 
       Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
       assertNotNull(annotation.getAnnotation());
       assertTrue(annotation.getType() == AnnotationType.CLASS);
       assertEquals("org.jboss.annotations.test.tests.interfacelevel.Test", annotation.getClassName());
@@ -131,6 +132,7 @@
       assertTrue("Size=" + l.size(), l.size() == 1);
 
       Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
       assertNotNull(annotation.getAnnotation());
       assertTrue(annotation.getType() == AnnotationType.METHOD);
       assertEquals("org.jboss.annotations.test.tests.interfacemethod.Test", annotation.getClassName());
@@ -158,6 +160,7 @@
       assertTrue("Size=" + l.size(), l.size() == 1);
 
       Annotation annotation = l.iterator().next();
+      assertNotNull(annotation.getAnnotationClassName());
       assertNotNull(annotation.getAnnotation());
       assertTrue(annotation.getType() == AnnotationType.METHOD);
       assertEquals("org.jboss.annotations.test.tests.interfacemethodwithparameter.Test", annotation.getClassName());

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javalangreflect/unit/InheritanceTestCase.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javalangreflect/unit/InheritanceTestCase.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javalangreflect/unit/InheritanceTestCase.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,72 @@
+/*
+ * 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.annotations.test.javalangreflect.unit;
+
+import org.jboss.annotations.AnnotationScannerFactory;
+import org.jboss.annotations.test.InheritanceTests;
+
+import java.util.logging.Logger;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test for annotations in inheritance scenarios
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+public class InheritanceTestCase extends InheritanceTests
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static Logger log = Logger.getLogger(InheritanceTestCase.class.getName());
+
+   // --------------------------------------------------------------------------------||
+   // Lifecycle Methods --------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Lifecycle start, before the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @BeforeClass
+   public static void beforeClass() throws Throwable
+   {
+      scanner = AnnotationScannerFactory.getStrategy(AnnotationScannerFactory.JAVA_LANG_REFLECT);
+   }
+
+   /**
+    * Lifecycle stop, after the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @AfterClass
+   public static void afterClass() throws Throwable
+   {
+      scanner = null;
+   }
+}

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javassistclasspool/unit/InheritanceTestCase.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javassistclasspool/unit/InheritanceTestCase.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javassistclasspool/unit/InheritanceTestCase.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,72 @@
+/*
+ * 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.annotations.test.javassistclasspool.unit;
+
+import org.jboss.annotations.AnnotationScannerFactory;
+import org.jboss.annotations.test.InheritanceTests;
+
+import java.util.logging.Logger;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test for annotations in inheritance scenarios
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+public class InheritanceTestCase extends InheritanceTests
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static Logger log = Logger.getLogger(InheritanceTestCase.class.getName());
+
+   // --------------------------------------------------------------------------------||
+   // Lifecycle Methods --------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Lifecycle start, before the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @BeforeClass
+   public static void beforeClass() throws Throwable
+   {
+      scanner = AnnotationScannerFactory.getStrategy(AnnotationScannerFactory.JAVASSIST_CLASS_POOL);
+   }
+
+   /**
+    * Lifecycle stop, after the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @AfterClass
+   public static void afterClass() throws Throwable
+   {
+      scanner = null;
+   }
+}

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javassistinputstream/unit/InheritanceTestCase.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javassistinputstream/unit/InheritanceTestCase.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/javassistinputstream/unit/InheritanceTestCase.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,72 @@
+/*
+ * 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.annotations.test.javassistinputstream.unit;
+
+import org.jboss.annotations.AnnotationScannerFactory;
+import org.jboss.annotations.test.InheritanceTests;
+
+import java.util.logging.Logger;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test for annotations in inheritance scenarios
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+public class InheritanceTestCase extends InheritanceTests
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static Logger log = Logger.getLogger(InheritanceTestCase.class.getName());
+
+   // --------------------------------------------------------------------------------||
+   // Lifecycle Methods --------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Lifecycle start, before the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @BeforeClass
+   public static void beforeClass() throws Throwable
+   {
+      scanner = AnnotationScannerFactory.getStrategy(AnnotationScannerFactory.JAVASSIST_INPUT_STREAM);
+   }
+
+   /**
+    * Lifecycle stop, after the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @AfterClass
+   public static void afterClass() throws Throwable
+   {
+      scanner = null;
+   }
+}

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/AbstractTest.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/AbstractTest.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/AbstractTest.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,31 @@
+/*
+ * 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.annotations.test.tests.inheritanceclassabstract;
+
+/**
+ * Abstract Test
+ */
+ at Deprecated
+public abstract class AbstractTest
+{
+}

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/Test.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/Test.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/Test.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,30 @@
+/*
+ * 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.annotations.test.tests.inheritanceclassabstract;
+
+/**
+ * Test
+ */
+public class Test extends AbstractTest
+{
+}

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/package.html
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/package.html	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassabstract/package.html	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,3 @@
+<body>
+An abstract base class with a class level annotation
+</body>

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/BaseTest.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/BaseTest.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/BaseTest.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,31 @@
+/*
+ * 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.annotations.test.tests.inheritanceclassclass;
+
+/**
+ * Base Test
+ */
+ at Deprecated
+public class BaseTest
+{
+}

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/Test.java
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/Test.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/Test.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,30 @@
+/*
+ * 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.annotations.test.tests.inheritanceclassclass;
+
+/**
+ * Test
+ */
+public class Test extends BaseTest
+{
+}

Added: projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/package.html
===================================================================
--- projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/package.html	                        (rev 0)
+++ projects/annotations/trunk/core/src/test/java/org/jboss/annotations/test/tests/inheritanceclassclass/package.html	2009-08-28 21:37:32 UTC (rev 92985)
@@ -0,0 +1,3 @@
+<body>
+A  base class with a class level annotation
+</body>

Modified: projects/annotations/trunk/doc/userguide/en/modules/ant.xml
===================================================================
--- projects/annotations/trunk/doc/userguide/en/modules/ant.xml	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/doc/userguide/en/modules/ant.xml	2009-08-28 21:37:32 UTC (rev 92985)
@@ -13,7 +13,7 @@
 &lt;taskdef name="indexer" classname="org.jboss.annotations.indexer.IndexerTask"/&gt;
     </programlisting>
 
-    <para>The Indexer will generate the project specific metadata files which describes
+    <para>The Indexer will generate the project specific metadata file which describes
       where annotations are located, such that the entire archive doesn't have to be
       scanned.</para>
 
@@ -44,13 +44,6 @@
             </entry>
           </row>
           <row>
-            <entry>mode</entry>
-            <entry>
-              The metadata mode: xml|binary|both (Default: both)
-              <para>xml = 'jboss-annotation.xml', binary = 'jboss-annotation.ser'</para>
-            </entry>
-          </row>
-          <row>
             <entry>update</entry>
             <entry>
               Should the output file be updated with metadata ? (Default: true).

Modified: projects/annotations/trunk/doc/userguide/en/modules/troubleshooting.xml
===================================================================
--- projects/annotations/trunk/doc/userguide/en/modules/troubleshooting.xml	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/doc/userguide/en/modules/troubleshooting.xml	2009-08-28 21:37:32 UTC (rev 92985)
@@ -2,6 +2,26 @@
 <chapter id="troubleshooting">
    <title>Troubleshooting</title>
 
+   <section id="submittingapatch">
+      <title>How do I: Submit a patch ?</title>
+
+      <para>So you want to submit a patch for the project, great ! There are a number of steps though;
+        first of course you have to implement the functionality and the test cases needed for testing.</para>
+
+      <para>Then you must execute the following statements:</para>
+
+      <programlisting>
+ant clean test
+ant clean test-indexer
+ant clean checkstyle
+ant clean findbugs
+ant clean cobertura
+      </programlisting>
+
+      <para>Once the test suite is clean and all the QE environments are passing too, submit your patch
+        to our JIRA installation.</para>
+   </section>
+
    <section id="howdoi">
       <title>How do I ?</title>
 

Modified: projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/IndexerTask.java
===================================================================
--- projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/IndexerTask.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/IndexerTask.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -22,8 +22,13 @@
 
 package org.jboss.annotations.indexer;
 
+import org.jboss.annotations.AnnotationScanner;
+import org.jboss.annotations.AnnotationScannerFactory;
+import org.jboss.annotations.impl.AnnotationRepositoryImpl;
+
 import java.io.File;
 import java.io.IOException;
+import java.net.URL;
 import java.util.logging.Logger;
 
 import org.apache.tools.ant.BuildException;
@@ -39,7 +44,6 @@
 
    private File input;
    private File output;
-   private String mode;
    private boolean update;
    private File metadata;
    
@@ -50,7 +54,6 @@
    {
       input = null;
       output = null;
-      mode = "both";
       update = true;
       metadata = null;
    }
@@ -92,24 +95,6 @@
    }
 
    /**
-    * Get the mode
-    * @return The mode
-    */
-   public String getMode()
-   {
-      return mode;
-   }
-
-   /**
-    * Set the mode
-    * @param s The mode
-    */
-   public void setMode(String s)
-   {
-      mode = s;
-   }
-
-   /**
     * Get the update mode
     * @return The mode
     */
@@ -158,81 +143,36 @@
 
          Main m = new Main();
             
-         boolean binary = false;
-         boolean xml = false;
+         AnnotationScanner as = AnnotationScannerFactory.getStrategy(AnnotationScannerFactory.JAVA_LANG_REFLECT);
+         AnnotationRepositoryImpl ari = (AnnotationRepositoryImpl)as.scan(new URL[] {input.toURI().toURL()});
 
-         if ("binary".equalsIgnoreCase(mode))
+         if (update)
          {
-            binary = true;
-         }
-         else if ("xml".equalsIgnoreCase(mode))
-         {
-            xml = true;
-         }
-         else if ("both".equalsIgnoreCase(mode))
-         {
-            binary = true;
-            xml = true;
-         }
-
-         if (binary || xml)
-         {
             File tmp = new File(System.getProperty("java.io.tmpdir"));
 
-            if (update)
-            {
-               File root = FileUtil.extract(input, tmp);
-               File destination = new File(root, "META-INF");
+            File root = FileUtil.extract(input, tmp);
+            File destination = new File(root, "META-INF");
 
-               File xmlFile = null;
-               if (xml)
-               {
-                  xmlFile = m.generateXML(input, destination);
-               }
-               else
-               {
-                  xmlFile = m.generateXML(input, tmp);
-               }
+            m.store(ari, destination);
 
-               if (binary)
-                  m.generateBinary(xmlFile, destination);
-
-               FileUtil.compress(root, output);
+            FileUtil.compress(root, output);
                
-               FileUtil.recursiveDelete(root);
-            
-               if (!xml)
-                  FileUtil.recursiveDelete(xmlFile);
+            FileUtil.recursiveDelete(root);
+         }
+         else
+         {
+            if (metadata.exists())
+            {
+               if (metadata.isFile())
+                  throw new IOException("Metadata should be a directory: " + metadata);
             }
             else
             {
-               if (metadata.exists())
-               {
-                  if (metadata.isFile())
-                     throw new IOException("Metadata should be a directory: " + metadata);
-               }
-               else
-               {
-                  if (!metadata.mkdirs())
-                     throw new IOException("Unable to create directory: " + metadata);
-               }
-
-               File xmlFile = null;
-               if (xml)
-               {
-                  xmlFile = m.generateXML(input, metadata);
-               }
-               else
-               {
-                  xmlFile = m.generateXML(input, tmp);
-               }
-
-               if (binary)
-                  m.generateBinary(xmlFile, metadata);
-
-               if (!xml)
-                  FileUtil.recursiveDelete(xmlFile);
+               if (!metadata.mkdirs())
+                  throw new IOException("Unable to create directory: " + metadata);
             }
+
+            m.store(ari, metadata);
          }
       }
       catch (Throwable t)

Modified: projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/Main.java
===================================================================
--- projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/Main.java	2009-08-28 20:53:17 UTC (rev 92984)
+++ projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/Main.java	2009-08-28 21:37:32 UTC (rev 92985)
@@ -22,35 +22,16 @@
 
 package org.jboss.annotations.indexer;
 
-import org.jboss.annotations.Annotation;
-import org.jboss.annotations.AnnotationRepository;
 import org.jboss.annotations.AnnotationScanner;
 import org.jboss.annotations.AnnotationScannerFactory;
-import org.jboss.annotations.AnnotationType;
 import org.jboss.annotations.impl.AbstractAnnotationScanner;
-import org.jboss.annotations.impl.Scan;
-import org.jboss.annotations.util.XMLLoader;
-import org.jboss.annotations.util.XMLSaver;
-import org.jboss.annotations.xml.ClassType;
-import org.jboss.annotations.xml.ConstructorType;
-import org.jboss.annotations.xml.FieldType;
-import org.jboss.annotations.xml.JbossAnnotation;
-import org.jboss.annotations.xml.MethodType;
-import org.jboss.annotations.xml.ParameterType;
-import org.jboss.annotations.xml.ScanType;
-
+import org.jboss.annotations.impl.AnnotationRepositoryImpl;
+ 
 import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileOutputStream;
-import java.io.FileWriter;
 import java.io.ObjectOutputStream;
-import java.io.Writer;
 import java.net.URL;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.zip.GZIPOutputStream;
@@ -71,187 +52,37 @@
    }
 
    /**
-    * Generate binary
-    * @param f The JAR file
+    * Store
+    * @param ari The annotation repository implementation
     * @param directory The destination directory
     * @exception Exception Thrown if an error occurs
     */
-   public void generateBinary(File f, File directory) throws Exception
+   public void store(AnnotationRepositoryImpl ari, File directory) throws Exception
    {
-      if (f == null || !f.exists())
-         throw new IllegalArgumentException("File is null");
+      if (ari == null)
+         throw new IllegalArgumentException("ARI is null");
 
       if (directory == null || !directory.exists())
          throw new IllegalArgumentException("Directory is null");
 
-      FileInputStream fis = new FileInputStream(f);
-
-      Scan scan = XMLLoader.loadJBossAnnotation(fis);
-
       File file = new File(directory, AbstractAnnotationScanner.JBOSS_ANNOTATION_BINARY);
       FileOutputStream fos = new FileOutputStream(file);
       BufferedOutputStream bos = new BufferedOutputStream(fos);
       GZIPOutputStream gos = new GZIPOutputStream(bos);
       ObjectOutputStream oos = new ObjectOutputStream(gos);
 
-      oos.writeObject(scan);
+      oos.writeObject(ari);
 
       oos.flush();
       oos.close();
    }
 
    /**
-    * Generate XML
-    * @param f The JAR file
-    * @param directory The destination directory
-    * @return The XML file 
-    * @exception Exception Thrown if an error occurs
-    */
-   public File generateXML(File f, File directory) throws Exception
-   {
-      if (f == null || !f.exists())
-         throw new IllegalArgumentException("File is null");
-
-      if (directory == null || !directory.exists())
-         throw new IllegalArgumentException("Directory is null");
-
-      AnnotationScanner scanner = 
-         AnnotationScannerFactory.getStrategy(AnnotationScannerFactory.JAVA_LANG_REFLECT);
-
-      AnnotationRepository repository = scanner.scan(new URL[] {f.toURI().toURL()});
-
-      JbossAnnotation root = new JbossAnnotation();
-      root.setExcludeAll(Boolean.TRUE);
-
-      ScanType scanType = new ScanType();
-      root.setScan(scanType);
-
-      Set<String> keys = repository.getAvailableAnnotations();
-      if (keys.size() > 0)
-      {
-         root.setExcludeAll(Boolean.FALSE);
-
-         for (String key : keys)
-         {
-            Collection<Annotation> l = repository.getAnnotation(key);
-
-            if (l != null)
-            {
-               for (Annotation a : l)
-               {
-                  AnnotationType type = a.getType();
-                  String className = a.getClassName();
-
-                  ClassType ct = getClassType(className, scanType.getClazz());
-
-                  if (type == AnnotationType.CLASS)
-                  {
-                     // Nothing else to do
-                  }
-                  else if (type == AnnotationType.FIELD)
-                  {
-                     FieldType ft = new FieldType();
-                     ft.setValue(a.getMemberName());
-                     ct.getField().add(ft);
-                  }
-                  else if (type == AnnotationType.CONSTRUCTOR)
-                  {
-                     ConstructorType cont = new ConstructorType();
-
-                     if (a.getParameterTypes() != null)
-                     {
-                        for (String parameter : a.getParameterTypes())
-                        {
-                           ParameterType pt = new ParameterType();
-                           pt.setValue(parameter);
-                           cont.getParameter().add(pt);
-                        }
-                     }
-
-                     ct.getConstructor().add(cont);
-                  }
-                  else if (type == AnnotationType.METHOD)
-                  {
-                     MethodType mt = new MethodType();
-                     mt.setName(a.getMemberName());
-
-                     if (a.getParameterTypes() != null)
-                     {
-                        for (String parameter : a.getParameterTypes())
-                        {
-                           ParameterType pt = new ParameterType();
-                           pt.setValue(parameter);
-                           mt.getParameter().add(pt);
-                        }
-                     }
-                     
-                     ct.getMethod().add(mt);
-                  }
-               }
-            }
-         }
-      }
-
-      File output = new File(directory, AbstractAnnotationScanner.JBOSS_ANNOTATION_XML);
-      Writer writer = new FileWriter(output);
-      writer = new BufferedWriter(writer);
-
-      XMLSaver.save(root, writer);
-
-      writer.flush();
-      writer.close();
-
-      return output;
-   }
-
-   /**
-    * Get class type
-    * @param className The class name
-    * @param list The class type list
-    * @return The class type
-    */
-   private ClassType getClassType(String className, List<ClassType> list)
-   {
-      ClassType type = findClassType(className, list);
-
-      if (type == null)
-      {
-         type = new ClassType();
-         type.setName(className);
-         list.add(type);
-      }
-
-      return type;
-   }
-
-   /**
-    * Find a class type
-    * @param className The class name
-    * @param list The class type list
-    * @return The class type; <code>null</code> if the list doesn't contain a reference
-    */
-   private ClassType findClassType(String className, List<ClassType> list)
-   {
-      if (list != null)
-      {
-         for (ClassType ct : list)
-         {
-            if (ct.getName().equals(className))
-            {
-               return ct;
-            }
-         }
-      }
-
-      return null;
-   }
-
-   /**
     * Usage
     */
    private static void usage()
    {
-      System.out.println("Usage: Indexer <binary|xml|both> <input-jar> <output-jar>");
+      System.out.println("Usage: Indexer <input-jar> <output-jar>");
    }
 
    /**
@@ -262,57 +93,26 @@
    {
       try
       {
-         if (args.length == 3)
+         if (args.length == 2)
          {
             Main m = new Main();
             
-            boolean binary = false;
-            boolean xml = false;
+            File input = new File(args[0]);
+            File output = new File(args[1]);
 
-            if ("binary".equalsIgnoreCase(args[0]))
-            {
-               binary = true;
-            }
-            else if ("xml".equalsIgnoreCase(args[0]))
-            {
-               xml = true;
-            }
-            else if ("both".equalsIgnoreCase(args[0]))
-            {
-               binary = true;
-               xml = true;
-            }
+            File tmp = new File(System.getProperty("java.io.tmpdir"));
 
-            if (binary || xml)
-            {
-               File input = new File(args[1]);
-               File output = new File(args[2]);
+            File root = FileUtil.extract(input, tmp);
+            File destination = new File(root, "META-INF");
 
-               File tmp = new File(System.getProperty("java.io.tmpdir"));
+            AnnotationScanner as = AnnotationScannerFactory.getStrategy(AnnotationScannerFactory.JAVA_LANG_REFLECT);
+            AnnotationRepositoryImpl ari = (AnnotationRepositoryImpl)as.scan(new URL[] {input.toURI().toURL()});
 
-               File root = FileUtil.extract(input, tmp);
-               File destination = new File(root, "META-INF");
+            m.store(ari, destination);
 
-               File xmlFile = null;
-               if (xml)
-               {
-                  xmlFile = m.generateXML(input, destination);
-               }
-               else
-               {
-                  xmlFile = m.generateXML(input, tmp);
-               }
-
-               if (binary)
-                  m.generateBinary(xmlFile, destination);
-
-               FileUtil.compress(root, output);
+            FileUtil.compress(root, output);
                
-               FileUtil.recursiveDelete(root);
-               
-               if (!xml)
-                  FileUtil.recursiveDelete(xmlFile);
-            }
+            FileUtil.recursiveDelete(root);
          }
          else
          {




More information about the jboss-cvs-commits mailing list