从 activiti监听器的使用范围来看,大致分为三种:
1.全局的监听器。
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="daling">
<process id="daling" name="name_daling" isExecutable="true" activiti:candidateStarterUsers="a,b,c,d">
<!-- 全局的监控器 -->
<extensionElements>
<activiti:executionListener event="start" class="com.daling.ch1.listener.MyExecutionListener"></activiti:executionListener>
<activiti:executionListener event="end" class="com.daling.ch1.listener.MyExecutionListener"></activiti:executionListener>
</extensionElements>
<startEvent id="startevent1" name="Start"></startEvent>
<endEvent id="endevent1" name="End"></endEvent>
<userTask id="usertask2" name="User Task" activiti:assignee="c">
<!-- 节点任务的监控器 -->
<extensionElements>
<activiti:taskListener event="all" class="com.daling.ch1.listener.MyExecutionListener"></activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow3" name="flow3" sourceRef="startevent1" targetRef="usertask2">
<!-- 连线的监控器 -->
<extensionElements>
<activiti:executionListener event="take" class="com.daling.ch1.listener.MyExecutionListener"></activiti:executionListener>
</extensionElements>
</sequenceFlow>
<sequenceFlow id="flow4" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_daling">
<bpmndi:BPMNPlane bpmnElement="daling" id="BPMNPlane_daling">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="120.0" y="110.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="640.0" y="90.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
<omgdc:Bounds height="55.0" width="105.0" x="300.0" y="90.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="155.0" y="127.0"></omgdi:waypoint>
<omgdi:waypoint x="300.0" y="117.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="100.0" x="155.0" y="127.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="405.0" y="117.0"></omgdi:waypoint>
<omgdi:waypoint x="640.0" y="107.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
2.连线的监听器。—— 如上注释
3.节点的监听器。—— 如上注释