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 31dba4b70..34695ad5d 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 @@ -71,8 +71,9 @@ public class FlowExecutor { /** * FlowExecutor的初始化化方式,主要用于parse规则文件 + * isStart表示是否是系统启动阶段,启动阶段要做额外的事情,而因为reload所调用的init就不用做 */ - public void init(boolean hook) { + public void init(boolean isStart) { if (ObjectUtil.isNull(liteflowConfig)) { throw new ConfigErrorException("config error, please check liteflow config property"); } @@ -82,8 +83,10 @@ public class FlowExecutor { // 在非spring体系下是一个空实现,等于不做此步骤 ContextCmpInitHolder.loadContextCmpInit().initCmp(); - // 进行id生成器的初始化 - IdGeneratorHolder.init(); + if (isStart){ + // 进行id生成器的初始化 + IdGeneratorHolder.init(); + } String ruleSource = liteflowConfig.getRuleSource(); if (StrUtil.isBlank(ruleSource)) { @@ -191,7 +194,7 @@ public class FlowExecutor { } // 执行钩子 - if (hook) { + if (isStart) { FlowInitHook.executeHook(); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/id/IdGeneratorHolder.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/id/IdGeneratorHolder.java index a5ef66665..31c4e6d64 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/id/IdGeneratorHolder.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/id/IdGeneratorHolder.java @@ -1,5 +1,6 @@ package com.yomahub.liteflow.flow.id; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.exception.RequestIdGeneratorException; import com.yomahub.liteflow.property.LiteflowConfig; @@ -44,6 +45,9 @@ public class IdGeneratorHolder { } public String generate() { + if (ObjectUtil.isNull(requestIdGenerator)){ + init(); + } return requestIdGenerator.generate(); }