activiti 7监听器

一、创建监听器MyExecutionListener
package com.ruoyi.web.listener; import org.activiti.engine.delegate.DelegateExecution; import org.activiti.engine.delegate.ExecutionListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MyExecutionListener implements ExecutionListener { private static final Logger log = LoggerFactory.getLogger(MyExecutionListener.class); @Override public void notify(DelegateExecution execution) { String eventName = execution.getEventName(); switch (eventName) { case "start": log.info("eventName = {} 启动了", eventName); break; case "end": log.info("eventName = {} 结束了", eventName); break; case "take": log.info("eventName = {} 接收了", eventName); break; default: log.info("eventName = {} 默认执行了", eventName); } } }
二、创建测试流程
<?xml version="1.0" encoding="UTF-8"?> <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:activiti="http://activiti.org/bpmn" id="sample-diagram" targetNamespace="http://activiti.org/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="leave" name="测试请假流程" isExecutable="true"> <bpmn2:startEvent id="StartEvent_1" name="开始" activiti:initiator="guanxing,zhaoyun"> <bpmn2:extensionElements> <activiti:executionListener class="com.ruoyi.web.listener.MyExecutionListener" event="start" /> </bpmn2:extensionElements> <bpmn2:outgoing>Flow_1j0swj3</bpmn2:outgoing> </bpmn2:startEvent> <bpmn2:userTask id="Activity_1awxkhg" name="部门审核"> <bpmn2:incoming>Flow_1j0swj3</bpmn2:incoming> <bpmn2:outgoing>Flow_1h9ftf8</bpmn2:outgoing> </bpmn2:userTask> <bpmn2:userTask id="Activity_1af1xeg" name="人事审核"> <bpmn2:incoming>Flow_1h9ftf8</bpmn2:incoming> <bpmn2:outgoing>Flow_1ha3ul5</bpmn2:outgoing> </bpmn2:userTask> <bpmn2:endEvent id="Event_1ltadn6" name="结束"> <bpmn2:incoming>Flow_1ha3ul5</bpmn2:incoming> </bpmn2:endEvent> <bpmn2:sequenceFlow id="Flow_1j0swj3" sourceRef="StartEvent_1" targetRef="Activity_1awxkhg" /> <bpmn2:sequenceFlow id="Flow_1h9ftf8" sourceRef="Activity_1awxkhg" targetRef="Activity_1af1xeg" /> <bpmn2:sequenceFlow id="Flow_1ha3ul5" sourceRef="Activity_1af1xeg" targetRef="Event_1ltadn6" /> </bpmn2:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="leave"> <bpmndi:BPMNEdge id="Flow_1j0swj3_di" bpmnElement="Flow_1j0swj3"> <di:waypoint x="268" y="180" /> <di:waypoint x="400" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1h9ftf8_di" bpmnElement="Flow_1h9ftf8"> <di:waypoint x="500" y="180" /> <di:waypoint x="640" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1ha3ul5_di" bpmnElement="Flow_1ha3ul5"> <di:waypoint x="740" y="180" /> <di:waypoint x="872" y="180" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> <dc:Bounds x="232" y="162" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="239" y="205" width="22" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1awxkhg_di" bpmnElement="Activity_1awxkhg"> <dc:Bounds x="400" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1af1xeg_di" bpmnElement="Activity_1af1xeg"> <dc:Bounds x="640" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_1ltadn6_di" bpmnElement="Event_1ltadn6"> <dc:Bounds x="872" y="162" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="879" y="205" width="22" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions>

浙公网安备 33010602011771号