in taverna-server-worker/src/main/java/org/apache/taverna/server/localworker/impl/LocalWorker.java [667:744]
public void setStatus(RemoteStatus newStatus)
throws IllegalStateTransitionException, RemoteException,
ImplementationException, StillWorkingOnItException {
if (status == newStatus)
return;
switch (newStatus) {
case Initialized:
throw new IllegalStateTransitionException(
"may not move back to start");
case Operating:
switch (status) {
case Initialized:
boolean started;
try {
started = createWorker();
} catch (Exception e) {
throw new ImplementationException(
"problem creating executing workflow", e);
}
if (!started)
throw new StillWorkingOnItException(
"workflow start in process");
break;
case Stopped:
try {
core.startWorker();
} catch (Exception e) {
throw new ImplementationException(
"problem continuing workflow run", e);
}
break;
case Finished:
throw new IllegalStateTransitionException("already finished");
default:
break;
}
status = Operating;
break;
case Stopped:
switch (status) {
case Initialized:
throw new IllegalStateTransitionException(
"may only stop from Operating");
case Operating:
try {
core.stopWorker();
} catch (Exception e) {
throw new ImplementationException(
"problem stopping workflow run", e);
}
break;
case Finished:
throw new IllegalStateTransitionException("already finished");
default:
break;
}
status = Stopped;
break;
case Finished:
switch (status) {
case Operating:
case Stopped:
try {
core.killWorker();
if (finish == null)
finish = new Date();
} catch (Exception e) {
throw new ImplementationException(
"problem killing workflow run", e);
}
default:
break;
}
status = Finished;
break;
}
}