[cargo] r1980 - core/trunk/containers/jboss/src/main/java/org/codehaus/cargo/container/jboss

View: New views
1 Messages — Rating Filter:   Alert me  

[cargo] r1980 - core/trunk/containers/jboss/src/main/java/org/codehaus/cargo/container/jboss

by mwringe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Author: mwringe
Date: 2009-09-02 14:09:23 -0500 (Wed, 02 Sep 2009)
New Revision: 1980

Modified:
   core/trunk/containers/jboss/src/main/java/org/codehaus/cargo/container/jboss/JBossInstalledLocalDeployer.java
Log:
Add support for undeployment on JBoss for deployables other than wars.

Modified: core/trunk/containers/jboss/src/main/java/org/codehaus/cargo/container/jboss/JBossInstalledLocalDeployer.java
===================================================================
--- core/trunk/containers/jboss/src/main/java/org/codehaus/cargo/container/jboss/JBossInstalledLocalDeployer.java 2009-09-02 15:27:17 UTC (rev 1979)
+++ core/trunk/containers/jboss/src/main/java/org/codehaus/cargo/container/jboss/JBossInstalledLocalDeployer.java 2009-09-02 19:09:23 UTC (rev 1980)
@@ -24,6 +24,7 @@
 import org.codehaus.cargo.container.InstalledLocalContainer;
 import org.codehaus.cargo.container.deployable.Deployable;
 import org.codehaus.cargo.container.deployable.DeployableType;
+import org.codehaus.cargo.container.deployable.EAR;
 import org.codehaus.cargo.container.deployable.WAR;
 import org.codehaus.cargo.container.spi.deployer.AbstractCopyingInstalledLocalDeployer;
 
@@ -52,7 +53,7 @@
     public String getDeployableDir()
     {  
         String clustered = getContainer().getConfiguration().
-                getPropertyValue(JBossPropertySet.CLUSTERED);
+                                 getPropertyValue(JBossPropertySet.CLUSTERED);
         
         if (Boolean.valueOf(clustered).booleanValue())
         {
@@ -102,22 +103,34 @@
      */
     public void undeploy(Deployable deployable)
     {
-        if (deployable.getType() != DeployableType.WAR)
+        if (deployable.getType() == DeployableType.WAR)
         {
+            WAR war = (WAR) deployable;
+            undeployFile(getDeployableDir(), war.getContext() + ".war");
+        }
+
+        else if (deployable.getType() == DeployableType.EAR)
+        {
+            EAR ear = (EAR) deployable;
+            undeployFile(getDeployableDir(), ear.getName() + ".ear");
+        }
+
+        else if (deployable.getType() == DeployableType.FILE
+                || deployable.getType() == DeployableType.SAR)
+        {
+            String fileName = getFileHandler().getName(deployable.getFile());
+            undeployFile(getDeployableDir(), fileName);
+        }
+
+        else
+        {
             super.undeploy(deployable);
             return;
         }
-        WAR war = (WAR) deployable;
-        String fileName = getFileHandler().append(getDeployableDir(), war.getContext() + ".war");
-        if (fileExists(fileName))
-        {
-            getLogger().info("Undeploying [" + fileName + "]...", this.getClass().getName());
-            getFileHandler().delete(fileName);
-        }
     }
 
     /**
-     * Checks whether file or dir represented by string exists
+     * Checks whether file or dir represented by string exists.
      *
      * @param fileName path to check
      * @return true if file/dir exists
@@ -127,5 +140,26 @@
         return new File(fileName).exists();
     }
 
-    
+    /**
+     *Undeploy the file in specified directory with the specified file name.
+     *
+     *@param directory The directory name
+     *@param file The file name
+     */
+    private void undeployFile(String directory, String file)
+    {
+        String fileName = getFileHandler().append(directory, file);
+        if (fileExists(fileName))
+        {
+            getLogger().info("Undeploying [" + fileName + "]...", this.getClass().getName());
+            getFileHandler().delete(fileName);
+        }
+        else
+        {
+            getLogger().info(
+                    "Couldn't not find file to undeploy [" + fileName + "]",
+                    this.getClass().getName());
+        }
+    }
+
 }


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email