You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/06/14 14:49:09 UTC

svn commit: r1350216 - /openejb/trunk/openejb/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java

Author: rmannibucau
Date: Thu Jun 14 12:49:09 2012
New Revision: 1350216

URL: http://svn.apache.org/viewvc?rev=1350216&view=rev
Log:
better undeployment managing for ear

Modified:
    openejb/trunk/openejb/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java

Modified: openejb/trunk/openejb/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java?rev=1350216&r1=1350215&r2=1350216&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java (original)
+++ openejb/trunk/openejb/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/TomEEContainer.java Thu Jun 14 12:49:09 2012
@@ -52,7 +52,7 @@ public abstract class TomEEContainer<Con
     protected static final String LOCALHOST = "localhost";
     protected static final String SHUTDOWN_COMMAND = "SHUTDOWN" + Character.toString((char) -1);
     protected Configuration configuration;
-    protected Map<String, File> moduleIds = new HashMap<String, File>();
+    protected Map<String, DeployedApp> moduleIds = new HashMap<String, DeployedApp>();
     private final Options options;
 
     protected TomEEContainer() {
@@ -216,7 +216,7 @@ public abstract class TomEEContainer<Con
                 Info.marshal(appInfo);
             }
 
-            moduleIds.put(archive.getName(), file);
+            moduleIds.put(archive.getName(), new DeployedApp(appInfo.path, file));
 
             final String fileName = file.getName();
             if (fileName.endsWith(".war")) {
@@ -264,9 +264,14 @@ public abstract class TomEEContainer<Con
 
     public void undeploy(Archive<?> archive) throws DeploymentException {
         try {
-            final File file = moduleIds.get(archive.getName());
-            deployer().undeploy(file.getAbsolutePath());
-            Files.delete(file.getParentFile()); // "i" folder
+            final DeployedApp deployed = moduleIds.get(archive.getName());
+            deployer().undeploy(deployed.path);
+            Files.delete(deployed.file); // "i" folder
+
+            final File pathFile = new File(deployed.path);
+            if (!deployed.path.equals(deployed.file.getAbsolutePath()) && pathFile.exists()) {
+                Files.delete(pathFile);
+            }
         } catch (Exception e) {
             e.printStackTrace();
             throw new DeploymentException("Unable to undeploy", e);
@@ -302,4 +307,14 @@ public abstract class TomEEContainer<Con
         }
         return contextRoot + "/" + mapping;
     }
+
+    public static class DeployedApp {
+        public final File file;
+        public final String path;
+
+        public DeployedApp(final String path, final File file) {
+            this.path = path;
+            this.file = file;
+        }
+    }
 }