加入格式化代码插件,并提交格式化后的代码

This commit is contained in:
everywhere.z
2023-03-20 11:50:40 +08:00
parent 1f13db48fc
commit ec50e3a0af
1756 changed files with 24781 additions and 22473 deletions

View File

@@ -4,20 +4,21 @@ import com.yomahub.liteflow.core.FlowExecutor;
import org.springframework.beans.factory.InitializingBean;
/**
* 执行器初始化类
* 主要用于在启动时执行执行器的初始化方法,避免在运行执行器时第一次初始化而耗费时间
* 执行器初始化类 主要用于在启动时执行执行器的初始化方法,避免在运行执行器时第一次初始化而耗费时间
*
* @author Bryan.Zhang
*/
public class LiteflowExecutorInit implements InitializingBean {
private final FlowExecutor flowExecutor;
private final FlowExecutor flowExecutor;
public LiteflowExecutorInit(FlowExecutor flowExecutor) {
this.flowExecutor = flowExecutor;
}
public LiteflowExecutorInit(FlowExecutor flowExecutor) {
this.flowExecutor = flowExecutor;
}
@Override
public void afterPropertiesSet() throws Exception {
flowExecutor.init(true);
}
@Override
public void afterPropertiesSet() throws Exception {
flowExecutor.init(true);
}
}

View File

@@ -4,52 +4,54 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* 监控器的基础参数类
*
* @author Bryan.Zhang
*/
@ConfigurationProperties(prefix = "liteflow.monitor", ignoreUnknownFields = true)
public class LiteflowMonitorProperty {
//是否打印监控日志
private boolean enableLog;
// 是否打印监控日志
private boolean enableLog;
//监控队列存储的最大数量
private int queueLimit;
// 监控队列存储的最大数量
private int queueLimit;
//延迟多少毫秒打印
private long delay;
// 延迟多少毫秒打印
private long delay;
//每隔多少毫秒打印
private long period;
// 每隔多少毫秒打印
private long period;
public boolean isEnableLog() {
return enableLog;
}
public boolean isEnableLog() {
return enableLog;
}
public void setEnableLog(boolean enableLog) {
this.enableLog = enableLog;
}
public void setEnableLog(boolean enableLog) {
this.enableLog = enableLog;
}
public int getQueueLimit() {
return queueLimit;
}
public int getQueueLimit() {
return queueLimit;
}
public void setQueueLimit(int queueLimit) {
this.queueLimit = queueLimit;
}
public void setQueueLimit(int queueLimit) {
this.queueLimit = queueLimit;
}
public long getDelay() {
return delay;
}
public long getDelay() {
return delay;
}
public void setDelay(long delay) {
this.delay = delay;
}
public void setDelay(long delay) {
this.delay = delay;
}
public long getPeriod() {
return period;
}
public long getPeriod() {
return period;
}
public void setPeriod(long period) {
this.period = period;
}
public void setPeriod(long period) {
this.period = period;
}
}

View File

@@ -6,230 +6,232 @@ import java.util.Map;
/**
* 执行流程主要的参数类
*
* @author Bryan.Zhang
*/
@ConfigurationProperties(prefix = "liteflow", ignoreUnknownFields = true)
public class LiteflowProperty {
//是否装配liteflow
private boolean enable;
// 是否装配liteflow
private boolean enable;
//流程定义资源地址
private String ruleSource;
// 流程定义资源地址
private String ruleSource;
//流程资源扩展数据String格式
private String ruleSourceExtData;
// 流程资源扩展数据String格式
private String ruleSourceExtData;
//流程资源扩展数据Map格式
private Map<String, String> ruleSourceExtDataMap;
// 流程资源扩展数据Map格式
private Map<String, String> ruleSourceExtDataMap;
//slot的数量
private int slotSize;
// slot的数量
private int slotSize;
//FlowExecutor的execute2Future的线程数
private int mainExecutorWorks;
// FlowExecutor的execute2Future的线程数
private int mainExecutorWorks;
//FlowExecutor的execute2Future的自定义线程池
private String mainExecutorClass;
// FlowExecutor的execute2Future的自定义线程池
private String mainExecutorClass;
//并行线程执行器class路径
private String threadExecutorClass;
// 并行线程执行器class路径
private String threadExecutorClass;
//异步线程最大等待描述
private int whenMaxWaitSeconds;
// 异步线程最大等待描述
private int whenMaxWaitSeconds;
//异步线程池最大线程数
private int whenMaxWorkers;
// 异步线程池最大线程数
private int whenMaxWorkers;
//异步线程池最大队列数量
private int whenQueueLimit;
// 异步线程池最大队列数量
private int whenQueueLimit;
//是否在启动时解析规则文件
//这个参数主要给编码式注册元数据的场景用的结合FlowBus.addNode一起用
private boolean parseOnStart;
// 是否在启动时解析规则文件
// 这个参数主要给编码式注册元数据的场景用的结合FlowBus.addNode一起用
private boolean parseOnStart;
//这个属性为true则支持多种不同的类型的配置
//但是要注意,不能将主流程和子流程分配在不同类型配置文件中
private boolean supportMultipleType;
// 这个属性为true则支持多种不同的类型的配置
// 但是要注意,不能将主流程和子流程分配在不同类型配置文件中
private boolean supportMultipleType;
//重试次数
private int retryCount;
// 重试次数
private int retryCount;
//是否打印liteflow banner
private boolean printBanner;
// 是否打印liteflow banner
private boolean printBanner;
// 节点执行器class全名
private String nodeExecutorClass;
// 节点执行器class全名
private String nodeExecutorClass;
// requestId 生成器
private String requestIdGeneratorClass;
// requestId 生成器
private String requestIdGeneratorClass;
//是否打印执行过程中的日志
private boolean printExecutionLog;
// 是否打印执行过程中的日志
private boolean printExecutionLog;
//替补组件的class路径
private String substituteCmpClass;
// 替补组件的class路径
private String substituteCmpClass;
// 规则文件/脚本文件变更监听
private Boolean enableMonitorFile;
// 规则文件/脚本文件变更监听
private Boolean enableMonitorFile;
public Boolean getEnableMonitorFile() {
return enableMonitorFile;
}
public Boolean getEnableMonitorFile() {
return enableMonitorFile;
}
public void setEnableMonitorFile(Boolean enableMonitorFile) {
this.enableMonitorFile = enableMonitorFile;
}
public void setEnableMonitorFile(Boolean enableMonitorFile) {
this.enableMonitorFile = enableMonitorFile;
}
public boolean isEnable() {
return enable;
}
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
public String getRuleSource() {
return ruleSource;
}
public String getRuleSource() {
return ruleSource;
}
public void setRuleSource(String ruleSource) {
this.ruleSource = ruleSource;
}
public void setRuleSource(String ruleSource) {
this.ruleSource = ruleSource;
}
public int getSlotSize() {
return slotSize;
}
public int getSlotSize() {
return slotSize;
}
public void setSlotSize(int slotSize) {
this.slotSize = slotSize;
}
public void setSlotSize(int slotSize) {
this.slotSize = slotSize;
}
public int getWhenMaxWaitSeconds() {
return whenMaxWaitSeconds;
}
public int getWhenMaxWaitSeconds() {
return whenMaxWaitSeconds;
}
public void setWhenMaxWaitSeconds(int whenMaxWaitSeconds) {
this.whenMaxWaitSeconds = whenMaxWaitSeconds;
}
public void setWhenMaxWaitSeconds(int whenMaxWaitSeconds) {
this.whenMaxWaitSeconds = whenMaxWaitSeconds;
}
public int getWhenMaxWorkers() {
return whenMaxWorkers;
}
public int getWhenMaxWorkers() {
return whenMaxWorkers;
}
public void setWhenMaxWorkers(int whenMaxWorkers) {
this.whenMaxWorkers = whenMaxWorkers;
}
public void setWhenMaxWorkers(int whenMaxWorkers) {
this.whenMaxWorkers = whenMaxWorkers;
}
public int getWhenQueueLimit() {
return whenQueueLimit;
}
public int getWhenQueueLimit() {
return whenQueueLimit;
}
public void setWhenQueueLimit(int whenQueueLimit) {
this.whenQueueLimit = whenQueueLimit;
}
public void setWhenQueueLimit(int whenQueueLimit) {
this.whenQueueLimit = whenQueueLimit;
}
public boolean isParseOnStart() {
return parseOnStart;
}
public boolean isParseOnStart() {
return parseOnStart;
}
public void setParseOnStart(boolean parseOnStart) {
this.parseOnStart = parseOnStart;
}
public void setParseOnStart(boolean parseOnStart) {
this.parseOnStart = parseOnStart;
}
public boolean isSupportMultipleType() {
return supportMultipleType;
}
public boolean isSupportMultipleType() {
return supportMultipleType;
}
public void setSupportMultipleType(boolean supportMultipleType) {
this.supportMultipleType = supportMultipleType;
}
public void setSupportMultipleType(boolean supportMultipleType) {
this.supportMultipleType = supportMultipleType;
}
public int getRetryCount() {
return retryCount;
}
public int getRetryCount() {
return retryCount;
}
public void setRetryCount(int retryCount) {
this.retryCount = retryCount;
}
public void setRetryCount(int retryCount) {
this.retryCount = retryCount;
}
public boolean isPrintBanner() {
return printBanner;
}
public boolean isPrintBanner() {
return printBanner;
}
public void setPrintBanner(boolean printBanner) {
this.printBanner = printBanner;
}
public void setPrintBanner(boolean printBanner) {
this.printBanner = printBanner;
}
public String getThreadExecutorClass() {
return threadExecutorClass;
}
public String getThreadExecutorClass() {
return threadExecutorClass;
}
public void setThreadExecutorClass(String threadExecutorClass) {
this.threadExecutorClass = threadExecutorClass;
}
public void setThreadExecutorClass(String threadExecutorClass) {
this.threadExecutorClass = threadExecutorClass;
}
public String getNodeExecutorClass() {
return nodeExecutorClass;
}
public String getNodeExecutorClass() {
return nodeExecutorClass;
}
public void setNodeExecutorClass(String nodeExecutorClass) {
this.nodeExecutorClass = nodeExecutorClass;
}
public void setNodeExecutorClass(String nodeExecutorClass) {
this.nodeExecutorClass = nodeExecutorClass;
}
public int getMainExecutorWorks() {
return mainExecutorWorks;
}
public int getMainExecutorWorks() {
return mainExecutorWorks;
}
public void setMainExecutorWorks(int mainExecutorWorks) {
this.mainExecutorWorks = mainExecutorWorks;
}
public void setMainExecutorWorks(int mainExecutorWorks) {
this.mainExecutorWorks = mainExecutorWorks;
}
public String getMainExecutorClass() {
return mainExecutorClass;
}
public String getMainExecutorClass() {
return mainExecutorClass;
}
public void setMainExecutorClass(String mainExecutorClass) {
this.mainExecutorClass = mainExecutorClass;
}
public void setMainExecutorClass(String mainExecutorClass) {
this.mainExecutorClass = mainExecutorClass;
}
public boolean isPrintExecutionLog() {
return printExecutionLog;
}
public boolean isPrintExecutionLog() {
return printExecutionLog;
}
public void setPrintExecutionLog(boolean printExecutionLog) {
this.printExecutionLog = printExecutionLog;
}
public void setPrintExecutionLog(boolean printExecutionLog) {
this.printExecutionLog = printExecutionLog;
}
public String getRequestIdGeneratorClass() {
return requestIdGeneratorClass;
}
public String getRequestIdGeneratorClass() {
return requestIdGeneratorClass;
}
public void setRequestIdGeneratorClass(String requestIdGeneratorClass) {
this.requestIdGeneratorClass = requestIdGeneratorClass;
}
public void setRequestIdGeneratorClass(String requestIdGeneratorClass) {
this.requestIdGeneratorClass = requestIdGeneratorClass;
}
public String getSubstituteCmpClass() {
return substituteCmpClass;
}
public String getSubstituteCmpClass() {
return substituteCmpClass;
}
public void setSubstituteCmpClass(String substituteCmpClass) {
this.substituteCmpClass = substituteCmpClass;
}
public void setSubstituteCmpClass(String substituteCmpClass) {
this.substituteCmpClass = substituteCmpClass;
}
public String getRuleSourceExtData() {
return ruleSourceExtData;
}
public String getRuleSourceExtData() {
return ruleSourceExtData;
}
public void setRuleSourceExtData(String ruleSourceExtData) {
this.ruleSourceExtData = ruleSourceExtData;
}
public void setRuleSourceExtData(String ruleSourceExtData) {
this.ruleSourceExtData = ruleSourceExtData;
}
public Map<String, String> getRuleSourceExtDataMap() {
return ruleSourceExtDataMap;
}
public Map<String, String> getRuleSourceExtDataMap() {
return ruleSourceExtDataMap;
}
public void setRuleSourceExtDataMap(Map<String, String> ruleSourceExtDataMap) {
this.ruleSourceExtDataMap = ruleSourceExtDataMap;
}
public void setRuleSourceExtDataMap(Map<String, String> ruleSourceExtDataMap) {
this.ruleSourceExtDataMap = ruleSourceExtDataMap;
}
}

View File

@@ -15,47 +15,47 @@ import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Import;
/**
* 主要的业务装配器
* 在这个装配器里装配了执行器,执行器初始化类,监控器
* 主要的业务装配器 在这个装配器里装配了执行器,执行器初始化类,监控器
* 这个装配前置条件是需要LiteflowConfigLiteflowPropertyAutoConfiguration以及SpringAware
*
* @author Bryan.Zhang
*/
@Configuration
@AutoConfigureAfter({LiteflowPropertyAutoConfiguration.class})
@AutoConfigureAfter({ LiteflowPropertyAutoConfiguration.class })
@ConditionalOnBean(LiteflowConfig.class)
@ConditionalOnProperty(prefix = "liteflow", name = "enable", havingValue = "true")
@Import(SpringAware.class)
public class LiteflowMainAutoConfiguration {
//实例化ComponentScanner
//多加一个SpringAware的意义是确保在执行这个的时候SpringAware这个bean已经被初始化
@Bean
public ComponentScanner componentScanner(LiteflowConfig liteflowConfig, SpringAware springAware){
return new ComponentScanner(liteflowConfig);
}
// 实例化ComponentScanner
// 多加一个SpringAware的意义是确保在执行这个的时候SpringAware这个bean已经被初始化
@Bean
public ComponentScanner componentScanner(LiteflowConfig liteflowConfig, SpringAware springAware) {
return new ComponentScanner(liteflowConfig);
}
//实例化FlowExecutor
//多加一个SpringAware的意义是确保在执行这个的时候SpringAware这个bean已经被初始化
@Bean
public FlowExecutor flowExecutor(LiteflowConfig liteflowConfig, SpringAware springAware) {
FlowExecutor flowExecutor = new FlowExecutor();
flowExecutor.setLiteflowConfig(liteflowConfig);
return flowExecutor;
}
// 实例化FlowExecutor
// 多加一个SpringAware的意义是确保在执行这个的时候SpringAware这个bean已经被初始化
@Bean
public FlowExecutor flowExecutor(LiteflowConfig liteflowConfig, SpringAware springAware) {
FlowExecutor flowExecutor = new FlowExecutor();
flowExecutor.setLiteflowConfig(liteflowConfig);
return flowExecutor;
}
//FlowExecutor的初始化工作和实例化分开来
@Bean
@ConditionalOnProperty(prefix = "liteflow", name = "parse-on-start", havingValue = "true")
public LiteflowExecutorInit liteflowExecutorInit(FlowExecutor flowExecutor) {
return new LiteflowExecutorInit(flowExecutor);
}
// FlowExecutor的初始化工作和实例化分开来
@Bean
@ConditionalOnProperty(prefix = "liteflow", name = "parse-on-start", havingValue = "true")
public LiteflowExecutorInit liteflowExecutorInit(FlowExecutor flowExecutor) {
return new LiteflowExecutorInit(flowExecutor);
}
// 实例化MonitorBus
// 多加一个SpringAware的意义是确保在执行这个的时候SpringAware这个bean已经被初始化
@Bean("monitorBus")
@ConditionalOnProperty(prefix = "liteflow", name = "monitor.enable-log", havingValue = "true")
public MonitorBus monitorBus(LiteflowConfig liteflowConfig, SpringAware springAware) {
return new MonitorBus(liteflowConfig);
}
//实例化MonitorBus
//多加一个SpringAware的意义是确保在执行这个的时候SpringAware这个bean已经被初始化
@Bean("monitorBus")
@ConditionalOnProperty(prefix = "liteflow", name = "monitor.enable-log", havingValue = "true")
public MonitorBus monitorBus(LiteflowConfig liteflowConfig, SpringAware springAware) {
return new MonitorBus(liteflowConfig);
}
}

View File

@@ -9,45 +9,44 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
/**
* LiteflowConfig的装配类
* 这个装配类主要是把监控器的配置参数类和流程配置参数类作一个合并,转换成统一的配置参数类。
* LiteflowConfig的装配类 这个装配类主要是把监控器的配置参数类和流程配置参数类作一个合并,转换成统一的配置参数类。
* 同时这里设置了默认的参数路径如果在springboot的application.properties/yml里没取到的话就取默认值
*
* @author Bryan.Zhang
*/
@Configuration
@EnableConfigurationProperties({LiteflowProperty.class, LiteflowMonitorProperty.class})
@PropertySource(
name = "Liteflow Default Properties",
value = "classpath:/META-INF/liteflow-default.properties")
@EnableConfigurationProperties({ LiteflowProperty.class, LiteflowMonitorProperty.class })
@PropertySource(name = "Liteflow Default Properties", value = "classpath:/META-INF/liteflow-default.properties")
public class LiteflowPropertyAutoConfiguration {
@Bean
public LiteflowConfig liteflowConfig(LiteflowProperty property, LiteflowMonitorProperty liteflowMonitorProperty){
LiteflowConfig liteflowConfig = new LiteflowConfig();
liteflowConfig.setRuleSource(property.getRuleSource());
liteflowConfig.setRuleSourceExtData(property.getRuleSourceExtData());
liteflowConfig.setRuleSourceExtDataMap(property.getRuleSourceExtDataMap());
liteflowConfig.setSlotSize(property.getSlotSize());
liteflowConfig.setThreadExecutorClass(property.getThreadExecutorClass());
liteflowConfig.setWhenMaxWaitSeconds(property.getWhenMaxWaitSeconds());
liteflowConfig.setEnableLog(liteflowMonitorProperty.isEnableLog());
liteflowConfig.setQueueLimit(liteflowMonitorProperty.getQueueLimit());
liteflowConfig.setDelay(liteflowMonitorProperty.getDelay());
liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod());
liteflowConfig.setWhenMaxWorkers(property.getWhenMaxWorkers());
liteflowConfig.setWhenQueueLimit(property.getWhenQueueLimit());
liteflowConfig.setParseOnStart(property.isParseOnStart());
liteflowConfig.setEnable(property.isEnable());
liteflowConfig.setSupportMultipleType(property.isSupportMultipleType());
liteflowConfig.setRetryCount(property.getRetryCount());
liteflowConfig.setPrintBanner(property.isPrintBanner());
liteflowConfig.setNodeExecutorClass(property.getNodeExecutorClass());
liteflowConfig.setRequestIdGeneratorClass(property.getRequestIdGeneratorClass());
liteflowConfig.setMainExecutorWorks(property.getMainExecutorWorks());
liteflowConfig.setMainExecutorClass(property.getMainExecutorClass());
liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog());
liteflowConfig.setSubstituteCmpClass(property.getSubstituteCmpClass());
liteflowConfig.setEnableMonitorFile(property.getEnableMonitorFile());
return liteflowConfig;
}
@Bean
public LiteflowConfig liteflowConfig(LiteflowProperty property, LiteflowMonitorProperty liteflowMonitorProperty) {
LiteflowConfig liteflowConfig = new LiteflowConfig();
liteflowConfig.setRuleSource(property.getRuleSource());
liteflowConfig.setRuleSourceExtData(property.getRuleSourceExtData());
liteflowConfig.setRuleSourceExtDataMap(property.getRuleSourceExtDataMap());
liteflowConfig.setSlotSize(property.getSlotSize());
liteflowConfig.setThreadExecutorClass(property.getThreadExecutorClass());
liteflowConfig.setWhenMaxWaitSeconds(property.getWhenMaxWaitSeconds());
liteflowConfig.setEnableLog(liteflowMonitorProperty.isEnableLog());
liteflowConfig.setQueueLimit(liteflowMonitorProperty.getQueueLimit());
liteflowConfig.setDelay(liteflowMonitorProperty.getDelay());
liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod());
liteflowConfig.setWhenMaxWorkers(property.getWhenMaxWorkers());
liteflowConfig.setWhenQueueLimit(property.getWhenQueueLimit());
liteflowConfig.setParseOnStart(property.isParseOnStart());
liteflowConfig.setEnable(property.isEnable());
liteflowConfig.setSupportMultipleType(property.isSupportMultipleType());
liteflowConfig.setRetryCount(property.getRetryCount());
liteflowConfig.setPrintBanner(property.isPrintBanner());
liteflowConfig.setNodeExecutorClass(property.getNodeExecutorClass());
liteflowConfig.setRequestIdGeneratorClass(property.getRequestIdGeneratorClass());
liteflowConfig.setMainExecutorWorks(property.getMainExecutorWorks());
liteflowConfig.setMainExecutorClass(property.getMainExecutorClass());
liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog());
liteflowConfig.setSubstituteCmpClass(property.getSubstituteCmpClass());
liteflowConfig.setEnableMonitorFile(property.getEnableMonitorFile());
return liteflowConfig;
}
}