服务热线
135-6963-3175
TriggerExecutionOperation分析代码发现在行为类里主要用于离开节点。
触发等待状态并继续该过程的操作,离开该活动。
看代码:
@Override
public void run() {
FlowElement currentFlowElement = getCurrentFlowElement(execution);
if (currentFlowElement instanceof FlowNode) {//是个节点
ActivityBehavior activityBehavior = (ActivityBehavior) ((FlowNode) currentFlowElement).getBehavior();
if (activityBehavior instanceof TriggerableActivityBehavior) {//属于可触发行为
if (currentFlowElement instanceof BoundaryEvent) {//边界事件
commandContext.getHistoryManager().recordActivityStart(execution);//历史记录活动开始
}
//触发行为,触发当前节点行为类,用于离开
((TriggerableActivityBehavior) activityBehavior).trigger(execution, null, null);
if (currentFlowElement instanceof BoundaryEvent) {//边界事件
commandContext.getHistoryManager().recordActivityEnd(execution, null);//历史记录活动结束
}
} else {
throw new ActivitiException("Invalid behavior: " + activityBehavior + " should implement " + TriggerableActivityBehavior.class.getName());
}
} else {
throw new ActivitiException("Programmatic error: no current flow element found or invalid type: " + currentFlowElement + ". Halting.");
}
}做了操作:
若是个节点且行为属于可触发行为(也就是节点行为类实现了以下接口)
public interface TriggerableActivityBehavior extends ActivityBehavior {
void trigger(DelegateExecution execution, String signalEvent, Object signalData);
}则继续执行:
a.当是边界事件,则记录历史活动开始(入库ACT_HI_ACTINST)
b.触发行为,触发当前节点行为类的trigger (大多数trigger用于离开)
c.当是边界事件,则:记录历史活动结束(更新结束信息(结束时间、花费时间、删除原因));
历史活动实例结束事件调度;
我们可以看几个行为类的trigger方法:
UserTaskActivityBehavior:
public void trigger(DelegateExecution execution, String signalName, Object signalData) {
CommandContext commandContext = Context.getCommandContext();
TaskEntityManager taskEntityManager = commandContext.getTaskEntityManager();
List<TaskEntity> taskEntities = taskEntityManager.findTasksByExecutionId(execution.getId()); // Should be only one
for (TaskEntity taskEntity : taskEntities) {
if (!taskEntity.isDeleted()) {
throw new ActivitiException("UserTask should not be signalled before complete");
}
}
//离开操作
leave(execution);
}
ReceiveTaskActivityBehavior:
public void trigger(DelegateExecution execution, String signalName, Object data) {
leave(execution);
}发现trigger主要用于离开节点(planTakeOutgoingSequenceFlowsOperation)