关于两种常用的监听
FlowAble监听的两个监听taskListener 和 executionListener 注意如果想要让flowable或activiti能获取到service 那么最好在调用的service 用 Component 注解 并指定名称 例如:@Component("sequenceFlowListener") 1、TaskListener 主要是监听usertask的情况,监听事件event有4种: create 创建 assignment 分配人 complete 完成 delete 删除 代码: @Service public class CountersignTaskListener implements TaskListener{ @Override public void notify(DelegateTask delegateTask) { System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaa"); System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaa"); } } xml: <userTask id="USERTASK" name="USERTASK" > <extensionElements> <activiti:taskListener event="create" delegateExpression="${sequenceFlowListener}"/> </extensionElements> </userTask> 2、ExecutionListener 主要是监听 sequenceFlow的监听器,监听事件有3种 start 开始 take 启用 end 结束 代码如下; @Component("sequenceFlowListener") public class SequenceFlowListener implements ExecutionListener { @Override public void notify(DelegateExecution execution) { System.out.println("aaaaaaaaaaaaaa"); execution.setVariable("审批人","111"); System.out.println("aaaaaaaaaaaaaa"); } } xml: <sequenceFlow id="sequenceFlow-b619e9a1-9e15-4ada-9bf6-54e0fcf7f6c8" name="条件1" sourceRef="gateWay-9134083e-a2a3-4021-9628-f478602c5933" targetRef="userTask-counterSign-0ae5c7c5-b282-4e4d-b8dd-b3d5fe623583"> <extensionElements> <flowable:executionListener event="take" delegateExpression="${sequenceFlowListener}"></flowable:executionListener> </extensionElements> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${conditionService.checkCondition(1,'userTask-counterSign-0ae5c7c5-b282-4e4d-b8dd-b3d5fe623583',execution)}]]></conditionExpression> </sequenceFlow>