提供FlowExecutorHolder的实现

This commit is contained in:
bryan31
2022-03-07 19:18:59 +08:00
parent c54e1a9cdc
commit d1421adc53
2 changed files with 28 additions and 4 deletions

View File

@@ -77,10 +77,6 @@ public class FlowExecutor {
DataBus.init();
}
public static FlowExecutor loadInstance(LiteflowConfig liteflowConfig){
return new FlowExecutor(liteflowConfig);
}
/**
* FlowExecutor的初始化化方式主要用于parse规则文件
*/

View File

@@ -0,0 +1,28 @@
package com.yomahub.liteflow.core;
import cn.hutool.core.util.ObjectUtil;
import com.yomahub.liteflow.exception.FlowExecutorNotInitException;
import com.yomahub.liteflow.property.LiteflowConfig;
public class FlowExecutorHolder {
private static FlowExecutor flowExecutor;
public static FlowExecutor loadInstance(LiteflowConfig liteflowConfig){
if (ObjectUtil.isNull(flowExecutor)){
flowExecutor = new FlowExecutor(liteflowConfig);
}
return flowExecutor;
}
public static FlowExecutor loadInstance(){
if (ObjectUtil.isNull(flowExecutor)){
throw new FlowExecutorNotInitException("flow executor is not initialized yet");
}
return flowExecutor;
}
public static void clean(){
flowExecutor = null;
}
}