Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D329E7AA0 for ; Tue, 20 Sep 2011 07:06:57 +0000 (UTC) Received: (qmail 58342 invoked by uid 500); 20 Sep 2011 07:06:57 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 58298 invoked by uid 500); 20 Sep 2011 07:06:57 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 58289 invoked by uid 99); 20 Sep 2011 07:06:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 07:06:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Sep 2011 07:06:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 525DB23888EA; Tue, 20 Sep 2011 07:06:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1173002 - /geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java Date: Tue, 20 Sep 2011 07:06:36 -0000 To: scm@geronimo.apache.org From: xuhaihong@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20110920070636.525DB23888EA@eris.apache.org> Author: xuhaihong Date: Tue Sep 20 07:06:35 2011 New Revision: 1173002 URL: http://svn.apache.org/viewvc?rev=1173002&view=rev Log: GERONIMO-5265 Modify the redeploy behavior to start all the running childs along with the parent (Based on the patch from Ashish Jain) Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java?rev=1173002&r1=1173001&r2=1173002&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java Tue Sep 20 07:06:35 2011 @@ -18,10 +18,12 @@ package org.apache.geronimo.deployment.p import java.io.File; import java.io.InputStream; -import java.util.Iterator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; import javax.enterprise.deploy.shared.CommandType; -import javax.enterprise.deploy.shared.ModuleType; import javax.enterprise.deploy.spi.Target; import javax.enterprise.deploy.spi.TargetModuleID; @@ -33,6 +35,7 @@ import org.apache.geronimo.kernel.Intern import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.config.ConfigurationManager; import org.apache.geronimo.kernel.config.ConfigurationUtil; +import org.apache.geronimo.kernel.config.LifecycleException; import org.apache.geronimo.kernel.config.LifecycleResults; import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.apache.geronimo.kernel.repository.Artifact; @@ -141,29 +144,24 @@ public class RedeployCommand extends Abs // Activate it //todo: make this asynchronous boolean newStarted = false; - for (Iterator it = results.getStopped().iterator(); it.hasNext();) { - Artifact name = (Artifact) it.next(); + for (Artifact name : results.getStopped()) { updateStatus("Stopped "+name); } - for (Iterator it = results.getUnloaded().iterator(); it.hasNext();) { - Artifact name = (Artifact) it.next(); + for (Artifact name : results.getUnloaded()) { updateStatus("Unloaded "+name); } - for (Iterator it = results.getLoaded().iterator(); it.hasNext();) { - Artifact name = (Artifact) it.next(); + for (Artifact name : results.getLoaded()) { updateStatus("Loaded "+name); } - for (Iterator it = results.getStarted().iterator(); it.hasNext();) { - Artifact name = (Artifact) it.next(); + for (Artifact name : results.getStarted()) { updateStatus("Started "+name); if(configID.matches(name)) { newStarted = true; } } - for (Iterator it = results.getFailed().keySet().iterator(); it.hasNext();) { - Artifact name = (Artifact) it.next(); - updateStatus("Failed on "+name+": "+results.getFailedCause(name).getMessage()); - doFail((Exception)results.getFailedCause(name)); + for(Map.Entry entry : results.getFailed().entrySet()) { + updateStatus("Failed on " + entry.getKey() + ": " + entry.getValue().getMessage()); + doFail(entry.getValue()); } if(results.getFailed().size() == 0 && !newStarted) { updateStatus("Note: new module was not started (probably because old module was not running)."); @@ -174,8 +172,13 @@ public class RedeployCommand extends Abs if(!configID.isResolved()) { throw new IllegalStateException("Cannot redeploy same module when module ID is not fully resolved ("+configID+")"); } + + List startedChildren = Collections.emptyList(); + try { - configurationManager.stopConfiguration(configID); + LifecycleResults lifecycleResults = configurationManager.stopConfiguration(configID); + startedChildren = new ArrayList(lifecycleResults.getStopped()); + Collections.reverse(startedChildren); updateStatus("Stopped "+configID); } catch (InternalKernelException e) { Exception cause = (Exception)e.getCause(); @@ -228,5 +231,20 @@ public class RedeployCommand extends Abs configurationManager.loadConfiguration(configID); configurationManager.startConfiguration(configID); updateStatus("Started " + configID); + + for (Artifact startedArtifactId : startedChildren) { + if(startedArtifactId.equals(configID)) { + continue; + } + try { + configurationManager.loadConfiguration(startedArtifactId); + configurationManager.startConfiguration(startedArtifactId); + updateStatus("Restarted Chid " + startedArtifactId); + } catch (NoSuchConfigException e) { + updateStatus("Restart Chid Failed " + startedArtifactId); + } catch (LifecycleException e) { + updateStatus("Restarted Chid Failed " + startedArtifactId); + } + } } }