Flowable源码地址:https://github.com/flowable/flowable-engine
Flowable-6.7.2 源码注释地址:https://github.com/solojin/flowable-6.7.2-annotated
包路径:org.activiti.engine.impl.bpmn.helper
ClassDelegate 类委托
继承TaskListener、ExecutionListener等接口
/**
* 用于允许类委派的bpmn构造的帮助器类。
*
* 在运行时需要时,该类将惰性地实例化引用的类。
*
* @author Joram Barrez
* @author Falko Menge
* @author Saeid Mirzaei
*/
public class ClassDelegate extends AbstractBpmnActivityBehavior implements TaskListener, ExecutionListener, SubProcessActivityBehavior {
protected String className;
protected List<FieldDeclaration> fieldDeclarations;
protected ExecutionListener executionListenerInstance;
protected TaskListener taskListenerInstance;
protected ActivityBehavior activityBehaviorInstance;
protected Expression skipExpression;
protected List<MapExceptionEntry> mapExceptions;
protected String serviceTaskId;
public ClassDelegate(String className, List<FieldDeclaration> fieldDeclarations, Expression skipExpression) {
this.className = className;
this.fieldDeclarations = fieldDeclarations;
this.skipExpression = skipExpression;
}
public ClassDelegate(String id, String className, List<FieldDeclaration> fieldDeclarations, Expression skipExpression, List<MapExceptionEntry> mapExceptions) {
this(className, fieldDeclarations, skipExpression);
this.serviceTaskId = id;
this.mapExceptions = mapExceptions;
}
public ClassDelegate(String className, List<FieldDeclaration> fieldDeclarations) {
this(className, fieldDeclarations, null);
}
public ClassDelegate(Class<?> clazz, List<FieldDeclaration> fieldDeclarations) {
this(clazz.getName(), fieldDeclarations, null);
}
public ClassDelegate(Class<?> clazz, List<FieldDeclaration> fieldDeclarations, Expression skipExpression) {
this(clazz.getName(), fieldDeclarations, skipExpression);
}
// 执行 监听器
@Override
public void notify(DelegateExecution execution) {
if (executionListenerInstance == null) {
executionListenerInstance = getExecutionListenerInstance();
}
Context.getProcessEngineConfiguration()
.getDelegateInterceptor()
.handleInvocation(new ExecutionListenerInvocation(executionListenerInstance, execution));
}
protected ExecutionListener getExecutionListenerInstance() {
Object delegateInstance = instantiateDelegate(className, fieldDeclarations);
if (delegateInstance instanceof ExecutionListener) {
return (ExecutionListener) delegateInstance;
} else if (delegateInstance instanceof JavaDelegate) {
return new ServiceTaskJavaDelegateActivityBehavior((