geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r446756 - in /geronimo/server/trunk: maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ testsuite/...
Date Fri, 15 Sep 2006 21:58:12 GMT
Author: jdillon
Date: Fri Sep 15 14:58:11 2006
New Revision: 446756

URL: http://svn.apache.org/viewvc?view=rev&rev=446756
Log:
(GERONIMO-2359) Applying slighlty modified patch from Prasad to improve module handling

Modified:
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ModuleConfig.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java
    geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ModuleConfig.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ModuleConfig.java?view=diff&rev=446756&r1=446755&r2=446756
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ModuleConfig.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/ModuleConfig.java
Fri Sep 15 14:58:11 2006
@@ -38,26 +38,13 @@
      */
     private File plan;
 
-    //
-    // FIXME: This is bad, as someone can configure an module's archive here which will cause
unexpected
-    //        problems.
-
-    private File archive;
-
+    
     public void setPlan(final File plan) {
         this.plan = plan;
     }
 
     public File getPlan() {
         return plan;
-    }
-
-    public void setArchive(final File archive) {
-        this.archive = archive;
-    }
-
-    public File getArchive() {
-        return archive;
     }
 
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java?view=diff&rev=446756&r1=446755&r2=446756
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/DeployModuleMojo.java
Fri Sep 15 14:58:11 2006
@@ -46,13 +46,6 @@
     extends ModuleMojoSupport
 {
     /**
-     * List of module artifact configurations.  Artifacts need to point to jar | war | ear
| rar archive.
-     *
-     * @parameter
-     */
-    protected ModuleConfig[] modules = null;
-
-    /**
      * A file which points to a specific module's jar | war | ear | rar archive.
      * If this parameter is set, then it will be used instead of from the
      * modules configuration.
@@ -81,38 +74,23 @@
     private boolean startModules = false;
 
     public void doExecute() throws Exception {
+        List completed = new ArrayList();
+
         if (moduleArchive != null) {
             log.info("Using non-artifact based module archive: " + moduleArchive);
 
-            // Add the single module to the list
-            ModuleConfig moduleConfig = new ModuleConfig();
-            moduleConfig.setArchive(moduleArchive);
-            moduleConfig.setPlan(modulePlan);
-
-            modules = new ModuleConfig[] {
-                moduleConfig
-            };
+            TargetModuleID[] ids = distribute(moduleArchive, modulePlan);
+            completed.add(ids);
         }
         else if (modules == null || modules.length == 0) {
             throw new MojoExecutionException("At least one module configuration (or moduleArchive)
must be specified");
         }
+        else {
+            log.info("Using artifact based module archive(s)...");
 
-        List completed = new ArrayList();
-        DeploymentManager manager = getDeploymentManager();
-        Target[] targets = manager.getTargets();
-
-        for (int i=0; i<modules.length; i++) {
-            File file = getModuleArchive(modules[i]);
-            log.info("Distributing module artifact: " + file);
-
-            ProgressObject progress = manager.distribute(targets, file, modules[i].getPlan());
-            DeploymentStatus status = waitFor(progress);
-
-            if (status.isFailed()) {
-                throw new MojoExecutionException("Distribution failed: " + status.getMessage());
-            }
-            else {
-                completed.add(progress.getResultTargetModuleIDs());
+            for (int i=0; i<modules.length; i++) {
+                TargetModuleID[] ids = distribute(getModuleArchive(modules[i]), modules[i].getPlan());
+                completed.add(ids);
             }
         }
 
@@ -127,7 +105,7 @@
                     log.info("Starting module: " + moduleIds[i].getModuleID() + (url == null
? "" : ("; URL: " + url)));
                 }
 
-                ProgressObject progress = manager.start(moduleIds);
+                ProgressObject progress = getDeploymentManager().start(moduleIds);
                 DeploymentStatus status = waitFor(progress);
 
                 if (status.isFailed()) {
@@ -141,13 +119,6 @@
     }
 
     private File getModuleArchive(final ModuleConfig module) throws MojoExecutionException
{
-        //
-        // HACK: For single non-artifact module archive
-        //
-        if (module.getArchive() != null) {
-            return module.getArchive();
-        }
-
         Artifact artifact = getArtifact(module);
 
         File file = artifact.getFile();
@@ -167,5 +138,22 @@
         }
 
         return file;
+    }
+
+    private TargetModuleID[] distribute(final File file, final File plan) throws Exception
{
+        assert file != null;
+        
+        log.info("Distributing module artifact: " + file);
+
+        DeploymentManager manager = getDeploymentManager();
+        Target[] targets = manager.getTargets();
+        ProgressObject progress = manager.distribute(targets, file, plan);
+        DeploymentStatus status = waitFor(progress);
+
+        if (status.isFailed()) {
+            throw new MojoExecutionException("Distribution failed: " + status.getMessage());
+        }
+
+        return progress.getResultTargetModuleIDs();
     }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java?view=diff&rev=446756&r1=446755&r2=446756
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java
Fri Sep 15 14:58:11 2006
@@ -35,6 +35,7 @@
 
 import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
 import org.apache.geronimo.mavenplugins.geronimo.GeronimoMojoSupport;
+import org.apache.geronimo.mavenplugins.geronimo.ModuleConfig;
 
 import org.apache.geronimo.genesis.ArtifactItem;
 
@@ -50,8 +51,26 @@
 {
     private static final String URI_PREFIX = "deployer:geronimo:jmx";
 
+    /**
+     * List of module artifact configurations.  Artifacts need to point to jar | war | ear
| rar archive.
+     *
+     * @parameter
+     */
+    protected ModuleConfig[] modules = null;
+
+    /**
+     * Cached deployment manager.
+     */
     private DeploymentManager deploymentManager;
 
+    /**
+     * Get a deployment manager; if the manager was previosuly initialized then that cached
instance is used.
+     *
+     * @return  Deployment manager instance; never null
+     *
+     * @throws IOException
+     * @throws DeploymentManagerCreationException
+     */
     protected DeploymentManager getDeploymentManager() throws IOException, DeploymentManagerCreationException
{
         if (deploymentManager == null) {
             // Register the Geronimo factory
@@ -67,6 +86,14 @@
         return deploymentManager;
     }
 
+    /**
+     * Waits for the given progress to stop running.
+     *
+     * @param progress  The progress object to wait for.
+     * @return          The status of the deployment; never null
+     *
+     * @throws InterruptedException
+     */
     protected DeploymentStatus waitFor(final ProgressObject progress) throws InterruptedException
{
         assert progress != null;
 
@@ -110,6 +137,14 @@
         return item.getGroupId() + "/" + item.getArtifactId() + "/" + item.getVersion() +
"/" + item.getType();
     }
 
+    /**
+     * Check of the given module is started.
+     *
+     * @param moduleId  The module ID to check
+     * @return          True if the module for this ID is started.
+     *
+     * @throws Exception
+     */
     protected boolean isModuleStarted(final String moduleId) throws Exception {
         assert moduleId != null;
 
@@ -151,86 +186,104 @@
     // TODO: Can probably wrap up some of this into findModules with a flag for running or
non-running
     //
     
-    protected void startModule(final String moduleId) throws Exception {
-        assert moduleId != null;
-        
-        if (isModuleStarted(moduleId)) {
-            throw new MojoExecutionException("Module is already started: " + moduleId);
-        }
+    protected void startModule() throws Exception {
+        assert modules != null;
 
         DeploymentManager manager = getDeploymentManager();
         Target[] targets = manager.getTargets();
         TargetModuleID[] targetIds = manager.getNonRunningModules(null, targets);
-        TargetModuleID[] found = findModules(moduleId, targetIds);
 
-        if (found.length == 0) {
-            throw new MojoExecutionException("Module is not deployed: " + moduleId);
-        }
+        for (int i=0; i<modules.length; i++) {
+           String moduleId = getModuleId(modules[i]);
+        
+           if (isModuleStarted(moduleId)) {
+               log.warn("Module is already started: " + moduleId);
+               continue;
+               //throw new MojoExecutionException("Module is already started: " + moduleId);
+           }
 
-        log.info("Starting module: " + moduleId);
-        ProgressObject progress = manager.start(found);
+           TargetModuleID[] found = findModules(moduleId, targetIds);
 
-        DeploymentStatus status = waitFor(progress);
-        if (status.isFailed()) {
-            throw new MojoExecutionException("Failed to start module: " + moduleId);
-        }
+           if (found.length == 0) {
+               throw new MojoExecutionException("Module is not deployed: " + moduleId);
+           }
 
-        log.info("Started module(s):");
-        logModules(found, "    ");
-    }
+           log.info("Starting module: " + moduleId);
+           ProgressObject progress = manager.start(found);
 
-    protected void stopModule(final String moduleId) throws Exception {
-        assert moduleId != null;
-        
-        if (!isModuleStarted(moduleId)) {
-            throw new MojoExecutionException("Module is not started: " + moduleId);
+           DeploymentStatus status = waitFor(progress);
+           if (status.isFailed()) {
+               throw new MojoExecutionException("Failed to start module: " + moduleId);
+           }
+
+           log.info("Started module(s):");
+           logModules(found, "    ");
         }
+    }
+
+    protected void stopModule() throws Exception {
+        assert modules != null;
 
         DeploymentManager manager = getDeploymentManager();
         Target[] targets = manager.getTargets();
         TargetModuleID[] targetIds = manager.getRunningModules(null, targets);
-        TargetModuleID[] found = findModules(moduleId, targetIds);
 
-        if (found.length == 0) {
-            throw new MojoExecutionException("Module not deployed: " + moduleId);
-        }
+         for (int i=0; i<modules.length; i++) {
+           String moduleId = getModuleId(modules[i]);
+           if (!isModuleStarted(moduleId)) {
+               log.warn("Module is already stopped: " + moduleId);
+               continue;
+               //throw new MojoExecutionException("Module is not started: " + moduleId);
+           }
 
-        log.info("Stopping module: " + moduleId);
-        ProgressObject progress = manager.stop(found);
+           TargetModuleID[] found = findModules(moduleId, targetIds);
 
-        DeploymentStatus status = waitFor(progress);
-        if (status.isFailed()) {
-            throw new MojoExecutionException("Failed to stop module: " + moduleId);
-        }
+           if (found.length == 0) {
+               throw new MojoExecutionException("Module not deployed: " + moduleId);
+           }
 
-        log.info("Stopped module(s):");
-        logModules(found, "    ");
+           log.info("Stopping module: " + moduleId);
+           ProgressObject progress = manager.stop(found);
+
+           DeploymentStatus status = waitFor(progress);
+           if (status.isFailed()) {
+               throw new MojoExecutionException("Failed to stop module: " + moduleId);
+           }
+
+           log.info("Stopped module(s):");
+           logModules(found, "    ");
+         }
     }
 
-    protected void undeployModule(final String moduleId) throws Exception {
-        assert moduleId != null;
+    protected void undeployModule() throws Exception {
+        assert modules != null;
+
+        stopModule();
 
-        stopModule(moduleId);
-        
         DeploymentManager manager = getDeploymentManager();
         Target[] targets = manager.getTargets();
         TargetModuleID[] targetIds = manager.getNonRunningModules(null, targets);
-        TargetModuleID[] found = findModules(moduleId, targetIds);
 
-        if (found.length == 0) {
-            throw new Exception("Module is not deployed: " + moduleId);
-        }
+        for (int i=0; i<modules.length; i++) {
+          String moduleId = getModuleId(modules[i]);
 
-        log.info("Undeploying module: " + moduleId);
-        ProgressObject progress = manager.undeploy(found);
+          TargetModuleID[] found = findModules(moduleId, targetIds);
 
-        DeploymentStatus status = waitFor(progress);
-        if (status.isFailed()) {
-            throw new MojoExecutionException("Failed to undeploy module: " + moduleId);
-        }
+          if (found.length == 0) {
+              throw new Exception("Module is not deployed: " + moduleId);
+          }
+
+          log.info("Undeploying module: " + moduleId);
+          ProgressObject progress = manager.undeploy(found);
 
-        log.info("Undeployed module(s):");
-        logModules(found, "    ");
+          DeploymentStatus status = waitFor(progress);
+          if (status.isFailed()) {
+              throw new MojoExecutionException("Failed to undeploy module: " + moduleId);
+          }
+
+          log.info("Undeployed module(s):");
+          logModules(found, "    ");
+        }
     }
 
     protected void logModules(final TargetModuleID[] targetIds) {

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java?view=diff&rev=446756&r1=446755&r2=446756
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartModuleMojo.java
Fri Sep 15 14:58:11 2006
@@ -34,6 +34,6 @@
     //
 
     public void doExecute() throws Exception {
-        startModule(moduleId);
+        startModule();
     }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java?view=diff&rev=446756&r1=446755&r2=446756
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StartStopUndeployMojoSupport.java
Fri Sep 15 14:58:11 2006
@@ -19,6 +19,10 @@
 
 package org.apache.geronimo.mavenplugins.geronimo.module;
 
+import org.apache.geronimo.mavenplugins.geronimo.ModuleConfig;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
 /**
  * Support for start/stop/undeploy mojos.
  *
@@ -35,7 +39,40 @@
      * The id of the module to be started in the format of <tt>groupId/artifactId/version/type</tt>.
      *
      * @parameter expression="${moduleId}
-     * @required
      */
     protected String moduleId = null;
+
+    protected void init() throws MojoExecutionException, MojoFailureException {
+        super.init();
+
+        if (moduleId != null) {
+            log.info("Using non-artifact based module id: " + moduleId);
+
+            // Add the single module to the list
+            ModuleConfig moduleConfig = createModuleConfigFromId(moduleId);
+            modules = new ModuleConfig[] {
+                moduleConfig
+            };
+        }
+        else if (modules == null || modules.length == 0) {
+            throw new MojoExecutionException("At least one module configuration (or moduleId)
must be specified");
+        }
+    }
+
+    private ModuleConfig createModuleConfigFromId(String moduleId) throws MojoExecutionException
{
+        assert moduleId != null;
+
+        ModuleConfig moduleConfig = new ModuleConfig();
+        moduleId = moduleId.replace('\\', '/');
+        String[] splitStr = moduleId.split("/");
+        if (splitStr.length != 4) {
+            throw new MojoExecutionException("Invalid moduleId: " + moduleId);
+        }
+        moduleConfig.setGroupId(splitStr[0]);
+        moduleConfig.setArtifactId(splitStr[1]);
+        moduleConfig.setVersion(splitStr[2]);
+        moduleConfig.setType(splitStr[3]);
+         
+        return moduleConfig;
+    }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java?view=diff&rev=446756&r1=446755&r2=446756
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/StopModuleMojo.java
Fri Sep 15 14:58:11 2006
@@ -34,6 +34,6 @@
     //
     
     public void doExecute() throws Exception {
-        stopModule(moduleId);
+        stopModule();
     }
 }

Modified: geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java?view=diff&rev=446756&r1=446755&r2=446756
==============================================================================
--- geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/UndeployModuleMojo.java
Fri Sep 15 14:58:11 2006
@@ -34,6 +34,6 @@
     //
     
     public void doExecute() throws Exception {
-        undeployModule(moduleId);
+        undeployModule();
     }
 }

Modified: geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml?view=diff&rev=446756&r1=446755&r2=446756
==============================================================================
--- geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml (original)
+++ geronimo/server/trunk/testsuite/deployment-testsuite/pom.xml Fri Sep 15 14:58:11 2006
@@ -94,14 +94,10 @@
                                 </goals>
                                 <configuration>
                                     <background>true</background>
-                                    <!--
-                                    HACK: For now need to refresh the install since we
-                                          do not have an easy way to automate undeploy.
-                                    -->
-                                    <refresh>true</refresh>
                                 </configuration>
                             </execution>
-                            
+
+
                             <execution>
                                 <id>deploy-ears</id>
                                 <phase>pre-integration-test</phase>
@@ -127,9 +123,34 @@
                                 </configuration>
                             </execution>
                             
-                            <!--
-                            TODO: Undeploy
-                            -->
+                            <execution>
+                                <id>undeploy-ear-as-module</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>undeploy-module</goal>
+                                </goals>
+                                <configuration>
+                                  <modules>
+                                        <module>
+                                            <groupId>org.apache.geronimo.testsupport</groupId>
+                                            <artifactId>test-ear-j2ee_1.3</artifactId>
+                                            <version>${pom.version}</version>
+                                            <type>ear</type>
+                                        </module>
+                                  </modules>
+                                </configuration>
+                            </execution>
+
+                            <execution>
+                                <id>undeploy-ear-as-moduleId</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>undeploy-module</goal>
+                                </goals>
+                                <configuration>
+                                    <moduleId>org.apache.geronimo.testsupport/test-ear-j2ee_1.4/${pom.version}/ear</moduleId>
+                                </configuration>
+                            </execution>
                             
                             <execution>
                                 <id>stop-server</id>



Mime
View raw message