mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-20 10:18:10 +08:00
配置统一化,优化配置阶段代码
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.yomahub.liteflow.springboot;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.entity.data.DataBus;
|
||||
import com.yomahub.liteflow.monitor.MonitorBus;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.spring.ComponentScaner;
|
||||
import com.yomahub.liteflow.util.SpringAware;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -25,19 +27,28 @@ import java.util.List;
|
||||
public class LiteflowAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public ComponentScaner componentScaner(){
|
||||
public LiteflowConfig liteflowConfig(LiteflowProperty property, LiteflowMonitorProperty liteflowMonitorProperty){
|
||||
LiteflowConfig liteflowConfig = new LiteflowConfig();
|
||||
liteflowConfig.setRuleSource(property.getRuleSource());
|
||||
liteflowConfig.setSlotSize(property.getSlotSize());
|
||||
liteflowConfig.setWhenMaxWaitSecond(property.getWhenMaxWaitSecond());
|
||||
liteflowConfig.setEnableLog(liteflowMonitorProperty.isEnableLog());
|
||||
liteflowConfig.setQueueLimit(liteflowMonitorProperty.getQueueLimit());
|
||||
liteflowConfig.setDelay(liteflowMonitorProperty.getDelay());
|
||||
liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod());
|
||||
return liteflowConfig;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ComponentScaner componentScaner(LiteflowConfig liteflowConfig){
|
||||
return new ComponentScaner();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FlowExecutor flowExecutor(LiteflowProperty property){
|
||||
if(StringUtils.isNotBlank(property.getRuleSource())){
|
||||
List<String> ruleList = Lists.newArrayList(property.getRuleSource().split(","));
|
||||
public FlowExecutor flowExecutor(LiteflowConfig liteflowConfig){
|
||||
if(StrUtil.isNotBlank(liteflowConfig.getRuleSource())){
|
||||
FlowExecutor flowExecutor = new FlowExecutor();
|
||||
flowExecutor.setRulePath(ruleList);
|
||||
|
||||
DataBus.setSlotSize(property.getSlotSize());
|
||||
|
||||
flowExecutor.setLiteflowConfig(liteflowConfig);
|
||||
return flowExecutor;
|
||||
}else{
|
||||
return null;
|
||||
@@ -55,7 +66,7 @@ public class LiteflowAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MonitorBus monitorBus(LiteflowMonitorProperty property){
|
||||
return new MonitorBus(property.isEnableLog(), property.getQueueLimit(), property.getDelay(), property.getPeriod());
|
||||
public MonitorBus monitorBus(LiteflowConfig liteflowConfig){
|
||||
return new MonitorBus(liteflowConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ public class LiteflowProperty {
|
||||
|
||||
private int slotSize;
|
||||
|
||||
private int whenMaxWaitSecond;
|
||||
|
||||
public String getRuleSource() {
|
||||
return ruleSource;
|
||||
}
|
||||
@@ -24,4 +26,12 @@ public class LiteflowProperty {
|
||||
public void setSlotSize(int slotSize) {
|
||||
this.slotSize = slotSize;
|
||||
}
|
||||
|
||||
public int getWhenMaxWaitSecond() {
|
||||
return whenMaxWaitSecond;
|
||||
}
|
||||
|
||||
public void setWhenMaxWaitSecond(int whenMaxWaitSecond) {
|
||||
this.whenMaxWaitSecond = whenMaxWaitSecond;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user