@QueryParam(value="wait") String waitParam)
{
RunManager rm = RunManager.getInstance();
try {
Runner r = rm.get(runner);
if (r == null) {
throw new RunnerException("Request for unknown runner: " +
runner);
}
boolean wait = false;
if (waitParam != null) {
wait = Boolean.parseBoolean(waitParam);
}
StatusWaiter waiter = null;
if (action.equalsIgnoreCase("start")) {
waiter = rm.start(r, wait);
} else if (action.equalsIgnoreCase("stop")) {
waiter = rm.stop(r, wait);
} else if (action.equalsIgnoreCase("restart")) {
// stop the runner and wait for it to stop
waiter = rm.stop(r, true);
if (waiter != null) {
waiter.waitFor();
}
// wait for a bit so that everything gets cleaned up
try {
Thread.sleep(ActionResource.getRestartDelay() * 1000);
} catch (InterruptedException ie) {
// oh well
}
// restart the runner
waiter = rm.start(r, wait);
} else if (action.equalsIgnoreCase("log")) {
// read the log file
if (r.getLogFile() != null) {
BufferedReader reader = new BufferedReader(
new FileReader(r.getLogFile()));
StringBuffer sb = new StringBuffer();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
sb.append("\n");