1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| // 1. CompleteTaskCmd.executeTaskComplete(), 触发任务节点完成行为 Context.getAgenda().planTriggerExecutionOperation(executionEntity);
// 2. TriggerExecutionOperation.run(), 真正触发代码 ((TriggerableActivityBehavior) activityBehavior).trigger(execution, null, null);
// 3. 执行UserTaskActivityBehavior.trigger(DelegateExecution, String, Object) leave(execution);// 执行节点离开之后的操作
// 4. 当前节点不是多实例, 执行上面的代码 if (!hasLoopCharacteristics()) { // 如果不是多实例执行 super.leave(execution); } else if (hasMultiInstanceCharacteristics()) { // 节点包含多实例执行 multiInstanceActivityBehavior.leave(execution); }
// 5. 流程继续向下走, 执行节点流出操作 bpmnActivityBehavior.performDefaultOutgoingBehavior((ExecutionEntity) execution);
// 6. 取出下一个节点, 向下执行 TakeOutgoingSequenceFlowsOperation.run() // 取出下个节点, 流程继续向下走 execution.setCurrentFlowElement(sequenceFlow); execution.setActive(true); outgoingExecutions.add((ExecutionEntity) execution); Context.getAgenda().planContinueProcessOperation(outgoingExecution);
// 7. 流程继续执行ContinueProcessOperation.run() // 取出当前节点 FlowElement currentFlowElement = getCurrentFlowElement(execution); if (currentFlowElement instanceof FlowNode) { continueThroughFlowNode((FlowNode) currentFlowElement); } else if (currentFlowElement instanceof SequenceFlow) { // 当前节点是连接线, 走这个分支, continueThroughSequenceFlow((SequenceFlow) currentFlowElement); }
protected void continueThroughSequenceFlow(SequenceFlow sequenceFlow) { // 取出下面节点 FlowElement targetFlowElement = sequenceFlow.getTargetFlowElement(); execution.setCurrentFlowElement(targetFlowElement); // 执行流程继续操作 Context.getAgenda().planContinueProcessOperation(execution); }
// 8. ContinueProcessOperation.run(), 继续执行代码, 现在执行才是上一个节点完成后的下一个任务节点, 就是多实例节点 if (currentFlowElement instanceof FlowNode) { // UserTask执行该分支 continueThroughFlowNode((FlowNode) currentFlowElement); }
// 下面是continueThroughFlowNode()方法的代码片段 if (flowNode instanceof Activity && ((Activity) flowNode).hasMultiInstanceLoopCharacteristics()) { // 初始化多实例节点 executeMultiInstanceSynchronous(flowNode); }
// 下面是executeMultiInstanceSynchronous()方法的代码片段 // 获取多实例处理行为 ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior(); // 执行多实例节点能力 executeActivityBehavior(activityBehavior, flowNode); // 调用子类的能力 activityBehavior.execute(execution); // 9. ParallelMultiInstanceBehavior.execute() // 执行, 多实例节点的能力全部在这个类中 MultiInstanceActivityBehavior.execute(); // 创建会签多实例 ParallelMultiInstanceBehavior.createInstances(execution);// // 创建子类执行流 // ParallelGatewayActivityBehavior执行execute()方法 ParallelMultiInstanceBehavior.createInstances()// 创建实例对象 // 创建子执行流的具体的执行代码 Context.getAgenda().planContinueMultiInstanceOperation((ExecutionEntity) execution);
|