geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pra...@apache.org
Subject svn commit: r478288 - /geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java
Date Wed, 22 Nov 2006 19:07:15 GMT
Author: prasad
Date: Wed Nov 22 11:07:14 2006
New Revision: 478288

URL: http://svn.apache.org/viewvc?view=rev&rev=478288
Log:
* if module already undeployed, don't throw an execption.

Modified:
    geronimo/server/trunk/maven-plugins/geronimo-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/module/ModuleMojoSupport.java

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=478288&r1=478287&r2=478288
==============================================================================
--- 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
Wed Nov 22 11:07:14 2006
@@ -139,7 +139,47 @@
     }
 
     /**
-     * Check of the given module is started.
+     * Given a list of modules, return a list of non-running ones.
+     *
+     * @param moduleIds  The list of modules to check
+     * @return          The list of modules that are not running
+     *
+     * @throws Exception
+     */
+    protected TargetModuleID[] getNonRunningModules(final TargetModuleID[] moduleIds) throws
Exception {
+        assert moduleIds != null;
+
+        List modulesList = new ArrayList();
+
+        DeploymentManager manager = getDeploymentManager();
+
+        Target[] targets = manager.getTargets();
+        TargetModuleID runningModuleIds[] = manager.getRunningModules(null, targets);
+
+        for (int j = 0; j < moduleIds.length; j++) {
+            String moduleId = moduleIds[j].getModuleID();
+            log.debug("Checking if module is running: " + moduleId);
+
+            boolean found = false;
+            for (int i = 0; i < runningModuleIds.length; i++) {
+            String runningModuleId = runningModuleIds[i].getModuleID();
+                if (moduleId.equals(runningModuleId)) {
+                    log.debug("Module is running: " + moduleId);
+                    found = true;
+                    break;
+                }
+            }
+
+            if (!found) {
+                log.debug("Module is not running: " + moduleId);
+                modulesList.add(moduleIds[j]);
+            }
+        }
+        return (TargetModuleID[]) modulesList.toArray(new TargetModuleID[modulesList.size()]);
+    }
+
+    /**
+     * Check if the given module is started.
      *
      * @param moduleId  The module ID to check
      * @return          True if the module for this ID is started.
@@ -190,10 +230,6 @@
     protected void startModule() throws Exception {
         assert modules != null;
 
-        DeploymentManager manager = getDeploymentManager();
-        Target[] targets = manager.getTargets();
-        TargetModuleID[] targetIds = manager.getNonRunningModules(null, targets);
-
         for (int i=0; i<modules.length; i++) {
            String moduleId = getModuleId(modules[i]);
         
@@ -203,6 +239,10 @@
                //throw new MojoExecutionException("Module is already started: " + moduleId);
            }
 
+           DeploymentManager manager = getDeploymentManager();
+           Target[] targets = manager.getTargets();
+           TargetModuleID[] targetIds = manager.getNonRunningModules(null, targets);
+
            TargetModuleID[] found = findModules(moduleId, targetIds);
 
            if (found.length == 0) {
@@ -232,7 +272,7 @@
          for (int i=0; i<modules.length; i++) {
            String moduleId = getModuleId(modules[i]);
            if (!isModuleStarted(moduleId)) {
-               log.warn("Module is already stopped: " + moduleId);
+               log.info("Module is already stopped: " + moduleId);
                continue;
                //throw new MojoExecutionException("Module is not started: " + moduleId);
            }
@@ -271,7 +311,9 @@
           TargetModuleID[] found = findModules(moduleId, targetIds);
 
           if (found.length == 0) {
-              throw new Exception("Module is not deployed: " + moduleId);
+              log.info("Module is not deployed: " + moduleId);
+              continue;
+              //throw new Exception("Module is not deployed: " + moduleId);
           }
 
           log.info("Undeploying module: " + moduleId);



Mime
View raw message