"modules on the specified targets.");
}
public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
if(!connection.isOnline()) {
throw new DeploymentException("This command cannot be run unless connecting to a running server. Specify --url if server is not running on the default port on localhost.");
}
List targets = new ArrayList();
Boolean started = null;
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if(arg.startsWith("--")) {
if(arg.equals("--all")) {
if(started != null) {
throw new DeploymentSyntaxException("Cannot specify more than one of --all, --started, --stopped");
}
} else if(arg.equals("--started")) {
if(started != null) {
throw new DeploymentSyntaxException("Cannot specify more than one of --all, --started, --stopped");
}
started = Boolean.TRUE;
} else if(arg.equals("--stopped")) {
if(started != null) {
throw new DeploymentSyntaxException("Cannot specify more than one of --all, --started, --stopped");
}
started = Boolean.FALSE;
} else {
throw new DeploymentSyntaxException("Unrecognized option '"+arg+"'");
}
} else {
targets.add(arg);
}
}
final DeploymentManager mgr = connection.getDeploymentManager();
TargetModuleID[] results;
Target[] tlist = identifyTargets(targets, mgr);
if(tlist.length == 0) {
tlist = mgr.getTargets();
}
try {
if(started == null) {
results = mgr.getAvailableModules(null, tlist);
} else if(started.booleanValue()) {
results = mgr.getRunningModules(null, tlist);
} else {
results = mgr.getNonRunningModules(null, tlist);
}
} catch (TargetException e) {
throw new DeploymentException("Unable to query modules", e);
} catch (IllegalStateException e) {
throw new DeploymentSyntaxException(e.getMessage());
}
if(results == null) {
results = new TargetModuleID[0];