dengzedong
2024-12-24 76743b009ca5ea67557fcab597b332f8d1947813
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
package com.iailab.module.bpm.framework.flowable.core.listener.demo.exection;
 
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.flowable.bpmn.model.FieldExtension;
import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;
 
import java.util.List;
 
/**
 * 类型为 expression 的 ExecutionListener 监听器示例
 *
 * 和 {@link DemoDelegateClassExecutionListener} 的差异是,需要注册到 Spring 中,但不用实现 {@link org.flowable.engine.delegate.JavaDelegate} 接口
 */
@Component
@Slf4j
public class DemoSpringExpressionExecutionListener {
 
    public void execute(DelegateExecution execution) {
        log.info("[execute][execution({}) 执行监听器(spring表达式)被调用!变量有:{}]", execution.getId(),
                execution.getCurrentFlowableListener().getFieldExtensions());
        List<FieldExtension> fieldExtensions = execution.getCurrentFlowableListener().getFieldExtensions();
        if(ObjectUtils.isNotEmpty(fieldExtensions)) {
            fieldExtensions.stream().forEach(fieldExtension -> {
                System.out.println(fieldExtension.getFieldName());
                System.out.println(fieldExtension.getExpression());
            });
        }
    }
 
}