Flowable源码地址:https://github.com/flowable/flowable-engine
Flowable-6.7.2 源码注释地址:https://github.com/solojin/flowable-6.7.2-annotated
事件解析处理器,包路径:org.flowable.engine.impl.bpmn.parser.handler
ConditionalEventDefinitionParseHandler 条件事件定义解析器
/**
* 条件事件定义解析器
*
* @author Tijs Rademakers
*/
public class ConditionalEventDefinitionParseHandler extends AbstractBpmnParseHandler<ConditionalEventDefinition> {
@Override
public Class<? extends BaseElement> getHandledType() {
return ConditionalEventDefinition.class;
}
@Override
protected void executeParse(BpmnParse bpmnParse, ConditionalEventDefinition eventDefinition) {
if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement();
intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchConditionalEventActivityBehavior(
intermediateCatchEvent, eventDefinition, eventDefinition.getConditionExpression()));
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryConditionalEventActivityBehavior(boundaryEvent,
eventDefinition, eventDefinition.getConditionExpression(), boundaryEvent.isCancelActivity()));
}
}
}
ErrorEventDefinitionParseHandler 错误事件解析处理器
/**
* 错误事件解析处理器
*
* @author Joram Barrez
* @author Tijs Rademakers
*/
public class ErrorEventDefinitionParseHandler extends AbstractBpmnParseHandler<ErrorEventDefinition> {
@Override
public Class<? extends BaseElement> getHandledType() {
return ErrorEventDefinition.class;
}
@Override
protected void executeParse(BpmnParse bpmnParse, ErrorEventDefinition eventDefinition) {
if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, true));
}
}
}
TimerEventDefinitionParseHandler 定时器定义解析处理器
/**
* 定时器定义解析处理器
*
* @author Joram Barrez
*/
public class TimerEventDefinitionParseHandler extends AbstractBpmnParseHandler<TimerEventDefinition> {
@Override
public Class<? extends BaseElement> getHandledType() {
return TimerEventDefinition.class;
}
@Override
protected void executeParse(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition) {
if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement();
intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchTimerEventActivityBehavior(intermediateCatchEvent, timerEventDefinition));
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryTimerEventActivityBehavior(boundaryEvent, timerEventDefinition, boundaryEvent.isCancelActivity()));
}
}
}
VariableListenerEventDefinitionParseHandler 变量监听器事件定义解析处理器
/**
* 变量监听器事件定义解析处理器
*
* @author Joram Barrez
* @author Tijs Rademakers
*/
public class VariableListenerEventDefinitionParseHandler extends AbstractBpmnParseHandler<VariableListenerEventDefinition> {
@Override
public Class<? extends BaseElement> getHandledType() {
return VariableListenerEventDefinition.class;
}
@Override
protected void executeParse(BpmnParse bpmnParse, VariableListenerEventDefinition variableListenerEventDefinition) {
if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement();
intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchVariableListenerEventActivityBehavior(intermediateCatchEvent, variableListenerEventDefinition));
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryVariableListenerEventActivityBehavior(boundaryEvent, variableListenerEventDefinition, boundaryEvent.isCancelActivity()));
}
}
}
EscalationEventDefinitionParseHandler 升级事件定义解析处理器
/**
* 升级事件定义解析处理器
*
* @author Tijs Rademakers
*/
public class EscalationEventDefinitionParseHandler extends AbstractBpmnParseHandler<EscalationEventDefinition> {
@Override
public Class<? extends BaseElement> getHandledType() {
return EscalationEventDefinition.class;
}
@Override
protected void executeParse(BpmnParse bpmnParse, EscalationEventDefinition eventDefinition) {
if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
Escalation escalation = null;
if (bpmnParse.getBpmnModel().containsEscalationRef(eventDefinition.getEscalationCode())) {
escalation = bpmnParse.getBpmnModel().getEscalation(eventDefinition.getEscalationCode());
}
boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEscalationEventActivityBehavior(boundaryEvent,
eventDefinition, escalation, boundaryEvent.isCancelActivity()));
}
}
}
本文深入解析Flowable流程引擎中的事件处理,包括条件事件、错误事件、定时器事件、变量监听器事件和升级事件的定义解析处理器。通过源码注释,详细介绍了每个处理器在流程中的作用和实现原理。
919

被折叠的 条评论
为什么被折叠?



