001    package org.apache.geronimo.deployment.cli;
002    
003    import javax.enterprise.deploy.spi.status.ProgressObject;
004    import javax.enterprise.deploy.spi.DeploymentManager;
005    import javax.enterprise.deploy.spi.TargetModuleID;
006    import java.io.PrintWriter;
007    
008    /**
009     * The CLI deployer logic to restart.
010     */
011    public class CommandRestart extends CommandStart {
012        public CommandRestart() {
013            super("restart", "1. Common Commands", "[ModuleID|TargetModuleID]+",
014                    "Accepts the configId of a module, or the fully-qualified " +
015                    "TargetModuleID identifying both the module and the server or cluster it's " +
016                    "on, and restarts that module.  The module should be available to the server " +
017                    "and running. If multiple modules are specified, they will all be restarted.\n");
018        }
019    
020        protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[] ids) {
021            ProgressObject po = mgr.stop(ids);
022            waitForProgress(out, po);
023            if(po.getDeploymentStatus().isCompleted()) {
024                po = mgr.start(ids);
025                waitForProgress(out, po);
026            }
027            return po;
028        }
029    
030        protected String getAction() {
031            return "Restarted";
032        }
033    }