houzhongyi
2024-07-11 e7c1260db32209a078a962aaa0ad5492c35774fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.iailab.module.bpm.event;
 
import cn.hutool.core.util.StrUtil;
import org.springframework.context.ApplicationListener;
 
/**
 * {@link BpmProcessInstanceStatusEvent} 的监听器
 *
 * @author iailab
 */
public abstract class BpmProcessInstanceStatusEventListener
        implements ApplicationListener<BpmProcessInstanceStatusEvent> {
 
    @Override
    public final void onApplicationEvent(BpmProcessInstanceStatusEvent event) {
        if (!StrUtil.equals(event.getProcessDefinitionKey(), getProcessDefinitionKey())) {
            return;
        }
        onEvent(event);
    }
 
    /**
     * @return 返回监听的流程定义 Key
     */
    protected abstract String getProcessDefinitionKey();
 
    /**
     * 处理事件
     *
     * @param event 事件
     */
    protected abstract void onEvent(BpmProcessInstanceStatusEvent event);
 
}