geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 53773 - in geronimo/trunk/modules: client-builder/src/java/org/apache/geronimo/client/builder deployment/src/java/org/apache/geronimo/deployment kernel/src/java/org/apache/geronimo/kernel/config system/src/java/org/apache/geronimo/system/configuration
Date Tue, 05 Oct 2004 01:11:50 GMT
Author: dain
Date: Mon Oct  4 18:11:49 2004
New Revision: 53773

Modified:
   geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
Log:
Deployment system no longer builds into temp directory, and instead it builds into a new directory
already in the config store.  Upon a successful deployment, we add this directory to the index.properties
file, thus activating it.  Otherwise, we delete the directory.


Modified: geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(original)
+++ geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
Mon Oct  4 18:11:49 2004
@@ -302,7 +302,7 @@
         File appClientConfiguration = null;
         try {
             try {
-                appClientConfiguration = DeploymentUtil.createTempDir();
+                appClientConfiguration = store.createNewConfigurationDir();
 
                 // construct the app client deployment context... this is the same class
used by the ear context
                 try {
@@ -472,14 +472,17 @@
             } catch (Exception e) {
                 throw new DeploymentException(e);
             }
-        } catch (DeploymentException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new DeploymentException(e);
-        } finally {
+        } catch(Throwable e) {
             DeploymentUtil.recursiveDelete(appClientConfiguration);
+            if (e instanceof Error) {
+                throw (Error)e;
+            } else if (e instanceof DeploymentException) {
+                throw (DeploymentException)e;
+            } else if (e instanceof Exception) {
+                throw new DeploymentException(e);
+            }
+            throw new Error(e);
         }
-
     }
 
     private ReadOnlyContext buildComponentContext(EARContext earContext, AppClientModule
appClientModule, ApplicationClientType appClient, GerApplicationClientType geronimoAppClient,
ClassLoader cl) throws DeploymentException {

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java
Mon Oct  4 18:11:49 2004
@@ -138,15 +138,15 @@
             // write the deployer system out to a jar
 
             // create a temp directory to build into
-            File tempDir = null;
+            File configurationDir = null;
             try {
-                tempDir = DeploymentUtil.createTempDir();
+                configurationDir = configStore.createNewConfigurationDir();
 
-                // build the deployer-system configuration into the tempDir
-                builder.buildConfiguration(deployerSystemConfig, null, tempDir);
+                // build the deployer-system configuration into the configurationDir
+                builder.buildConfiguration(deployerSystemConfig, null, configurationDir);
 
                 // Write the manifest
-                File metaInf = new File(tempDir, "META-INF");
+                File metaInf = new File(configurationDir, "META-INF");
                 metaInf.mkdirs();
                 FileOutputStream out = null;
                 try {
@@ -161,28 +161,40 @@
                 startupJarTag.createNewFile();
 
                 // jar up the directory
-                DeploymentUtil.jarDirectory(tempDir,  new File(deployerJar));
+                DeploymentUtil.jarDirectory(configurationDir,  new File(deployerJar));
 
                 // delete the startup file before moving this to the config store
                 startupJarTag.delete();
 
                 // install the configuration
-                configStore.install(tempDir);
-            } finally {
-                DeploymentUtil.recursiveDelete(tempDir);
+                configStore.install(configurationDir);
+            } catch(Throwable e) {
+                DeploymentUtil.recursiveDelete(configurationDir);
+                if (e instanceof Error) {
+                    throw (Error)e;
+                } else if (e instanceof Exception) {
+                    throw (Exception)e;
+                }
+                throw new Error(e);
             }
 
             // build and install the j2ee-deployer configuration
             try {
-                tempDir = DeploymentUtil.createTempDir();
+                configurationDir = configStore.createNewConfigurationDir();
 
-                // build the j2ee-deployer configuration into the tempDir
-                builder.buildConfiguration(j2eeDeployerConfig, null, tempDir);
+                // build the j2ee-deployer configuration into the configurationDir
+                builder.buildConfiguration(j2eeDeployerConfig, null, configurationDir);
 
                 // install the configuration
-                configStore.install(tempDir);
-            } finally {
-                DeploymentUtil.recursiveDelete(tempDir);
+                configStore.install(configurationDir);
+            } catch(Throwable e) {
+                DeploymentUtil.recursiveDelete(configurationDir);
+                if (e instanceof Error) {
+                    throw (Error)e;
+                } else if (e instanceof Exception) {
+                    throw (Exception)e;
+                }
+                throw new Error(e);
             }
         } finally {
             Thread.currentThread().setContextClassLoader(oldCL);

Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
Mon Oct  4 18:11:49 2004
@@ -112,7 +112,7 @@
             }
         }
 
-        File tempDir = null;
+        File configurationDir = null;
         try {
             Object plan = null;
             ConfigurationBuilder builder = null;
@@ -128,15 +128,11 @@
                 throw new DeploymentException("No deployer found for this plan type: " +
planFile);
             }
 
-            // create a temp dir to write the configuration during the building proces
-            try {
-                tempDir = DeploymentUtil.createTempDir();
-            } catch (IOException e) {
-                throw new DeploymentException("Unable to create temp file for deployment",
e);
-            }
+            // create a configuration dir to write the configuration during the building
proces
+            configurationDir = store.createNewConfigurationDir();
 
             // create te meta-inf dir
-            File metaInf = new File(tempDir, "META-INF");
+            File metaInf = new File(configurationDir, "META-INF");
             metaInf.mkdirs();
 
             // create the manifest
@@ -161,7 +157,7 @@
 
 
             // this is a bit weird and should be rethougth but it works
-            List childURIs = builder.buildConfiguration(plan, module, tempDir);
+            List childURIs = builder.buildConfiguration(plan, module, configurationDir);
 
             try {
                 if (targetFile != null) {
@@ -172,13 +168,13 @@
                     }
 
                     // jar up the directory
-                    DeploymentUtil.jarDirectory(tempDir,  targetFile);
+                    DeploymentUtil.jarDirectory(configurationDir,  targetFile);
 
                     // remove the startup tag file so it doesn't accidently leak into a normal
classloader
                     startupJarTag.delete();
                 }
                 if (install) {
-                    URI uri = store.install(tempDir);
+                    URI uri = store.install(configurationDir);
                     List deployedURIs = new ArrayList(childURIs.size() + 1);
                     deployedURIs.add(uri.toString());
                     deployedURIs.addAll(childURIs);
@@ -189,18 +185,21 @@
                 // unlikely as we just built this
                 throw new DeploymentException(e);
             }
-        } catch (DeploymentException e) {
+        } catch(Throwable e) {
+            DeploymentUtil.recursiveDelete(configurationDir);
             if (targetFile != null) {
                 targetFile.delete();
             }
-            throw e;
-        } catch (Exception e) {
-            if (targetFile != null) {
-                targetFile.delete();
+
+            if (e instanceof Error) {
+                throw (Error)e;
+            } else if (e instanceof DeploymentException) {
+                throw (DeploymentException)e;
+            } else if (e instanceof Exception) {
+                throw new DeploymentException(e);
             }
-            throw new DeploymentException(e);
+            throw new Error(e);
         } finally {
-            DeploymentUtil.recursiveDelete(tempDir);
             DeploymentUtil.close(module);
         }
     }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java
Mon Oct  4 18:11:49 2004
@@ -92,4 +92,6 @@
      * @return a List<URI> of configurations in the store
      */
     List listConfiguations();
+
+    File createNewConfigurationDir();
 }

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
Mon Oct  4 18:11:49 2004
@@ -136,7 +136,7 @@
         }
     }
 
-    private File createConfigurationDir() {
+    public File createNewConfigurationDir() {
         // loop until we find a directory that doesn't alredy exist
         // this can happen when a deployment fails (leaving an bad directory)
         // and the server reboots without saving out the index.propreties file
@@ -154,7 +154,7 @@
     }
 
     public URI install(URL source) throws IOException, InvalidConfigException {
-        File configurationDir = createConfigurationDir();
+        File configurationDir = createNewConfigurationDir();
 
         InputStream is = source.openStream();
         try {
@@ -186,23 +186,18 @@
 
     public URI install(File source) throws IOException, InvalidConfigException {
         if (!source.isDirectory()) {
-            throw new InvalidConfigException("Source must be a directory");
+            throw new InvalidConfigException("Source must be a directory: source=" + source);
         }
-
-        File configurationDir = createConfigurationDir();
-        if (!source.renameTo(configurationDir)) {
-            throw new IOException("Could not move source directory into config store:" +
-                    " source=" + source.getAbsolutePath() + ", destination=" + configurationDir.getAbsolutePath());
+        if (!source.getParentFile().equals(rootDir)) {
+            throw new InvalidConfigException("Source must be within the config store: source="
+ source + ", configStoreDir=" + rootDir);
         }
 
         URI configId;
         try {
-            GBeanMBean config = loadConfig(configurationDir);
+            GBeanMBean config = loadConfig(source);
             configId = (URI) config.getAttribute("ID");
-            index.setProperty(configId.toString(), configurationDir.getName());
+            index.setProperty(configId.toString(), source.getName());
         } catch (Exception e) {
-            // try to put the file back
-            configurationDir.renameTo(source);
             throw new InvalidConfigException("Unable to get ID from downloaded configuration",
e);
         }
 
@@ -210,7 +205,7 @@
             saveIndex();
         }
 
-        log.info("Installed configuration " + configId + " in location " + configurationDir.getName());
+        log.info("Installed configuration " + configId + " in location " + source.getName());
         return configId;
     }
 

Mime
View raw message