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 UndeployModule extends AbstractModuleCommand { 35 36 private String id; 37 38 public String getId() { 39 return id; 40 } 41 42 public void setId(String id) { 43 this.id = id; 44 } 45 46 public void execute() throws Exception { 47 DeploymentManager manager = getDeploymentManager(); 48 49 Target [] targets = manager.getTargets(); 50 TargetModuleID moduleIds[] = manager.getNonRunningModules(null, targets); 51 List toUndeploy = new ArrayList (moduleIds.length); 52 for (int i = 0; i < moduleIds.length; i++) { 53 TargetModuleID moduleId = moduleIds[i]; 54 if (getId().equals(moduleId.getModuleID())) { 55 toUndeploy.add(moduleId); 56 } 57 } 58 if (toUndeploy.size() == 0) { 59 System.out.println("Module is running or not deployed: " + getId()); 60 return; 61 } 62 moduleIds = (TargetModuleID []) toUndeploy.toArray(new TargetModuleID [toUndeploy.size()]); 63 ProgressObject progress = manager.undeploy(moduleIds); 64 DeploymentClient.waitFor(progress); 65 } 66 67 } 68 | Popular Tags |