[jboss-cvs] JBossAS SVN: r92393 - in projects/annotations/trunk: core and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 14 16:21:16 EDT 2009


Author: jesper.pedersen
Date: 2009-08-14 16:21:16 -0400 (Fri, 14 Aug 2009)
New Revision: 92393

Added:
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/BinaryLoader.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/
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ClassType.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ConstructorType.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/FieldType.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/JbossAnnotation.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/MethodType.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ParameterType.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ScanType.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/package.html
   projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/IndexerTask.java
   projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/package.html
Removed:
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/BinaryLoader.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/XMLLoader.java
Modified:
   projects/annotations/trunk/build.xml
   projects/annotations/trunk/core/build.xml
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.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/Scan.java
   projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ScanClass.java
   projects/annotations/trunk/core/src/main/resources/core-manifest.mf
   projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/Main.java
   projects/annotations/trunk/indexer/src/main/resources/indexer-manifest.mf
   projects/annotations/trunk/ivy.xml
Log:
[JBANN-9] [JBANN-10] [JBANN-24] Indexer and its Ant task

Modified: projects/annotations/trunk/build.xml
===================================================================
--- projects/annotations/trunk/build.xml	2009-08-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/build.xml	2009-08-14 20:21:16 UTC (rev 92393)
@@ -74,6 +74,7 @@
        Versions              
        ================================= -->
   <property name="version.activation" value="1.1.1"/>
+  <property name="version.ant" value="1.6.5"/>
   <property name="version.jaxb.api" value="2.1"/>
   <property name="version.jaxb.impl" value="2.1"/>
   <property name="version.jaxb.xjc" value="2.1.6"/>
@@ -167,6 +168,13 @@
   </target>
   
   <!-- ================================= 
+       Target: test-indexer
+       ================================= -->
+  <target name="test-indexer" depends="prepare-test">
+    <ant dir="core" inheritRefs="true" target="test-indexer"/>
+  </target>
+  
+  <!-- ================================= 
        Target: one-test
        ================================= -->
   <target name="one-test" depends="prepare-test">

Modified: projects/annotations/trunk/core/build.xml
===================================================================
--- projects/annotations/trunk/core/build.xml	2009-08-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/core/build.xml	2009-08-14 20:21:16 UTC (rev 92393)
@@ -37,36 +37,9 @@
   </target>
 
   <!-- ================================= 
-       Target: compile jboss-annotations.xsd
-       ================================= -->
-  <target name="compile-jboss-annotations-xsd" depends="init">
-    <taskdef name="xjc"
-             classname="com.sun.tools.xjc.XJCTask"
-             classpathref="core.lib.path.id"/>
-    <xjc schema="src/main/resources/jboss-annotation.xsd"
-         destdir="${build.core.dir}/impl"
-         package="org.jboss.annotations.xml"/>
-    <javac srcdir="${build.core.dir}/impl"
-           destdir="${build.core.dir}/impl"
-           classpathref="core.lib.path.id"
-           debug="${javac.debug}"
-           deprecation="${javac.deprecation}"
-           optimize="${javac.optimize}">
-      <compilerarg value="-Xlint"/>
-    </javac>
-<!--
-    <delete>
-      <fileset dir="${build.core.dir}/impl">
-        <include name="**/*.java"/>
-      </fileset>
-    </delete>
--->
-  </target>
-
-  <!-- ================================= 
        Target: compile
        ================================= -->
-  <target name="compile" depends="compile-jboss-annotations-xsd">
+  <target name="compile" depends="init">
     <javac srcdir="src/main"
            destdir="${build.core.dir}/impl"
            classpathref="core.lib.path.id"
@@ -143,6 +116,66 @@
   </target>
 
   <!-- ================================= 
+       Target: test-indexer
+       ================================= -->
+  <target name="test-indexer" depends="jars, prepare-test">
+    <taskdef name="indexer"
+             classname="org.jboss.annotations.indexer.IndexerTask"
+             classpathref="core.lib.path.id"/>
+
+    <indexer input="${build.core.dir}/testjars/classabstract.jar"/>
+    <indexer input="${build.core.dir}/testjars/classconstructor.jar"/>
+    <indexer input="${build.core.dir}/testjars/classconstructorwithparameter.jar"/>
+    <indexer input="${build.core.dir}/testjars/classempty.jar"/>
+    <indexer input="${build.core.dir}/testjars/classinterface.jar"/>
+    <indexer input="${build.core.dir}/testjars/classinterfacemethod.jar"/>
+    <indexer input="${build.core.dir}/testjars/classlevel.jar"/>
+    <indexer input="${build.core.dir}/testjars/classmethod.jar"/>
+    <indexer input="${build.core.dir}/testjars/classmethodwithparameter.jar"/>
+    <indexer input="${build.core.dir}/testjars/classfield.jar"/>
+    <indexer input="${build.core.dir}/testjars/interfaceempty.jar"/>
+    <indexer input="${build.core.dir}/testjars/interfacelevel.jar"/>
+    <indexer input="${build.core.dir}/testjars/interfacemethod.jar"/>
+    <indexer input="${build.core.dir}/testjars/interfacemethodwithparameter.jar"/>
+
+    <mkdir dir="${reports.dir}"/>
+    <mkdir dir="${reports.dir}/indexer"/>
+
+    <junit dir="src/test"
+           printsummary="${junit.printsummary}"
+           haltonerror="${junit.haltonerror}"
+           haltonfailure="${junit.haltonfailure}"
+           fork="${junit.fork}"
+           timeout="${junit.timeout}">
+      
+      <jvmarg line="${junit.jvm.options}"/>
+      <sysproperty key="test.dir" value="${test.dir}"/>
+      <sysproperty key="archives.dir" value="${build.core.dir}/testjars"/>
+      <sysproperty key="java.util.logging.config.file" value="${build.core.dir}/test/logging.properties"/>
+
+      <classpath>
+        <pathelement location="${build.core.dir}/test"/>
+        <fileset dir="${target.dir}" includes="*.jar"/>
+        <fileset dir="${lib.dir}/test" includes="*.jar" />
+      </classpath>
+      
+      <formatter type="plain"/>
+      <formatter type="xml"/>
+      
+      <batchtest todir="${reports.dir}/indexer"
+                 haltonerror="${junit.batchtest.haltonerror}"
+                 haltonfailure="${junit.batchtest.haltonfailure}"
+                 fork="${junit.batchtest.fork}">
+        
+        <fileset dir="${build.core.dir}/test">
+          <include name="**/*TestCase.class"/>
+        </fileset>
+      </batchtest>
+
+    </junit>
+  </target>
+
+  <!-- ================================= 
        Target: test
        ================================= -->
   <target name="test" depends="jars, prepare-test">

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-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AbstractAnnotationScanner.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -24,8 +24,10 @@
 
 import org.jboss.annotations.AnnotationRepository;
 import org.jboss.annotations.AnnotationScanner;
+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;

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-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/AnnotationRepositoryImpl.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -152,4 +152,19 @@
 
       return l.size();
    }
+
+   /**
+    * String representation
+    * @return The string
+    */
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder(AnnotationRepositoryImpl.class.getName());
+
+      sb = sb.append("{");
+      sb = sb.append("Data=" + repository);
+      sb = sb.append("}");
+
+      return sb.toString();
+   }
 }

Deleted: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/BinaryLoader.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/BinaryLoader.java	2009-08-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/BinaryLoader.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -1,69 +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.InputStream;
-import java.io.ObjectInputStream;
-import java.util.logging.Logger;
-import java.util.zip.GZIPInputStream;
-
-/**
- * The binary loader class
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class BinaryLoader
-{
-   private static Logger log = Logger.getLogger(BinaryLoader.class.getName());
-
-   /**
-    * Constructor
-    */
-   private BinaryLoader()
-   {
-   }
-
-   /**
-    * Loads the internal representation of the jboss-annotation.xml file
-    * @param is The input stream for the binary file
-    * @return The scanning representation; <code>null</code> if no representation
-    *         can be created
-    */
-   public static Scan loadJBossAnnotation(InputStream is)
-   {
-      Scan result = null;
-
-      try
-      {
-         GZIPInputStream gis = new GZIPInputStream(is);
-         ObjectInputStream ois = new ObjectInputStream(gis);
-
-         result = (Scan)ois.readObject();
-      }
-      catch (Throwable t)
-      {
-         log.finest(t.getMessage());
-      }
-
-      return result;
-   }
-}

Modified: 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-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/Scan.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -88,4 +88,20 @@
 
       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();
+   }
 }

Modified: 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-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/ScanClass.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -65,6 +65,15 @@
    }
 
    /**
+    * Get the class name
+    * @return The class name
+    */
+   public String getClassName()
+   {
+      return className;
+   }
+
+   /**
     * Add a field
     * @param name The field name
     */
@@ -182,4 +191,22 @@
 
       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();
+   }
 }

Deleted: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/XMLLoader.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/XMLLoader.java	2009-08-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/XMLLoader.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -1,135 +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 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 java.io.InputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-
-
-/**
- * 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());
-
-   /**
-    * 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>();
-
-         JAXBContext fileJc = JAXBContext.newInstance("org.jboss.annotations.xml");
-         Unmarshaller fileU = fileJc.createUnmarshaller();
-         JbossAnnotation ja = (JbossAnnotation)fileU.unmarshal(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);
-               }
-            }
-         }
-
-         result = new Scan(excludeAll, data);
-      }
-      catch (Throwable t)
-      {
-         log.finest(t.getMessage());
-      }
-
-      return result;
-   }
-}

Copied: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/BinaryLoader.java (from rev 92284, projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/BinaryLoader.java)
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/BinaryLoader.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/BinaryLoader.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,71 @@
+/*
+ * 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 java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.util.logging.Logger;
+import java.util.zip.GZIPInputStream;
+
+/**
+ * The binary loader class
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class BinaryLoader
+{
+   private static Logger log = Logger.getLogger(BinaryLoader.class.getName());
+
+   /**
+    * Constructor
+    */
+   private BinaryLoader()
+   {
+   }
+
+   /**
+    * Loads the internal representation of the jboss-annotation.xml file
+    * @param is The input stream for the binary file
+    * @return The scanning representation; <code>null</code> if no representation
+    *         can be created
+    */
+   public static Scan loadJBossAnnotation(InputStream is)
+   {
+      Scan result = null;
+
+      try
+      {
+         GZIPInputStream gis = new GZIPInputStream(is);
+         ObjectInputStream ois = new ObjectInputStream(gis);
+
+         result = (Scan)ois.readObject();
+      }
+      catch (Throwable t)
+      {
+         log.finest(t.getMessage());
+      }
+
+      return result;
+   }
+}

Copied: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLLoader.java (from rev 92284, projects/annotations/trunk/core/src/main/java/org/jboss/annotations/impl/XMLLoader.java)
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLLoader.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLLoader.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,259 @@
+/*
+ * 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;
+   }
+}

Added: 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	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/util/XMLSaver.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,56 @@
+/*
+ * 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());
+   }
+}

Added: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ClassType.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ClassType.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ClassType.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,136 @@
+/*
+ * 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.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Represents a class
+ */
+public class ClassType
+{
+   private static final String EOL = System.getProperty("line.separator");
+   private List<FieldType> field;
+   private List<ConstructorType> constructor;
+   private List<MethodType> method;
+   private String name;
+
+   /**
+    * Gets the value of the field property.
+    * @return The list
+    */
+   public List<FieldType> getField()
+   {
+      if (field == null)
+         field = new ArrayList<FieldType>();
+
+      return this.field;
+   }
+
+   /**
+    * Gets the value of the constructor property.
+    * @return The list
+    */
+   public List<ConstructorType> getConstructor()
+   {
+      if (constructor == null)
+         constructor = new ArrayList<ConstructorType>();
+
+      return this.constructor;
+   }
+
+   /**
+    * Gets the value of the method property.
+    * @return The list
+    */
+   public List<MethodType> getMethod()
+   {
+      if (method == null)
+         method = new ArrayList<MethodType>();
+
+      return this.method;
+   }
+
+   /**
+    * Gets the value of the name property.
+    * @return The value
+    */
+   public String getName()
+   {
+      return name;
+   }
+
+   /**
+    * Sets the value of the name property.
+    * @param value The value
+    */
+   public void setName(String value)
+   {
+      this.name = value;
+   }
+
+   /**
+    * XML representation
+    * @param indentation The value
+    * @return The string
+    */
+   public String toXML(int indentation)
+   {
+      StringBuilder sb = new StringBuilder();
+
+      String prefix = "";
+      for (int i = 0; i < indentation; i++)
+         prefix += " ";
+
+      sb = sb.append(prefix + "<class name=\"" + name + "\">" + EOL);
+      for (FieldType ft : getField())
+         sb = sb.append(ft.toXML(indentation + 3));
+      for (ConstructorType ct : getConstructor())
+         sb = sb.append(ct.toXML(indentation + 3));
+      for (MethodType mt : getMethod())
+         sb = sb.append(mt.toXML(indentation + 3));
+      sb = sb.append(prefix + "</class>" + EOL);
+
+      return sb.toString();
+   }
+
+   /**
+    * String representation
+    * @return The string
+    */
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder(ClassType.class.getName());
+
+      sb = sb.append("{");
+      sb = sb.append("Name=" + name + ",");
+      sb = sb.append("Field=" + field + ",");
+      sb = sb.append("Constructor=" + constructor + ",");
+      sb = sb.append("Method=" + method);
+      sb = sb.append("}");
+
+      return sb.toString();
+   }
+}

Added: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ConstructorType.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ConstructorType.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ConstructorType.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,84 @@
+/*
+ * 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.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Represents a constructor
+ */
+public class ConstructorType
+{
+   private static final String EOL = System.getProperty("line.separator");
+   private List<ParameterType> parameter;
+
+   /**
+    * Gets the value of the parameter property.
+    * @return The list
+    */
+   public List<ParameterType> getParameter()
+   {
+      if (parameter == null)
+         parameter = new ArrayList<ParameterType>();
+
+      return this.parameter;
+   }
+
+   /**
+    * XML representation
+    * @param indentation The value
+    * @return The string
+    */
+   public String toXML(int indentation)
+   {
+      StringBuilder sb = new StringBuilder();
+
+      String prefix = "";
+      for (int i = 0; i < indentation; i++)
+         prefix += " ";
+
+      sb = sb.append(prefix + "<constructor>" + EOL);
+      for (ParameterType pt : getParameter())
+         sb = sb.append(pt.toXML(indentation + 3));
+      sb = sb.append(prefix + "</constructor>" + EOL);
+
+      return sb.toString();
+   }
+
+   /**
+    * String representation
+    * @return The string
+    */
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder(ConstructorType.class.getName());
+
+      sb = sb.append("{");
+      sb = sb.append("Parameter=" + parameter);
+      sb = sb.append("}");
+
+      return sb.toString();
+   }
+}

Added: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/FieldType.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/FieldType.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/FieldType.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,83 @@
+/*
+ * 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.xml;
+
+/**
+ * Represents a field
+ */
+public class FieldType
+{
+   private static final String EOL = System.getProperty("line.separator");
+   private String value;
+
+   /**
+    * Gets the value of the value property.
+    * @return The value
+    */
+   public String getValue()
+   {
+      return value;
+   }
+
+   /**
+    * Sets the value of the value property.
+    * @param value The value
+    */
+   public void setValue(String value)
+   {
+      this.value = value;
+   }
+
+   /**
+    * XML representation
+    * @param indentation The value
+    * @return The string
+    */
+   public String toXML(int indentation)
+   {
+      StringBuilder sb = new StringBuilder();
+
+      String prefix = "";
+      for (int i = 0; i < indentation; i++)
+         prefix += " ";
+
+      sb = sb.append(prefix + "<field>" + value + "</field>" + EOL);
+
+      return sb.toString();
+   }
+
+   /**
+    * String representation
+    * @return The string
+    */
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder(FieldType.class.getName());
+
+      sb = sb.append("{");
+      sb = sb.append("Value=" + value);
+      sb = sb.append("}");
+
+      return sb.toString();
+   }
+}

Added: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/JbossAnnotation.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/JbossAnnotation.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/JbossAnnotation.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,108 @@
+/*
+ * 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.xml;
+
+/**
+ * Represents the JBoss Annotations XML model
+ */
+public class JbossAnnotation
+{
+   private static final String EOL = System.getProperty("line.separator");
+   private ScanType scan;
+   private Boolean excludeAll;
+
+   /**
+    * Gets the value of the scan property.
+    * @return The value
+    */
+   public ScanType getScan()
+   {
+      return scan;
+   }
+
+   /**
+    * Sets the value of the scan property.
+    * @param value The type
+    */
+   public void setScan(ScanType value)
+   {
+      this.scan = value;
+   }
+
+   /**
+    * Gets the value of the excludeAll property.
+    * @return True if exclude all; otherwise false
+    */
+   public boolean isExcludeAll()
+   {
+      if (excludeAll == null)
+      {
+         return true;
+      }
+
+      return excludeAll.booleanValue();
+   }
+
+   /**
+    * Sets the value of the excludeAll property.
+    * @param value The value
+    */
+   public void setExcludeAll(Boolean value)
+   {
+      this.excludeAll = value;
+   }
+
+   /**
+    * XML representation
+    * @return The string
+    */
+   public String toXML()
+   {
+      StringBuilder sb = new StringBuilder();
+
+      sb = sb.append("<jboss-annotation exclude-all=\"" + excludeAll + "\">" + EOL);
+      if (excludeAll != null && Boolean.FALSE.equals(excludeAll))
+      {
+         sb = sb.append(scan.toXML(3));
+      }
+      sb = sb.append("</jboss-annotation>" + EOL);
+
+      return sb.toString();
+   }
+
+   /**
+    * String representation
+    * @return The string
+    */
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder(JbossAnnotation.class.getName());
+
+      sb = sb.append("{");
+      sb = sb.append("ExcludeAll=" + excludeAll + ",");
+      sb = sb.append("Scan=" + scan);
+      sb = sb.append("}");
+
+      return sb.toString();
+   }
+}

Added: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/MethodType.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/MethodType.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/MethodType.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,103 @@
+/*
+ * 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.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a method
+ */
+public class MethodType
+{
+   private static final String EOL = System.getProperty("line.separator");
+   private List<ParameterType> parameter;
+   private String name;
+
+   /**
+    * Gets the value of the parameter property.
+    * @return The list
+    */
+   public List<ParameterType> getParameter()
+   {
+      if (parameter == null)
+         parameter = new ArrayList<ParameterType>();
+        
+      return this.parameter;
+   }
+
+   /**
+    * Gets the value of the name property.
+    * @return The name
+    */
+   public String getName()
+   {
+      return name;
+   }
+
+   /**
+    * Sets the value of the name property.
+    * @param value The value
+    */
+   public void setName(String value)
+   {
+      this.name = value;
+   }
+
+   /**
+    * XML representation
+    * @param indentation The value
+    * @return The string
+    */
+   public String toXML(int indentation)
+   {
+      StringBuilder sb = new StringBuilder();
+
+      String prefix = "";
+      for (int i = 0; i < indentation; i++)
+         prefix += " ";
+
+      sb = sb.append(prefix + "<method name=\"" + name + "\">" + EOL);
+      for (ParameterType pt : getParameter())
+         sb = sb.append(pt.toXML(indentation + 3));
+      sb = sb.append(prefix + "</method>" + EOL);
+
+      return sb.toString();
+   }
+
+   /**
+    * String representation
+    * @return The string
+    */
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder(MethodType.class.getName());
+
+      sb = sb.append("{");
+      sb = sb.append("Name=" + name + ",");
+      sb = sb.append("Parameter=" + parameter);
+      sb = sb.append("}");
+
+      return sb.toString();
+   }
+}

Added: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ParameterType.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ParameterType.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ParameterType.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,83 @@
+/*
+ * 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.xml;
+
+/**
+ * Represents a parameter
+ */
+public class ParameterType
+{
+   private static final String EOL = System.getProperty("line.separator");
+   private String value;
+
+   /**
+    * Gets the value of the value property.
+    * @return The value
+    */
+   public String getValue()
+   {
+      return value;
+   }
+
+   /**
+    * Sets the value of the value property.
+    * @param value The value
+    */
+   public void setValue(String value)
+   {
+      this.value = value;
+   }
+
+   /**
+    * XML representation
+    * @param indentation The value
+    * @return The string
+    */
+   public String toXML(int indentation)
+   {
+      StringBuilder sb = new StringBuilder();
+
+      String prefix = "";
+      for (int i = 0; i < indentation; i++)
+         prefix += " ";
+
+      sb = sb.append(prefix + "<parameter>" + value + "</parameter>" + EOL);
+
+      return sb.toString();
+   }
+
+   /**
+    * String representation
+    * @return The string
+    */
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder(ParameterType.class.getName());
+
+      sb = sb.append("{");
+      sb = sb.append("Value=" + value);
+      sb = sb.append("}");
+
+      return sb.toString();
+   }
+}

Added: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ScanType.java
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ScanType.java	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/ScanType.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,83 @@
+/*
+ * 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.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a scan element
+ */
+public class ScanType
+{
+   private static final String EOL = System.getProperty("line.separator");
+   private List<ClassType> clazz;
+
+   /**
+    * Gets the value of the clazz property.
+    * @return The result
+    */
+   public List<ClassType> getClazz()
+   {
+      if (clazz == null)
+         clazz = new ArrayList<ClassType>();
+        
+      return this.clazz;
+   }
+
+   /**
+    * XML representation
+    * @param indentation The value
+    * @return The string
+    */
+   public String toXML(int indentation)
+   {
+      StringBuilder sb = new StringBuilder();
+
+      String prefix = "";
+      for (int i = 0; i < indentation; i++)
+         prefix += " ";
+
+      sb = sb.append(prefix + "<scan>" + EOL);
+      for (ClassType ct : getClazz())
+         sb = sb.append(ct.toXML(indentation + 3));
+      sb = sb.append(prefix + "</scan>" + EOL);
+
+      return sb.toString();
+   }
+
+   /**
+    * String representation
+    * @return The string
+    */
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder(ScanType.class.getName());
+
+      sb = sb.append("{");
+      sb = sb.append("Class=" + clazz);
+      sb = sb.append("}");
+
+      return sb.toString();
+   }
+}

Added: projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/package.html
===================================================================
--- projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/package.html	                        (rev 0)
+++ projects/annotations/trunk/core/src/main/java/org/jboss/annotations/xml/package.html	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,3 @@
+<body>
+The package defines the XML model
+</body>

Modified: projects/annotations/trunk/core/src/main/resources/core-manifest.mf
===================================================================
--- projects/annotations/trunk/core/src/main/resources/core-manifest.mf	2009-08-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/core/src/main/resources/core-manifest.mf	2009-08-14 20:21:16 UTC (rev 92393)
@@ -1,4 +1,4 @@
-Class-Path: activation.jar jaxb-api.jar jaxb-impl.jar stax-api.jar javassist.jar
+Class-Path: javassist.jar
 Implementation-Title: JBoss Annotations
 Implementation-Vendor: Red Hat Middleware LLC
 Implementation-Vendor-Id: org.jboss

Added: 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	                        (rev 0)
+++ projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/IndexerTask.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,231 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.indexer;
+
+import java.io.File;
+import java.util.logging.Logger;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * The JBoss Annotations Indexer Ant task
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class IndexerTask extends Task
+{
+   private static Logger log = Logger.getLogger(IndexerTask.class.getName());
+
+   private File input;
+   private File output;
+   private String mode;
+   private boolean update;
+   private File metadata;
+   
+   /**
+    * Constructor
+    */
+   public IndexerTask()
+   {
+      input = null;
+      output = null;
+      mode = "both";
+      update = true;
+      metadata = null;
+   }
+
+   /**
+    * Get the input file
+    * @return The file
+    */
+   public File getInput()
+   {
+      return input;
+   }
+
+   /**
+    * Set the input file
+    * @param f The file
+    */
+   public void setInput(File f)
+   {
+      input = f;
+   }
+
+   /**
+    * Get the output file
+    * @return The file
+    */
+   public File getOutput()
+   {
+      return output;
+   }
+
+   /**
+    * Set the output file
+    * @param f The file
+    */
+   public void setOutput(File f)
+   {
+      output = f;
+   }
+
+   /**
+    * 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
+    */
+   public boolean isUpdate()
+   {
+      return update;
+   }
+
+   /**
+    * Set the update mode
+    * @param b The mode
+    */
+   public void setUpdate(boolean b)
+   {
+      update = b;
+   }
+
+   /**
+    * Get the metadata
+    * @return The metadata
+    */
+   public File getMetadata()
+   {
+      return metadata;
+   }
+
+   /**
+    * Set the metadata
+    * @param f The metadata
+    */
+   public void setMetadata(File f)
+   {
+      metadata = f;
+   }
+
+   /**
+    * Execute Ant task
+    * @exception BuildException If an error occurs
+    */
+   public void execute() throws BuildException
+   {
+      try
+      {
+         if (output == null)
+            output = input;
+
+         Main m = new Main();
+            
+         boolean binary = false;
+         boolean xml = false;
+
+         if ("binary".equalsIgnoreCase(mode))
+         {
+            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 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.recursiveDelete(root);
+            
+               if (!xml)
+                  FileUtil.recursiveDelete(xmlFile);
+            }
+            else
+            {
+               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);
+            }
+         }
+      }
+      catch (Throwable t)
+      {
+         throw new BuildException(t.getMessage(), 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-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/Main.java	2009-08-14 20:21:16 UTC (rev 92393)
@@ -29,7 +29,8 @@
 import org.jboss.annotations.AnnotationType;
 import org.jboss.annotations.impl.AbstractAnnotationScanner;
 import org.jboss.annotations.impl.Scan;
-import org.jboss.annotations.impl.XMLLoader;
+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;
@@ -39,11 +40,13 @@
 import org.jboss.annotations.xml.ScanType;
 
 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.OutputStream;
+import java.io.Writer;
 import java.net.URL;
 import java.util.Collection;
 import java.util.List;
@@ -52,9 +55,6 @@
 import java.util.logging.Logger;
 import java.util.zip.GZIPOutputStream;
 
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-
 /**
  * The JBoss Annotations Indexer
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
@@ -78,6 +78,12 @@
     */
    public void generateBinary(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");
+
       FileInputStream fis = new FileInputStream(f);
 
       Scan scan = XMLLoader.loadJBossAnnotation(fis);
@@ -103,7 +109,15 @@
     */
    public File generateXML(File f, File directory) throws Exception
    {
-      AnnotationScanner scanner = AnnotationScannerFactory.getDefault();
+      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();
@@ -175,20 +189,14 @@
          }
       }
 
-      JAXBContext context = JAXBContext.newInstance("org.jboss.annotations.xml");
-      Marshaller marshaller = context.createMarshaller();
-      marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
-      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-      marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://www.jboss.org/annotations");
-
       File output = new File(directory, AbstractAnnotationScanner.JBOSS_ANNOTATION_XML);
-      OutputStream os = new FileOutputStream(output);
-      os = new BufferedOutputStream(os);
+      Writer writer = new FileWriter(output);
+      writer = new BufferedWriter(writer);
 
-      marshaller.marshal(root, os);
+      XMLSaver.save(root, writer);
 
-      os.flush();
-      os.close();
+      writer.flush();
+      writer.close();
 
       return output;
    }

Added: projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/package.html
===================================================================
--- projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/package.html	                        (rev 0)
+++ projects/annotations/trunk/indexer/src/main/java/org/jboss/annotations/indexer/package.html	2009-08-14 20:21:16 UTC (rev 92393)
@@ -0,0 +1,3 @@
+<body>
+This package contains the JBoss Annotations Indexer.
+</body>

Modified: projects/annotations/trunk/indexer/src/main/resources/indexer-manifest.mf
===================================================================
--- projects/annotations/trunk/indexer/src/main/resources/indexer-manifest.mf	2009-08-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/indexer/src/main/resources/indexer-manifest.mf	2009-08-14 20:21:16 UTC (rev 92393)
@@ -1,4 +1,4 @@
-Class-Path: jboss-annotations.jar activation.jar jaxb-api.jar jaxb-impl.jar stax-api.jar javassist.jar
+Class-Path: jboss-annotations.jar javassist.jar
 Main-Class: org.jboss.annotations.indexer.Main
 Implementation-Title: JBoss Annotations - Indexer
 Implementation-Vendor: Red Hat Middleware LLC

Modified: projects/annotations/trunk/ivy.xml
===================================================================
--- projects/annotations/trunk/ivy.xml	2009-08-14 20:20:45 UTC (rev 92392)
+++ projects/annotations/trunk/ivy.xml	2009-08-14 20:21:16 UTC (rev 92393)
@@ -35,13 +35,20 @@
   </configurations>
 
   <dependencies>
+    <dependency org="ant" name="ant" rev="${version.ant}" conf="core->default"/>
+<!--
     <dependency org="com.sun.xml.bind" name="jaxb-xjc" rev="${version.jaxb.xjc}" conf="core->default"/>
+-->
     <dependency org="javassist" name="javassist" rev="${version.javassist}" conf="core->default"/>
+<!--
     <dependency org="javax.activation" name="activation" rev="${version.activation}" conf="core->default"/>
     <dependency org="javax.xml" name="jaxb-impl" rev="${version.jaxb.impl}" conf="core->default"/>
     <dependency org="javax.xml.bind" name="jaxb-api" rev="${version.jaxb.api}" conf="core->default"/>
+-->
     <dependency org="junit" name="junit" rev="${version.junit}" conf="test->default"/>
+<!--
     <dependency org="stax" name="stax-api" rev="${version.stax}" conf="core->default"/>
+-->
   </dependencies>
 
 </ivy-module>




More information about the jboss-cvs-commits mailing list