static final String DEBUG_OPTS = " -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005";
static final String DEFAULT_OPTS = "-server -Xmx512M -Dcom.sun.management.jmxremote";
protected Object doExecute() throws Exception {
MultiException exception = new MultiException("Error starting instance(s)");
List<Instance> toWaitFor = new ArrayList<>();
for (Instance instance : getMatchingInstances(instances)) {
try {
String opts = javaOpts;
if (opts == null) {
opts = instance.getJavaOpts();
}
if (opts == null) {
opts = DEFAULT_OPTS;
}
if (debug) {
opts += DEBUG_OPTS;
}
if (wait) {
String state = instance.getState();
if (Instance.STOPPED.equals(state)) {
instance.start(opts);
toWaitFor.add(instance);
}
} else {
instance.start(opts);
}
} catch (Exception e) {
exception.addException(e);
}
}
exception.throwIfExceptions();
while (true) {
boolean allStarted = true;
for (Instance child : toWaitFor) {
allStarted &= Instance.STARTED.equals(child.getState());
}