diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java index d9d299230..3b2eb8e20 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java @@ -77,10 +77,6 @@ public class FlowExecutor { DataBus.init(); } - public static FlowExecutor loadInstance(LiteflowConfig liteflowConfig){ - return new FlowExecutor(liteflowConfig); - } - /** * FlowExecutor的初始化化方式,主要用于parse规则文件 */ diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutorHolder.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutorHolder.java new file mode 100644 index 000000000..8371c909c --- /dev/null +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutorHolder.java @@ -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; + } +}