}
// Activates an activity object
private void startActivity(GenericValue value) throws WfException {
WfActivity activity = WfFactory.getWfActivity(value, workEffortId);
GenericResultWaiter req = new GenericResultWaiter();
if (Debug.verboseOn()) Debug.logVerbose("[WfProcess.startActivity] : Attempting to start activity (" + activity.name() + ")", module);
// locate the dispatcher to use
LocalDispatcher dispatcher = this.getDispatcher();
// get the job manager
JobManager jm = dispatcher.getJobManager();
if (jm == null) {
throw new WfException("No job manager found on the service dispatcher; cannot start activity");
}
// using the StartActivityJob class to run the activity within its own thread
try {
Job activityJob = new StartActivityJob(activity, req);
jm.runJob(activityJob);
} catch (JobManagerException e) {
throw new WfException("JobManager error", e);
}
// the GenericRequester object will hold any exceptions; and report the job as failed
if (req.status() == GenericResultWaiter.SERVICE_FAILED) {
Throwable reqt = req.getThrowable();
if (reqt instanceof CannotStart)
Debug.logVerbose("[WfProcess.startActivity] : Cannot start activity. Waiting for manual start.", module);
else if (reqt instanceof AlreadyRunning)
throw new WfException("Activity already running", reqt);
else