本篇文章為大家展示了activiti 5.16 businessKey如何為null處理。,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
尼木ssl適用于網站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18980820575(備注:SSL證書合作)期待與您的合作!
activiti版本 5.16
產生原因:創(chuàng)建子流程時,businesskey 不傳遞。
解決如下:
1、創(chuàng)建監(jiān)聽類:
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、配置監(jiān)聽:
上述內容就是activiti 5.16 businessKey如何為null處理。,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。