一、核心配置类

package com.magus.project.flow.config;

import com.google.common.collect.Maps;
import com.magus.project.flow.listener.ProcessStartedListener;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map; /**
* @Description flowable全局监听器配置类
* @author: lxk
* @Date 2020年6月17日14:44:33
*/
@Configuration
public class FlowableListenerConfig { /**
* 任务节点前置监听
* flowable监听级别参照 {@link FlowableEngineEventType} org.flowable.common.engine.api.delegate.event
*/
private static final String CUSTOMER_LISTENER_PROCESS_STARTED = "PROCESS_STARTED"; /**
* 任务节点前置监听
* 自己建立监听类实现FlowableEventListener接口
*/
private final ProcessStartedListener taskBeforeListener; @Autowired
public FlowableListenerConfig(ProcessStartedListener taskBeforeListener) {
this.taskBeforeListener = taskBeforeListener;
} /**
* 将自定义监听器纳入flowable监听
*
* @param
* @return org.flowable.spring.boot.EngineConfigurationConfigurer
*/
@Bean
public EngineConfigurationConfigurer globalListenerConfigurer() {
return engineConfiguration -> {
engineConfiguration.setTypedEventListeners(this.customFlowableListeners());
};
} /**
* 监听类配置 {@link FlowableEngineEventType} flowable监听器级别
*
* @param
* @return java.util.Map>
*/
private Map> customFlowableListeners() {
Map> listenerMap = Maps.newHashMap();
listenerMap.put(CUSTOMER_LISTENER_PROCESS_STARTED, new ArrayList<>(Collections.singletonList(taskBeforeListener)));
return listenerMap;
} }
二、监听器 package com.magus.project.flow.listener; import com.magus.framework.core.springbean.SpringContextUtils;
import com.magus.project.flow.constants.Constant;
import com.magus.project.flow.webBean.FormRelevant;
import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.event.impl.FlowableProcessEventImpl;
import org.springframework.stereotype.Component; /**
* 流程实例开始,监听处理类
* @author: lxk
* @create: 2020年6月17日14:47:52
**/
@Slf4j
@Component
public class ProcessStartedListener implements FlowableEventListener { @Override
public void onEvent(FlowableEvent event) {
log.error("----------前置监听器{},执行开始----------");
FlowableProcessEventImpl eventImpl = (FlowableProcessEventImpl) event;
RuntimeService runtimeService = SpringContextUtils.getBean(RuntimeService.class);
runtimeService.setVariable(eventImpl.getExecutionId(), Constant.PROCESS_FORM_SKIP_EBABLE, true); //获取流程启动是设置的变量对象
FormRelevant formRelevant = (FormRelevant) runtimeService.getVariable(eventImpl.getExecutionId(), Constant.PROCESS_FORM_RELEVANT_KEY); log.error("----------前置监听器{},执行结束----------");
} @Override
public boolean isFailOnException() {
return false;
} @Override
public boolean isFireOnTransactionLifecycleEvent() {
return false;
} @Override
public String getOnTransaction() {
return null;
}
}

最新文章

  1. Selenium_IEDriver操作sendkeys输入速度太慢
  2. android中如何在低版本(5.0之前)上使用tint(着色)属性
  3. C++ TR1 Function Bind
  4. SDK Manager 中 没有 Support Library怎么弄?
  5. jQuery 插件autocomplete
  6. Normalize [ 浏览器渲染格式化 ]
  7. POJ3616 Milking Time 简单DP
  8. ViewPager切换大量Fragment不刷新的问题
  9. Linux备份
  10. vi命令提示:Terminal too wide
  11. Springmvc+Spring+Hibernate搭建方法
  12. 我的python之路【第二篇】数据类型与方法
  13. js转换字符串为数值的方法
  14. 快速开发基于 HTML5 网络拓扑图应用--入门篇(二)
  15. linux搭建FastDFS文件服务器
  16. Spring Security 之API 项目安全验证(基于basic-authentication)
  17. python爬取猫眼电影top100
  18. mycat 从入门到放弃 (转)
  19. Nand
  20. 构造函数与 new 命令

热门文章

  1. loading爬坑--跳出思维误区
  2. 第8.4节 Python类中不是构造方法却胜似构造方法的__new方法__深入剖析:语法释义
  3. PyQt(Python+Qt)学习随笔:QTabWidget部件选项卡可用状态访问方法isTabEnabled、setTabEnabled
  4. 第8.33节 Python中__getattr__以及__getattr__与__ getattribute__的关系深入剖析
  5. 第14.15节 爬虫实战1:使用Python和selenium实现csdn博文点赞
  6. PyQt学习随笔:重写setData方法截获Model/View中视图数据项编辑的注意事项
  7. PyQt(Python+Qt)学习随笔:QAbstractItemView的SelectionBehavior属性
  8. PyQt(Python+Qt)学习随笔:图例解释QFrame类的lineWidth、midLineWidth以及frameWidth属性
  9. PyQt(Python+Qt)学习随笔:Qt Designer中主窗口对象的dockOptions属性
  10. go中位运算