public void setId(String id) {
this.id = id;
}
public void execute() throws Exception {
DeploymentManager manager = getDeploymentManager();
Target[] targets = manager.getTargets();
TargetModuleID moduleIds[] = manager.getNonRunningModules(null, targets);
List toUndeploy = new ArrayList(moduleIds.length);
for (int i = 0; i < moduleIds.length; i++) {
TargetModuleID moduleId = moduleIds[i];
if (getId().equals(moduleId.getModuleID())) {
toUndeploy.add(moduleId);
}
}
if (toUndeploy.size() == 0) {
System.out.println("Module is running or not deployed: " + getId());
return;
}
moduleIds = (TargetModuleID[]) toUndeploy.toArray(new TargetModuleID[toUndeploy.size()]);
ProgressObject progress = manager.undeploy(moduleIds);
DeploymentClient.waitFor(progress);
}