mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
DataBus.init()多次被调用,不够优雅,改到放在初始化LiteFlowExecutor里去执行
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.yomahub.liteflow.builder;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.yomahub.liteflow.entity.data.DataBus;
|
||||
import com.yomahub.liteflow.entity.flow.*;
|
||||
import com.yomahub.liteflow.enums.ConditionTypeEnum;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
|
||||
@@ -79,11 +79,6 @@ public class LiteFlowNodeBuilder {
|
||||
}
|
||||
|
||||
public void build() {
|
||||
//这里也是一个防御性编程
|
||||
//如果单独用builder进行构建的话,那么flow.xml不一定存在,不存在则不会进行FlowExecutor的init,也就不会进行DataBus.init
|
||||
//所以这里多加一步,DataBus.init()事实上只会执行一遍,不会因为之前执行了,重复执行。因为里面有判断
|
||||
DataBus.init();
|
||||
|
||||
try {
|
||||
if (this.node.getType().equals(NodeTypeEnum.COMMON)) {
|
||||
FlowBus.addCommonNode(this.node.getId(), this.node.getName(), this.node.getClazz());
|
||||
|
||||
@@ -61,6 +61,8 @@ public class FlowExecutor {
|
||||
private LiteflowConfig liteflowConfig;
|
||||
|
||||
public FlowExecutor(){
|
||||
//初始化DataBus
|
||||
DataBus.init();
|
||||
}
|
||||
|
||||
public FlowExecutor(LiteflowConfig liteflowConfig){
|
||||
@@ -68,6 +70,8 @@ public class FlowExecutor {
|
||||
if (liteflowConfig.isParseOnStart()){
|
||||
this.init();
|
||||
}
|
||||
//初始化DataBus
|
||||
DataBus.init();
|
||||
}
|
||||
|
||||
public static FlowExecutor loadInstance(LiteflowConfig liteflowConfig){
|
||||
@@ -159,9 +163,6 @@ public class FlowExecutor {
|
||||
throw new FlowExecutorNotInitException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
//初始化DataBus
|
||||
DataBus.init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -177,10 +177,5 @@ public class FlowBus {
|
||||
} else if (type.equals(FlowParserTypeEnum.TYPE_YML)) {
|
||||
new LocalYmlFlowParser().parse(content);
|
||||
}
|
||||
|
||||
//这里是一个防御性策略,在parse-on-start参数为false的时候
|
||||
//启动时马上刷新流程规则,这时DataBus还未init,所以这时需要init一下
|
||||
//在DataBus里对init有判断,所以init不会执行多遍
|
||||
DataBus.init();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user