mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-15 04:22:09 +08:00
改变基础配置的方式
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.yomahub.liteflow.springboot;
|
||||
|
||||
import com.yomahub.liteflow.spring.ComponentScaner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class LiteflowComponentScanerAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public ComponentScaner componentScaner(){
|
||||
return new ComponentScaner();
|
||||
}
|
||||
}
|
||||
@@ -9,40 +9,26 @@ import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.spring.ComponentScaner;
|
||||
import com.yomahub.liteflow.util.SpringAware;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({LiteflowProperty.class,LiteflowMonitorProperty.class})
|
||||
@ConditionalOnProperty(prefix = "liteflow", name = "rule-source")
|
||||
@ConditionalOnBean(LiteflowConfig.class)
|
||||
@AutoConfigureAfter(LiteflowPropertyAutoConfiguration.class)
|
||||
@Import(SpringAware.class)
|
||||
@PropertySource(
|
||||
name = "liteflow Default Properties",
|
||||
name = "Liteflow Default Properties",
|
||||
value = "classpath:/META-INF/liteflow-default.properties")
|
||||
public class LiteflowAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
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();
|
||||
}
|
||||
public class LiteflowMainAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public FlowExecutor flowExecutor(LiteflowConfig liteflowConfig){
|
||||
@@ -56,12 +42,7 @@ public class LiteflowAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringAware springAware(){
|
||||
return new SpringAware();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LiteflowExecutorInit liteflowExecutorInit(FlowExecutor flowExecutor, SpringAware springAware){
|
||||
public LiteflowExecutorInit liteflowExecutorInit(FlowExecutor flowExecutor){
|
||||
return new LiteflowExecutorInit(flowExecutor);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yomahub.liteflow.springboot;
|
||||
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({LiteflowProperty.class,LiteflowMonitorProperty.class})
|
||||
@ConditionalOnProperty(prefix = "liteflow", name = "rule-source")
|
||||
@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.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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user