1 17 18 package org.apache.geronimo.deployment.mavenplugin; 19 20 import java.util.List ; 21 import java.util.ArrayList ; 22 23 import javax.enterprise.deploy.spi.DeploymentManager ; 24 import javax.enterprise.deploy.spi.Target ; 25 import javax.enterprise.deploy.spi.TargetModuleID ; 26 import javax.enterprise.deploy.spi.status.ProgressObject ; 27 28 34 public class StopModule extends AbstractModuleCommand { 35 private String id; 36 37 public String getId() { 38 return id; 39 } 40 41 public void setId(String id) { 42 this.id = id; 43 } 44 45 public void execute() throws Exception { 46 DeploymentManager manager = getDeploymentManager(); 47 48 Target [] targets = manager.getTargets(); 49 TargetModuleID moduleIds[] = manager.getRunningModules(null, targets); 50 List toStop = new ArrayList (moduleIds.length); 51 for (int i = 0; i < moduleIds.length; i++) { 52 TargetModuleID moduleId = moduleIds[i]; 53 if (getId().equals(moduleId.getModuleID())) { 54 toStop.add(moduleId); 55 } 56 } 57 if (toStop.size() == 0) { 58 System.out.println("Module is not running or not deployed: " + getId()); 59 return; 60 } 61 moduleIds = (TargetModuleID []) toStop.toArray(new TargetModuleID [toStop.size()]); 62 ProgressObject progress = manager.stop(moduleIds); 63 DeploymentClient.waitFor(progress); 64 } 65 66 } 67 | Popular Tags |