重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
本篇文章为大家展示了activiti 5.16 businessKey如何为null处理。,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
尼木ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!
activiti版本 5.16
产生原因:创建子流程时,businesskey 不传递。
解决如下:
1、创建监听类:
import org.activiti.engine.delegate.event.ActivitiEntityEvent; import org.activiti.engine.delegate.event.ActivitiEvent; import org.activiti.engine.delegate.event.ActivitiEventListener; import org.activiti.engine.impl.persistence.entity.ExecutionEntity; import org.activiti.engine.impl.persistence.entity.TaskEntity; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class BusinessKeyInjectionActivitiEventListener implements ActivitiEventListener { private Logger log = LoggerFactory.getLogger(getClass()); @Override public void onEvent(ActivitiEvent event) { switch (event.getType()) { case TASK_CREATED: if (event instanceof ActivitiEntityEvent) { ActivitiEntityEvent activityEntityEvent = (ActivitiEntityEvent) event; TaskEntity taskEntity = (TaskEntity) activityEntityEvent.getEntity(); ExecutionEntity exEntity = taskEntity.getExecution(); String key = exEntity.getBusinessKey(); log.info("获取当前任务的流程实例的businessKey:{}",key); if(StringUtils.isEmpty(key)){ ExecutionEntity superExecEntity = exEntity.getSuperExecution(); key=superExecEntity.getBusinessKey(); if(StringUtils.isEmpty(key)){ key=superExecEntity.getProcessInstance().getBusinessKey(); } log.info("获取当前任务 上一个流程实例的businessKey:{}",key); log.info("设置当前流程实例的businessKey:{}",key); exEntity.setBusinessKey(key); //让businessKey生效 此处非常关键。 exEntity.updateProcessBusinessKey(key); } break; } default: break; } } @Override public boolean isFailOnException() { // TODO Auto-generated method stub return false; } }
2、配置监听:
上述内容就是activiti 5.16 businessKey如何为null处理。,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。