You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2006/05/04 21:49:36 UTC

svn commit: r399840 - in /geronimo/branches/1.1/modules/deployment/src: java/org/apache/geronimo/deployment/SingleFileHotDeployer.java test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java

Author: dain
Date: Thu May  4 12:49:36 2006
New Revision: 399840

URL: http://svn.apache.org/viewcvs?rev=399840&view=rev
Log:
Fixed GERONIMO-1946 SingleFileHotDeploy fixes for resolve, no force restart, empty target, and messages
Thanks Joe Bohn

Modified:
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java
    geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java?rev=399840&r1=399839&r2=399840&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java (original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java Thu May  4 12:49:36 2006
@@ -81,6 +81,14 @@
             throw new IllegalArgumentException("Directory is not a directory " + dir.getAbsolutePath());
         }
 
+        // take no action if there is nothing in the directory to deploy.   Perhaps we should
+        // consider doing an undeploy in this case if the application is already deployed. Howevr 
+        // for now this is to handle the case where the application is not already laid down at the 
+        // time of the initial deploy of this gbean.
+        if (dir.list().length == 0) {
+            return null;
+        }
+
         // get the existing inplace configuration if there is one
         ConfigurationInfo existingConfiguration = null;
         List list = configurationManager.listConfigurations();
@@ -92,7 +100,13 @@
         }
         Artifact existingConfigurationId = (existingConfiguration == null) ? null : existingConfiguration.getConfigID();
 
-        if (!forceDeploy && existingConfiguration != null && !isModifedSince(existingConfiguration.getCreated())) {
+        if (!forceDeploy && existingConfiguration != null && !isModifiedSince(existingConfiguration.getCreated())) {
+            try {
+                configurationManager.loadConfiguration(existingConfigurationId);
+                configurationManager.startConfiguration(existingConfigurationId);
+            } catch (Exception e) {
+                throw new DeploymentException("Unable to load and start " + dir, e);
+            }
             return existingConfigurationId;
         }
 
@@ -135,30 +149,35 @@
 
             // if the new configuration id isn't fully resolved, populate it with defaults
             if (!configurationId.isResolved()) {
-                resolve(configurationId);
+                configurationId = resolve(configurationId);
             }
 
             // if we are deploying over the exisitng version we need to uninstall first
             if(configurationId.equals(existingConfigurationId)) {
+                log.info("Undeploying " + configurationId);
                 configurationManager.uninstallConfiguration(existingConfigurationId);
             }
 
             // deploy it
+            log.info("Deploying " + configurationId + " in location " + dir);
             deployConfiguration(builder, store, configurationId, plan, module, Arrays.asList(configurationManager.getStores()), configurationManager.getArtifactResolver());
             wasDeployed = true;
 
             configurationManager.loadConfiguration(configurationId);
             configurationManager.startConfiguration(configurationId);
 
+            log.info("Successfully deployed and started " + configurationId + " in location " + dir);
+
             return configurationId;
         } catch (Exception e) {
             throw new DeploymentException("Unable to deploy " + dir, e);
         } finally {
             DeploymentUtil.close(module);
         }
+
     }
 
-    private boolean isModifedSince(long created) {
+    private boolean isModifiedSince(long created) {
         for (int i = 0; i < watchPaths.length; i++) {
             String path = watchPaths[i];
             File file = new File(dir, path);
@@ -173,7 +192,7 @@
         return false;
     }
 
-    private void resolve(Artifact configID) throws DeploymentException {
+    private Artifact resolve(Artifact configID) throws DeploymentException {
         String group = configID.getGroupId();
         if (group == null) {
             group = Artifact.DEFAULT_GROUP_ID;
@@ -190,7 +209,7 @@
         if (type == null) {
             type = "car";
         }
-        configID = new Artifact(group, artifactId, version, type);
+        return new Artifact(group, artifactId, version, type);
     }
 
     private List deployConfiguration(ConfigurationBuilder builder, ConfigurationStore store, Artifact configurationId, Object plan, JarFile module, Collection stores, ArtifactResolver artifactResolver) throws DeploymentException {

Modified: geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java?rev=399840&r1=399839&r2=399840&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java (original)
+++ geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java Thu May  4 12:49:36 2006
@@ -88,6 +88,9 @@
         dir = new File("target/deployTest");
         dir.mkdirs();
 
+        File someFile = new File(dir, "someFile");
+        someFile.createNewFile();
+
         String watch1 = "watch1";
         String watch2 = "watch2";
         watchPaths = new String[]{watch1, watch2};
@@ -199,8 +202,8 @@
     public void testNoRedeploy() throws Exception {
         shouldUninstall = false;
         shouldUnload = false;
-        shouldLoad = false;
-        shouldStart = false;
+        shouldLoad = true;
+        shouldStart = true;
         isConfigurationAlreadyLoaded = true;
 
         touch(watchFile1, PAST);