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/11 01:47:28 UTC
svn commit: r413386 -
/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
Author: kevan
Date: Sat Jun 10 16:47:28 2006
New Revision: 413386
URL: http://svn.apache.org/viewvc?rev=413386&view=rev
Log:
GERONIMO-2078 Insure configuration files are cleaned up, if service deployment fails
Modified:
geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=413386&r1=413385&r2=413386&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original)
+++ geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Sat Jun 10 16:47:28 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 {