pathList) throws IOException {
Assert.notEmpty(pathList, "rule source must not be null");
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java b/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java
index 2c6bec48..7a4d2078 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java
@@ -265,7 +265,11 @@ public class LiteflowConfig {
}
public String getNodeExecutorClass() {
- return nodeExecutorClass;
+ if (StrUtil.isBlank(nodeExecutorClass)){
+ return "com.yomahub.liteflow.entity.executor.DefaultNodeExecutor";
+ }else{
+ return nodeExecutorClass;
+ }
}
public void setNodeExecutorClass(String nodeExecutorClass) {
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorBuilder.java b/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorBuilder.java
index 3a8e80e4..6349f7b0 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorBuilder.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorBuilder.java
@@ -15,18 +15,7 @@ public interface ExecutorBuilder {
ExecutorService buildExecutor();
- /**
- *
- * 构建默认的线程池对象
- *
- * @author sikadai
- * @date 2022/1/21 23:07
- * @param corePoolSize : 核心线程池数量
- * @param maximumPoolSize : 最大线程池数量
- * @param queueCapacity : 队列的容量
- * @param threadName : 线程吃名称
- * @return java.util.concurrent.ExecutorService
- */
+ //构建默认的线程池对象
default ExecutorService buildDefaultExecutor(int corePoolSize, int maximumPoolSize, int queueCapacity, String threadName) {
return TtlExecutors.getTtlExecutorService(new ThreadPoolExecutor(corePoolSize,
maximumPoolSize,
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java b/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java
index 8aeafb94..2bfca78c 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java
@@ -53,7 +53,7 @@ public class ExecutorHelper {
}
/**
- * 使用默认的等待时间1分钟,来关闭目标线程组。
+ *
*
*
* @param pool 需要关闭的线程组.
@@ -63,6 +63,7 @@ public class ExecutorHelper {
}
/**
+ *
* 关闭ExecutorService的线程管理者
*
*
@@ -85,9 +86,7 @@ public class ExecutorHelper {
}
}
- /**
- * 构建全局默认线程池
- */
+ //构建全局默认线程池
public ExecutorService buildExecutor() {
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
if (!executorServiceMap.containsKey(liteflowConfig.getThreadExecutorClass())) {
@@ -97,16 +96,7 @@ public class ExecutorHelper {
return executorServiceMap.get(liteflowConfig.getThreadExecutorClass());
}
- /**
- *
- * 构建线程池执行器 - 支持多个when公用一个线程池
- *
- *
- * @param threadExecutorClass : 线程池构建者的Class全类名
- * @return java.util.concurrent.ExecutorService
- * @author sikadai
- * @date 2022/1/21 23:00
- */
+ //构建线程池执行器 - 支持多个when公用一个线程池
public ExecutorService buildExecutor(String threadExecutorClass) {
if (StrUtil.isBlank(threadExecutorClass)) {
return buildExecutor();
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/util/SpringAware.java b/liteflow-core/src/main/java/com/yomahub/liteflow/util/SpringAware.java
index 911df22c..0131a96b 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/util/SpringAware.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/util/SpringAware.java
@@ -1,6 +1,7 @@
package com.yomahub.liteflow.util;
import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.ReflectUtil;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -47,11 +48,15 @@ public class SpringAware implements ApplicationContextAware {
}
public static T registerBean(String beanName, Class c) {
- DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory)applicationContext.getAutowireCapableBeanFactory();
- BeanDefinition beanDefinition = new GenericBeanDefinition();
- beanDefinition.setBeanClassName(c.getName());
- beanFactory.registerBeanDefinition(beanName, beanDefinition);
- return getBean(beanName);
+ try{
+ DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory)applicationContext.getAutowireCapableBeanFactory();
+ BeanDefinition beanDefinition = new GenericBeanDefinition();
+ beanDefinition.setBeanClassName(c.getName());
+ beanFactory.registerBeanDefinition(beanName, beanDefinition);
+ return getBean(beanName);
+ }catch (Exception e){
+ return ReflectUtil.newInstance(c);
+ }
}
public static T registerBean(Class c) {
diff --git a/liteflow-script-common/pom.xml b/liteflow-script-common/pom.xml
index 545a26e8..d5fb52f7 100644
--- a/liteflow-script-common/pom.xml
+++ b/liteflow-script-common/pom.xml
@@ -5,7 +5,7 @@
liteflow
com.yomahub
- 2.6.9
+ 2.6.11
4.0.0
diff --git a/liteflow-script-groovy/pom.xml b/liteflow-script-groovy/pom.xml
index cb4e2ba3..7597a4f8 100644
--- a/liteflow-script-groovy/pom.xml
+++ b/liteflow-script-groovy/pom.xml
@@ -5,7 +5,7 @@
liteflow
com.yomahub
- 2.6.9
+ 2.6.11
4.0.0
diff --git a/liteflow-script-qlexpress/pom.xml b/liteflow-script-qlexpress/pom.xml
index 5c4f57df..a479b13c 100644
--- a/liteflow-script-qlexpress/pom.xml
+++ b/liteflow-script-qlexpress/pom.xml
@@ -5,7 +5,7 @@
liteflow
com.yomahub
- 2.6.9
+ 2.6.11
4.0.0
diff --git a/liteflow-spring-boot-starter/pom.xml b/liteflow-spring-boot-starter/pom.xml
index 0c4b6754..05057494 100644
--- a/liteflow-spring-boot-starter/pom.xml
+++ b/liteflow-spring-boot-starter/pom.xml
@@ -10,7 +10,7 @@
liteflow
com.yomahub
- 2.6.9
+ 2.6.11
diff --git a/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
index b5b9a788..b9ef68db 100644
--- a/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
+++ b/liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
@@ -78,6 +78,13 @@
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
"defaultValue": 0
},
+ {
+ "name": "liteflow.node-executor-class",
+ "type": "java.lang.String",
+ "description": "Executor class of node.",
+ "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
+ "defaultValue": 0
+ },
{
"name": "liteflow.monitor.enable-log",
"type": "java.lang.Boolean",
diff --git a/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties b/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties
index 3140e99e..01228a83 100644
--- a/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties
+++ b/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties
@@ -9,8 +9,8 @@ liteflow.when-queue-limit=512
liteflow.parse-on-start=true
liteflow.retry-count=0
liteflow.support-multiple-type=false
+liteflow.node-executor-class=com.yomahub.liteflow.entity.executor.DefaultNodeExecutor
liteflow.monitor.enable-log=false
liteflow.monitor.queue-limit=200
liteflow.monitor.delay=300000
liteflow.monitor.period=300000
-liteflow.node-executor-class=com.yomahub.liteflow.entity.executor.DefaultNodeExecutor
\ No newline at end of file
diff --git a/liteflow-testcase-script-groovy/pom.xml b/liteflow-testcase-script-groovy/pom.xml
index c5417c48..14952743 100644
--- a/liteflow-testcase-script-groovy/pom.xml
+++ b/liteflow-testcase-script-groovy/pom.xml
@@ -5,7 +5,7 @@
liteflow
com.yomahub
- 2.6.9
+ 2.6.11
4.0.0
diff --git a/liteflow-testcase-script-qlexpress/pom.xml b/liteflow-testcase-script-qlexpress/pom.xml
index f4937ec9..f9f15c65 100644
--- a/liteflow-testcase-script-qlexpress/pom.xml
+++ b/liteflow-testcase-script-qlexpress/pom.xml
@@ -5,7 +5,7 @@
liteflow
com.yomahub
- 2.6.9
+ 2.6.11
4.0.0
diff --git a/liteflow-testcase-springboot/pom.xml b/liteflow-testcase-springboot/pom.xml
index 1096433c..dc0c6b50 100644
--- a/liteflow-testcase-springboot/pom.xml
+++ b/liteflow-testcase-springboot/pom.xml
@@ -5,7 +5,7 @@
liteflow
com.yomahub
- 2.6.9
+ 2.6.11
4.0.0
diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java
new file mode 100644
index 00000000..a1e472e6
--- /dev/null
+++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/LazySpringbootTest.java
@@ -0,0 +1,36 @@
+package com.yomahub.liteflow.test.lazy;
+
+import cn.hutool.core.codec.Base64;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.ZipUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.entity.data.DefaultSlot;
+import com.yomahub.liteflow.entity.data.LiteflowResponse;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+
+@RunWith(SpringRunner.class)
+@TestPropertySource(value = "classpath:/lazy/application.properties")
+@SpringBootTest(classes = LazySpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.lazy.cmp"})
+public class LazySpringbootTest extends BaseTest {
+
+ @Resource
+ private FlowExecutor flowExecutor;
+
+ @Test
+ public void testLazy() throws Exception{
+ LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
+ Assert.assertTrue(response.isSuccess());
+ }
+}
diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/cmp/ACmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/cmp/ACmp.java
new file mode 100644
index 00000000..9d3dacbc
--- /dev/null
+++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/cmp/ACmp.java
@@ -0,0 +1,22 @@
+/**
+ * Title: liteflow
+ * Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.lazy.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Component;
+
+@Lazy
+@Component("a")
+public class ACmp extends NodeComponent {
+
+ @Override
+ public void process() {
+ System.out.println("ACmp executed!");
+ }
+}
diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/cmp/BCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/cmp/BCmp.java
new file mode 100644
index 00000000..13bfe672
--- /dev/null
+++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/cmp/BCmp.java
@@ -0,0 +1,21 @@
+/**
+ * Title: liteflow
+ * Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.lazy.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.stereotype.Component;
+
+@Component("b")
+public class BCmp extends NodeComponent {
+
+ @Override
+ public void process() {
+ System.out.println("BCmp executed!");
+ }
+
+}
diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/cmp/CCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/cmp/CCmp.java
new file mode 100644
index 00000000..3f45e86a
--- /dev/null
+++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/lazy/cmp/CCmp.java
@@ -0,0 +1,21 @@
+/**
+ * Title: liteflow
+ * Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.lazy.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.stereotype.Component;
+
+@Component("c")
+public class CCmp extends NodeComponent {
+
+ @Override
+ public void process() {
+ System.out.println("CCmp executed!");
+ }
+
+}
diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java
new file mode 100644
index 00000000..84b60247
--- /dev/null
+++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/CustomerDefaultNodeExecutor.java
@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.nodeExecutor;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.entity.data.DataBus;
+import com.yomahub.liteflow.entity.data.Slot;
+import com.yomahub.liteflow.entity.executor.NodeExecutor;
+
+/**
+ * 自定义默认的节点执行器
+ */
+public class CustomerDefaultNodeExecutor extends NodeExecutor {
+ @Override
+ public void execute(NodeComponent instance) throws Exception {
+ Slot slot = DataBus.getSlot(instance.getSlotIndex());
+ LOG.info("使用customerDefaultNodeExecutor进行执行");
+ slot.setData("customerDefaultNodeExecutor", this.getClass());
+ super.execute(instance);
+ }
+}
diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java
index b83bcb51..03940dea 100644
--- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java
+++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/LiteflowNodeExecutorSpringbootTest.java
@@ -35,10 +35,10 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest {
// 默认执行器测试
@Test
- public void testDefaultExecutor() {
+ public void testCustomerDefaultNodeExecutor() {
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
- Assert.assertEquals(DefaultNodeExecutor.class, response.getSlot().getData("defaultNodeExecutor"));
+ Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor"));
Assert.assertEquals("a", response.getSlot().getExecuteStepStr());
}
@@ -47,7 +47,7 @@ public class LiteflowNodeExecutorSpringbootTest extends BaseTest {
public void testDefaultExecutorForRetry() {
LiteflowResponse response = flowExecutor.execute2Resp("chain2", "arg");
Assert.assertTrue(response.isSuccess());
- Assert.assertEquals(DefaultNodeExecutor.class, response.getSlot().getData("defaultNodeExecutor"));
+ Assert.assertEquals(CustomerDefaultNodeExecutor.class, response.getSlot().getData("customerDefaultNodeExecutor"));
Assert.assertEquals("b==>b==>b", response.getSlot().getExecuteStepStr());
}
diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/CCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/CCmp.java
index 6762d18a..f7ad8f77 100644
--- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/CCmp.java
+++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/CCmp.java
@@ -10,6 +10,7 @@ package com.yomahub.liteflow.test.nodeExecutor.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowRetry;
import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.entity.executor.NodeExecutor;
import com.yomahub.liteflow.test.nodeExecutor.CustomerNodeExecutor;
@LiteflowComponent("c")
@@ -22,7 +23,7 @@ public class CCmp extends NodeComponent {
}
@Override
- public String getNodeExecutorClass() {
- return CustomerNodeExecutor.class.getName();
+ public Class extends NodeExecutor> getNodeExecutorClass() {
+ return CustomerNodeExecutor.class;
}
}
diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/DCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/DCmp.java
index d60135a0..b80d2e0a 100644
--- a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/DCmp.java
+++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/nodeExecutor/cmp/DCmp.java
@@ -1,6 +1,7 @@
/**
* Title: liteflow
* Description: 轻量级的组件式流程框架
+ *
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
@@ -10,21 +11,21 @@ package com.yomahub.liteflow.test.nodeExecutor.cmp;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowRetry;
import com.yomahub.liteflow.core.NodeComponent;
-import com.yomahub.liteflow.test.nodeExecutor.CustomerNodeExecutor;
+import com.yomahub.liteflow.entity.executor.NodeExecutor;
import com.yomahub.liteflow.test.nodeExecutor.CustomerNodeExecutorAndCustomRetry;
@LiteflowComponent("d")
@LiteflowRetry(retry = 5, forExceptions = {NullPointerException.class})
public class DCmp extends NodeComponent {
- @Override
- public void process() {
- System.out.println("DCmp executed!");
- throw new NullPointerException("demo exception");
- }
+ @Override
+ public void process() {
+ System.out.println("DCmp executed!");
+ throw new NullPointerException("demo exception");
+ }
- @Override
- public String getNodeExecutorClass() {
- return CustomerNodeExecutorAndCustomRetry.class.getName();
- }
+ @Override
+ public Class extends NodeExecutor> getNodeExecutorClass() {
+ return CustomerNodeExecutorAndCustomRetry.class;
+ }
}
diff --git a/liteflow-testcase-springboot/src/test/resources/lazy/application.properties b/liteflow-testcase-springboot/src/test/resources/lazy/application.properties
new file mode 100644
index 00000000..372a320c
--- /dev/null
+++ b/liteflow-testcase-springboot/src/test/resources/lazy/application.properties
@@ -0,0 +1 @@
+liteflow.rule-source=lazy/flow.xml
\ No newline at end of file
diff --git a/liteflow-testcase-springboot/src/test/resources/lazy/flow.xml b/liteflow-testcase-springboot/src/test/resources/lazy/flow.xml
new file mode 100644
index 00000000..22870d94
--- /dev/null
+++ b/liteflow-testcase-springboot/src/test/resources/lazy/flow.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/liteflow-testcase-springboot/src/test/resources/nodeExecutor/application.properties b/liteflow-testcase-springboot/src/test/resources/nodeExecutor/application.properties
index 62a0d3a9..b2ca1d08 100644
--- a/liteflow-testcase-springboot/src/test/resources/nodeExecutor/application.properties
+++ b/liteflow-testcase-springboot/src/test/resources/nodeExecutor/application.properties
@@ -1,4 +1,4 @@
liteflow.rule-source=nodeExecutor/flow.xml
liteflow.retry-count=3
liteflow.slot-size=512
-liteflow.node-executor-class=com.yomahub.liteflow.entity.executor.DefaultNodeExecutor
\ No newline at end of file
+liteflow.node-executor-class=com.yomahub.liteflow.test.nodeExecutor.CustomerDefaultNodeExecutor
\ No newline at end of file
diff --git a/liteflow-testcase-springnative/pom.xml b/liteflow-testcase-springnative/pom.xml
index c82bcd0c..e48b9e42 100644
--- a/liteflow-testcase-springnative/pom.xml
+++ b/liteflow-testcase-springnative/pom.xml
@@ -5,7 +5,7 @@
liteflow
com.yomahub
- 2.6.9
+ 2.6.11
4.0.0
diff --git a/pom.xml b/pom.xml
index 5c167f16..0bbe10c1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.yomahub
liteflow
pom
- 2.6.9
+ 2.6.11
liteflow
a lightweight and practical micro-process framework
https://github.com/bryan31/liteflow