dengzedong
2024-12-24 aa0382e44311f9f7e62a688c8fcaa9c69a512e0f
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.bpm.framework.flowable.core.listener.demo.exection;
H 2
3 import lombok.extern.slf4j.Slf4j;
49b4b6 4 import org.apache.commons.lang3.ObjectUtils;
H 5 import org.flowable.bpmn.model.FieldExtension;
e7c126 6 import org.flowable.engine.delegate.DelegateExecution;
H 7 import org.flowable.engine.delegate.JavaDelegate;
8 import org.springframework.stereotype.Component;
49b4b6 9
H 10 import java.util.List;
e7c126 11
H 12 /**
13  * 类型为 delegateExpression 的 ExecutionListener 监听器示例
14  *
15  * 和 {@link DemoDelegateClassExecutionListener} 的差异是,需要注册到 Spring 中
16  */
17 @Component
18 @Slf4j
19 public class DemoDelegateExpressionExecutionListener implements JavaDelegate {
20
21     @Override
22     public void execute(DelegateExecution execution) {
49b4b6 23         log.info("[execute][execution({}) 执行监听器(委托表达式被调用)!变量有:{}]", execution.getId(),
e7c126 24                 execution.getCurrentFlowableListener().getFieldExtensions());
49b4b6 25         List<FieldExtension> fieldExtensions = execution.getCurrentFlowableListener().getFieldExtensions();
H 26         if(ObjectUtils.isNotEmpty(fieldExtensions)) {
27             fieldExtensions.stream().forEach(fieldExtension -> {
28                 System.out.println(fieldExtension.getFieldName());
29                 System.out.println(fieldExtension.getStringValue());
30             });
31         }
e7c126 32     }
H 33
34 }