You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ke...@apache.org on 2006/06/04 02:25:39 UTC

svn commit: r411489 - /geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java

Author: kevan
Date: Sat Jun  3 17:25:39 2006
New Revision: 411489

URL: http://svn.apache.org/viewvc?rev=411489&view=rev
Log:
GERONIMO-2078 Make sure the configuration directories are cleaned up if a deployment fails. During an ear deploy, appclient configurations were not being cleaned up, if the deploy failed after the appclient configs had been created. The configurations are now deleted during cleanup processing

Modified:
    geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java

Modified: geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=411489&r1=411488&r2=411489&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java (original)
+++ geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java Sat Jun  3 17:25:39 2006
@@ -21,17 +21,19 @@
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.LinkedHashMap;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 import javax.xml.namespace.QName;
@@ -562,35 +564,19 @@
             // it's the caller's responsibility to close the context...
             return earContext;
         } catch (GBeanAlreadyExistsException e) {
-            // todo delete owned configuraitons like appclients
-            if (earContext != null) {
-                earContext.close();
-            }
-            cleanupConfigurationDir(configurationDir);
+            cleanupContext(earContext, configurationDir);
             throw new DeploymentException(e);
         } catch (IOException e) {
-            if (earContext != null) {
-                earContext.close();
-            }
-            cleanupConfigurationDir(configurationDir);
+            cleanupContext(earContext, configurationDir);
             throw e;
         } catch (DeploymentException e) {
-            if (earContext != null) {
-                earContext.close();
-            }
-            cleanupConfigurationDir(configurationDir);
+            cleanupContext(earContext, configurationDir);
             throw e;
         } catch(RuntimeException e) {
-            if (earContext != null) {
-                earContext.close();
-            }
-            cleanupConfigurationDir(configurationDir);
+            cleanupContext(earContext, configurationDir);
             throw e;
         } catch(Error e) {
-            if (earContext != null) {
-                earContext.close();
-            }
-            cleanupConfigurationDir(configurationDir);
+            cleanupContext(earContext, configurationDir);
             throw e;
         } finally {
             Set modules = applicationInfo.getModules();
@@ -598,6 +584,29 @@
                 Module module = (Module) iterator.next();
                 module.close();
             }
+        }
+    }
+
+    private void cleanupContext(EARContext earContext, File configurationDir) {
+        List configurations = new ArrayList();
+        if (earContext != null) {
+            configurations.addAll(earContext.getAdditionalDeployment());
+            try {
+                earContext.close();
+            } catch (IOException ioe) {
+                // ignore any cleanup problems
+            } catch (DeploymentException de) {
+                // ignore any cleanup problems
+            }
+        }
+        // configurationDir is created before we create an EARContext
+        if (configurationDir != null) {
+            cleanupConfigurationDir(configurationDir);
+        }
+        // cleanup any other configurations generated (e.g. AppClient config dirs)
+        for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
+            ConfigurationData configurationData = (ConfigurationData) iterator.next();
+            cleanupConfigurationDir(configurationData.getConfigurationDir());
         }
     }