if (!checkProcessInstance(stateEvent)) { returnfalse; }
boolean result = false; switch (stateEvent.getType()) { case PROCESS_STATE_CHANGE: result = processStateChangeHandler(stateEvent); break; case TASK_STATE_CHANGE: result = taskStateChangeHandler(stateEvent); break; case PROCESS_TIMEOUT: result = processTimeout(); break; case TASK_TIMEOUT: result = taskTimeout(stateEvent); break; case WAIT_TASK_GROUP: result = checkForceStartAndWakeUp(stateEvent); break; case TASK_RETRY: result = taskRetryEventHandler(stateEvent); break; default: break; }
if (result) { this.stateEvents.remove(stateEvent); } return result; }
// 进行状态改变操作 privatebooleantaskStateChangeHandler(StateEvent stateEvent){ if (!checkTaskInstanceByStateEvent(stateEvent)) { returntrue; }
TaskInstance task = getTaskInstance(stateEvent.getTaskInstanceId()); if (task.getState() == null) { logger.error("task state is null, state handler error: {}", stateEvent); returntrue; }
if (task.getState().typeIsFinished()) { if (completeTaskMap.containsKey(task.getTaskCode()) && completeTaskMap.get(task.getTaskCode()) == task.getId()) { returntrue; } taskFinished(task); if (task.getTaskGroupId() > 0) { releaseTaskGroup(task); } returntrue; } if (activeTaskProcessorMaps.containsKey(task.getTaskCode())) { ITaskProcessor iTaskProcessor = activeTaskProcessorMaps.get(task.getTaskCode()); iTaskProcessor.action(TaskAction.RUN);