From 311fe14868054d3b7fea2102e2aef0da457e3a2e Mon Sep 17 00:00:00 2001 From: "bryan.zhang" Date: Fri, 22 Mar 2019 18:57:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8springboot=E7=8E=AF=E5=A2=83=E4=B8=8B?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=97=B6=E5=8A=A0=E8=BD=BD=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=20=E7=9B=91=E6=8E=A7=E9=98=9F=E5=88=97=E7=9A=84=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E5=AE=89=E5=85=A8=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/spring/ComponentScaner.java | 8 ++++---- .../thebeastshop/liteflow/util/LimitQueue.java | 7 ++++--- .../springboot/LiteflowAutoConfiguration.java | 7 ------- .../liteflow/springboot/LiteflowExecutorInit.java | 15 +++++++++++++++ .../src/main/resources/META-INF/spring.factories | 5 ++++- 5 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 liteflow-spring-boot-starter/src/main/java/com/thebeastshop/liteflow/springboot/LiteflowExecutorInit.java diff --git a/liteflow-core/src/main/java/com/thebeastshop/liteflow/spring/ComponentScaner.java b/liteflow-core/src/main/java/com/thebeastshop/liteflow/spring/ComponentScaner.java index 60c3993f1..6cf4e6944 100644 --- a/liteflow-core/src/main/java/com/thebeastshop/liteflow/spring/ComponentScaner.java +++ b/liteflow-core/src/main/java/com/thebeastshop/liteflow/spring/ComponentScaner.java @@ -22,15 +22,15 @@ import com.thebeastshop.liteflow.entity.config.Node; import com.thebeastshop.liteflow.util.LOGOPrinter; public class ComponentScaner implements BeanPostProcessor, PriorityOrdered { - + private static final Logger LOG = LoggerFactory.getLogger(ComponentScaner.class); - + public static Map nodeComponentMap = new HashMap(); static { LOGOPrinter.print(); } - + @Override public int getOrder() { return Ordered.LOWEST_PRECEDENCE; @@ -48,7 +48,7 @@ public class ComponentScaner implements BeanPostProcessor, PriorityOrdered { } return bean; } - + @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { return bean; diff --git a/liteflow-core/src/main/java/com/thebeastshop/liteflow/util/LimitQueue.java b/liteflow-core/src/main/java/com/thebeastshop/liteflow/util/LimitQueue.java index 5122898a9..3bea33f8f 100644 --- a/liteflow-core/src/main/java/com/thebeastshop/liteflow/util/LimitQueue.java +++ b/liteflow-core/src/main/java/com/thebeastshop/liteflow/util/LimitQueue.java @@ -13,6 +13,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; public class LimitQueue implements Queue { @@ -21,7 +22,7 @@ public class LimitQueue implements Queue { */ private int limit; - Queue queue = new LinkedList(); + Queue queue = new ConcurrentLinkedQueue<>(); public LimitQueue(int limit) { this.limit = limit; @@ -49,7 +50,7 @@ public class LimitQueue implements Queue { /** * 获取队列 - * + * * @return * @author SHANHY * @date 2015年11月9日 @@ -60,7 +61,7 @@ public class LimitQueue implements Queue { /** * 获取限制大小 - * + * * @return * @author SHANHY * @date 2015年11月9日 diff --git a/liteflow-spring-boot-starter/src/main/java/com/thebeastshop/liteflow/springboot/LiteflowAutoConfiguration.java b/liteflow-spring-boot-starter/src/main/java/com/thebeastshop/liteflow/springboot/LiteflowAutoConfiguration.java index 160fd922a..7fccef113 100644 --- a/liteflow-spring-boot-starter/src/main/java/com/thebeastshop/liteflow/springboot/LiteflowAutoConfiguration.java +++ b/liteflow-spring-boot-starter/src/main/java/com/thebeastshop/liteflow/springboot/LiteflowAutoConfiguration.java @@ -4,16 +4,9 @@ import com.google.common.collect.Lists; import com.thebeastshop.liteflow.core.FlowExecutor; import com.thebeastshop.liteflow.spring.ComponentScaner; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; import java.util.List; diff --git a/liteflow-spring-boot-starter/src/main/java/com/thebeastshop/liteflow/springboot/LiteflowExecutorInit.java b/liteflow-spring-boot-starter/src/main/java/com/thebeastshop/liteflow/springboot/LiteflowExecutorInit.java new file mode 100644 index 000000000..34bae469b --- /dev/null +++ b/liteflow-spring-boot-starter/src/main/java/com/thebeastshop/liteflow/springboot/LiteflowExecutorInit.java @@ -0,0 +1,15 @@ +package com.thebeastshop.liteflow.springboot; + +import com.thebeastshop.liteflow.core.FlowExecutor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class LiteflowExecutorInit { + + @Bean + public String initExecutor(FlowExecutor flowExecutor){ + flowExecutor.init(); + return "init"; + } +} diff --git a/liteflow-spring-boot-starter/src/main/resources/META-INF/spring.factories b/liteflow-spring-boot-starter/src/main/resources/META-INF/spring.factories index 5f08005da..06a512b98 100644 --- a/liteflow-spring-boot-starter/src/main/resources/META-INF/spring.factories +++ b/liteflow-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -1,3 +1,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.thebeastshop.liteflow.springboot.LiteflowProperty,\ - com.thebeastshop.liteflow.springboot.LiteflowAutoConfiguration + com.thebeastshop.liteflow.springboot.LiteflowAutoConfiguration,\ + com.thebeastshop.liteflow.springboot.LiteflowExecutorInit + +