geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r413387 - /geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
Date Sat, 10 Jun 2006 23:48:51 GMT
Author: kevan
Date: Sat Jun 10 16:48:51 2006
New Revision: 413387

URL: http://svn.apache.org/viewvc?rev=413387&view=rev
Log:
GERONIMO-2078 Insure configuration files are cleaned up, if service deployment fails

Modified:
    geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java

Modified: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=413387&r1=413386&r2=413387&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
(original)
+++ geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
Sat Jun 10 16:48:51 2006
@@ -228,23 +228,25 @@
             throw new DeploymentException(e);
         }
 
-        ConfigurationManager configurationManager = this.configurationManager;
-        if (configurationManager == null) {
-            configurationManager = new SimpleConfigurationManager(configurationStores, artifactResolver,
repositories);
-        }
-        DeploymentContext context = new DeploymentContext(outfile,
-                inPlaceDeployment && null != jar ? DeploymentUtil.toFile(jar) : null,
-                environment, 
-                ConfigurationModuleType.SERVICE, 
-                naming,
-                configurationManager,
-                repositories
-        );
-        if(jar != null) {
-            File file = new File(jar.getName());
-            context.addIncludeAsPackedJar(URI.create(file.getName()), jar);
-        }
+        DeploymentContext context = null;
         try {
+            ConfigurationManager configurationManager = this.configurationManager;
+            if (configurationManager == null) {
+                configurationManager = new SimpleConfigurationManager(configurationStores,
artifactResolver, repositories);
+            }
+
+            context = new DeploymentContext(outfile,
+                    inPlaceDeployment && null != jar ? DeploymentUtil.toFile(jar)
: null,
+                    environment,
+                    ConfigurationModuleType.SERVICE,
+                    naming,
+                    configurationManager,
+                    repositories);
+            if(jar != null) {
+                File file = new File(jar.getName());
+                context.addIncludeAsPackedJar(URI.create(file.getName()), jar);
+            }
+
             ClassLoader cl = context.getClassLoader();
 
 
@@ -253,13 +255,34 @@
 
             addGBeans(gbeans, cl, moduleName, context);
             return context;
-        } catch (RuntimeException t) {
-            context.close();
-            throw t;
+        } catch (DeploymentException de) {
+            cleanupAfterFailedBuild(context, outfile);
+            throw de;
+        } catch (IOException ie) {
+            cleanupAfterFailedBuild(context, outfile);
+            throw ie;
+        } catch (RuntimeException re) {
+            cleanupAfterFailedBuild(context, outfile);
+            throw re;
         } catch (Error e) {
-            context.close();
+            cleanupAfterFailedBuild(context, outfile);
             throw e;
-        } 
+        }
+    }
+
+    private void cleanupAfterFailedBuild(DeploymentContext context, File directory) {
+        try {
+            if (context !=null) {
+                context.close();
+            }
+        } catch (DeploymentException de) {
+            // ignore error on cleanup
+        } catch (IOException ioe) {
+            // ignore error on cleanu
+        }
+        if (directory != null) {
+            DeploymentUtil.recursiveDelete(directory);
+        }
     }
 
     public static void addGBeans(GbeanType[] gbeans, ClassLoader cl, AbstractName moduleName,
DeploymentContext context) throws DeploymentException {



Mime
View raw message