[jboss-cvs] JBossAS SVN: r76399 - trunk/server/src/main/org/jboss/deployment.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 29 08:11:30 EDT 2008


Author: alesj
Date: 2008-07-29 08:11:30 -0400 (Tue, 29 Jul 2008)
New Revision: 76399

Modified:
   trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
Log:
Prepare class for OptAMDD.

Modified: trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java	2008-07-29 12:04:31 UTC (rev 76398)
+++ trunk/server/src/main/org/jboss/deployment/AnnotationMetaDataDeployer.java	2008-07-29 12:11:30 UTC (rev 76399)
@@ -36,16 +36,13 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.metadata.annotation.creator.client.ApplicationClient5MetaDataCreator;
-import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
 import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
 import org.jboss.metadata.annotation.creator.web.Web25MetaDataCreator;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
 import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
 import org.jboss.metadata.client.spec.ApplicationClient5MetaData;
 import org.jboss.metadata.client.spec.ApplicationClientMetaData;
-import org.jboss.metadata.ejb.jboss.JBoss50MetaData;
 import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
 import org.jboss.metadata.ejb.spec.EjbJar3xMetaData;
 import org.jboss.metadata.ejb.spec.EjbJarMetaData;
 import org.jboss.metadata.web.spec.Web25MetaData;
@@ -178,26 +175,40 @@
 
       try
       {
-         String mainClassName = getMainClassName(unit);
-         Collection<Class<?>> classes = getClasses(unit, mainClassName, classpath);
-         if(classes.size() > 0)
-         {
-            AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
-            if(webMetaData != null)
-               processJBossWebMetaData(unit, finder, classes);
-            else if(clientMetaData != null || mainClassName != null)
-               processJBossClientMetaData(unit, finder, classes);
-            else
-               processJBossMetaData(unit, finder, classes);
-         }
+         processMetaData(unit, webMetaData, clientMetaData, classpath);
       }
-      catch(IOException e)
+      catch (Exception e)
       {
-         throw new DeploymentException(e);
+         throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e);
       }
    }
 
    /**
+    * Process metadata.
+    *
+    * @param unit the deployment unit
+    * @param webMetaData the web metadata
+    * @param clientMetaData the client metadata
+    * @param classpath the classpath
+    * @throws DeploymentException for any error
+    */
+   protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception
+   {
+      String mainClassName = getMainClassName(unit);
+      Collection<Class<?>> classes = getClasses(unit, mainClassName, classpath);
+      if (classes.size() > 0)
+      {
+         AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+         if (webMetaData != null)
+            processJBossWebMetaData(unit, finder, classes);
+         else if (clientMetaData != null || mainClassName != null)
+            processJBossClientMetaData(unit, finder, classes);
+         else
+            processJBossMetaData(unit, finder, classes);
+      }
+   }
+
+   /**
     * Get the classes we want to scan.
     *
     * @param unit the deployment unit
@@ -252,37 +263,6 @@
    }
 
    /**
-    * Get main class from manifest.
-    *
-    * @param unit the deployment unit
-    * @return main class name
-    * @throws IOException for any error
-    */
-   protected String getMainClassName(VFSDeploymentUnit unit)
-      throws IOException
-   {
-      VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
-      if (log.isTraceEnabled())
-         log.trace("parsing " + file);
-
-      if(file == null)
-      {
-         return null;
-      }
-
-      try
-      {
-         Manifest mf = VFSUtils.readManifest(file);
-         Attributes attrs = mf.getMainAttributes();
-         return attrs.getValue(Attributes.Name.MAIN_CLASS);
-      }
-      finally
-      {
-         file.close();
-      }
-   }
-
-   /**
     * Process annotations.
     *
     * @param unit the deployment unit
@@ -313,5 +293,36 @@
       if(annotationMetaData != null)
          unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class);      
    }
+
+   /**
+    * Get main class from manifest.
+    *
+    * @param unit the deployment unit
+    * @return main class name
+    * @throws IOException for any error
+    */
+   protected String getMainClassName(VFSDeploymentUnit unit)
+      throws IOException
+   {
+      VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
+      if (log.isTraceEnabled())
+         log.trace("parsing " + file);
+
+      if(file == null)
+      {
+         return null;
+      }
+
+      try
+      {
+         Manifest mf = VFSUtils.readManifest(file);
+         Attributes attrs = mf.getMainAttributes();
+         return attrs.getValue(Attributes.Name.MAIN_CLASS);
+      }
+      finally
+      {
+         file.close();
+      }
+   }
 }
 




More information about the jboss-cvs-commits mailing list