[jboss-cvs] JBossAS SVN: r105634 - trunk/deployment/src/main/java/org/jboss/deployment/spi.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 3 07:28:04 EDT 2010


Author: wolfc
Date: 2010-06-03 07:28:04 -0400 (Thu, 03 Jun 2010)
New Revision: 105634

Modified:
   trunk/deployment/src/main/java/org/jboss/deployment/spi/DeploymentManagerImpl.java
Log:
JBAS-8059: analyze the deployment plan as well


Modified: trunk/deployment/src/main/java/org/jboss/deployment/spi/DeploymentManagerImpl.java
===================================================================
--- trunk/deployment/src/main/java/org/jboss/deployment/spi/DeploymentManagerImpl.java	2010-06-03 10:56:14 UTC (rev 105633)
+++ trunk/deployment/src/main/java/org/jboss/deployment/spi/DeploymentManagerImpl.java	2010-06-03 11:28:04 UTC (rev 105634)
@@ -29,14 +29,7 @@
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
+import java.util.*;
 import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
@@ -87,7 +80,7 @@
    private Target[] targets;
 
    // maps the DD to the archives
-   private HashMap mapDeploymentPlan;
+   private Map<String, File> mapDeploymentPlan;
    private DeploymentMetaData metaData;
 
    private List tmpFiles = new ArrayList();
@@ -436,7 +429,7 @@
     */
    private void initDeploymentMetaData() throws IOException
    {
-      File metaTmpFile = (File)mapDeploymentPlan.get(DeploymentMetaData.ENTRY_NAME);
+      File metaTmpFile = mapDeploymentPlan.get(DeploymentMetaData.ENTRY_NAME);
       if (metaTmpFile == null)
          throw new IOException("Deployment plan does not contain an entry: " + DeploymentMetaData.ENTRY_NAME);
 
@@ -485,27 +478,8 @@
          // only process file entries
          if (entryName.endsWith("/") == false)
          {
-            if (entryName.endsWith("/application.xml"))
-            {
-               moduleType = ModuleType.EAR;
-            }
-            else if (entryName.endsWith("/application-client.xml"))
-            {
-               moduleType = ModuleType.CAR;
-            }
-            else if (entryName.endsWith("/ra.xml"))
-            {
-               moduleType = ModuleType.RAR;
-            }
-            else if (entryName.endsWith("/web.xml"))
-            {
-               moduleType = ModuleType.WAR;
-            }
-            else if (entryName.endsWith("/ejb-jar.xml"))
-            {
-               moduleType = ModuleType.EJB;
-            }
-
+            moduleType = ifNotNull(determineModuleType(entryName), moduleType);
+            
             // process a sub module
             if (entryName.endsWith(".jar") || entryName.endsWith(".war"))
             {
@@ -525,6 +499,14 @@
          entry = jis.getNextJarEntry();
       }
 
+      // JBAS-8059: the regular jar didn't show us enough information, lets analyze the deployment plan
+      for (String entryName : mapDeploymentPlan.keySet())
+      {
+         moduleType = determineModuleType(entryName);
+         if (moduleType != null)
+            break;
+      }
+
       if (moduleType == null)
       {
          if (moduleName.endsWith(ModuleType.EAR.getModuleExtension()))
@@ -551,6 +533,40 @@
       return moduleInfo;
    }
 
+   /**
+    * A simple module type determination taking only the descriptor name into account.
+    */
+   private static ModuleType determineModuleType(String entryName)
+   {
+      ModuleType moduleType = null;
+      if (entryName.endsWith("/application.xml"))
+      {
+         moduleType = ModuleType.EAR;
+      }
+      else if (entryName.endsWith("/application-client.xml"))
+      {
+         moduleType = ModuleType.CAR;
+      }
+      else if (entryName.endsWith("/ra.xml"))
+      {
+         moduleType = ModuleType.RAR;
+      }
+      else if (entryName.endsWith("/web.xml"))
+      {
+         moduleType = ModuleType.WAR;
+      }
+      else if (entryName.endsWith("/ejb-jar.xml") || entryName.endsWith("/jboss.xml"))
+      {
+         moduleType = ModuleType.EJB;
+      }
+      return moduleType;
+   }
+
+   private static <T> T ifNotNull(T val, T def)
+   {
+      return val != null ? val : def;
+   }
+
    public ProgressObject redeploy(TargetModuleID[] targetModuleIDs, File file, File file1) throws UnsupportedOperationException, IllegalStateException
    {
       if (isConnected == false)
@@ -830,7 +846,7 @@
             String dpName = key.substring(moduleKey.length());
             log.debug("found deployment plan entry: " + dpName);
 
-            File dpFile = (File)mapDeploymentPlan.get(key);
+            File dpFile = mapDeploymentPlan.get(key);
             FileInputStream dpin = new FileInputStream(dpFile);
             JarUtils.addJarEntry(jos, dpName, dpin);
             dpin.close();
@@ -841,9 +857,9 @@
    /**
     * Create a temp file for every entry in the deployment plan
     */
-   private HashMap unpackDeploymentPlan(InputStream deploymentPlan) throws IOException
+   private Map<String, File> unpackDeploymentPlan(InputStream deploymentPlan) throws IOException
    {
-      HashMap dpMap = new HashMap();
+      Map<String, File> dpMap = new HashMap<String, File>();
 
       if (deploymentPlan == null)
          return dpMap;




More information about the jboss-cvs-commits mailing list