diff --git a/liteflow-core/pom.xml b/liteflow-core/pom.xml
index 042518470..745417a84 100644
--- a/liteflow-core/pom.xml
+++ b/liteflow-core/pom.xml
@@ -9,7 +9,7 @@
com.yomahub
liteflow
- 2.5.4
+ 2.5.5
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java
index fd9042ad3..3ced81919 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java
@@ -44,9 +44,9 @@ public class FlowExecutor {
private static final String ZK_CONFIG_REGEX = "[\\w\\d][\\w\\d\\.]+\\:(\\d)+(\\,[\\w\\d][\\w\\d\\.]+\\:(\\d)+)*";
- private static final String LOCAL_XML_CONFIG_REGEX = "^[\\w_\\-\\@\\/]+\\.xml$";
- private static final String LOCAL_JSON_CONFIG_REGEX = "^[\\w_\\-\\@\\/]+\\.json$";
- private static final String LOCAL_YML_CONFIG_REGEX = "^[\\w_\\-\\@\\/]+\\.yml$";
+ private static final String LOCAL_XML_CONFIG_REGEX = "^[\\w_\\-\\@\\/\\*]+\\.xml$";
+ private static final String LOCAL_JSON_CONFIG_REGEX = "^[\\w_\\-\\@\\/\\*]+\\.json$";
+ private static final String LOCAL_YML_CONFIG_REGEX = "^[\\w_\\-\\@\\/\\*]+\\.yml$";
private static final String FORMATE_XML_CONFIG_REGEX = "xml:.+";
private static final String FORMATE_JSON_CONFIG_REGEX = "json:.+";
@@ -85,7 +85,7 @@ public class FlowExecutor {
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_YML);
break;
default:
- LOG.error("can't surport the format {}", path);
+ LOG.error("can't support the format {}", path);
}
}
if(ObjectUtil.isNotNull(parser)) {
@@ -94,7 +94,7 @@ public class FlowExecutor {
throw new ConfigErrorException("parse error, please check liteflow config property");
}
} catch (Exception e) {
- String errorMsg = MessageFormat.format("init flow executor cause error,cannot parse rule file {0}", path);
+ String errorMsg = MessageFormat.format("init flow executor cause error,can not parse rule file {0}", path);
LOG.error(errorMsg, e);
throw new FlowExecutorNotInitException(errorMsg);
}
@@ -110,6 +110,7 @@ public class FlowExecutor {
private FlowParser matchFormatParser(String path, FlowParserTypeEnum pattern) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
boolean isLocalFile = isLocalConfig(path);
if(isLocalFile) {
+ LOG.info("flow info loaded from local file,path={},format type={}", path, pattern.getType());
switch (pattern) {
case TYPE_XML:
return new LocalXmlFlowParser();
@@ -120,6 +121,7 @@ public class FlowExecutor {
default:
}
} else if(isClassConfig(path)){
+ LOG.info("flow info loaded from class config,class={},format type={}", path, pattern.getType());
Class c = Class.forName(path);
switch (pattern) {
case TYPE_XML:
@@ -131,6 +133,7 @@ public class FlowExecutor {
default:
}
} else if(isZKConfig(path)) {
+ LOG.info("flow info loaded from Zookeeper,zkNode={},format type={}", path, pattern.getType());
switch (pattern) {
case TYPE_XML:
return StrUtil.isNotBlank(zkNode) ? new ZookeeperXmlFlowParser(zkNode) : new ZookeeperXmlFlowParser();
@@ -141,6 +144,7 @@ public class FlowExecutor {
default:
}
}
+ LOG.info("load flow info error, path={}, pattern={}", path, pattern.getType());
return null;
}
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java
index bbe88e339..0153b019d 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/FlowBus.java
@@ -7,11 +7,7 @@
*/
package com.yomahub.liteflow.flow;
-import java.util.HashMap;
-import java.util.Map;
-
import cn.hutool.core.map.MapUtil;
-
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.yomahub.liteflow.core.NodeComponent;
@@ -22,6 +18,9 @@ import com.yomahub.liteflow.util.SpringAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* 流程元数据类
* @author Bryan.Zhang
@@ -61,19 +60,19 @@ public class FlowBus {
}
public static void addNode(String nodeId, Node node) {
+ if (containNode(nodeId)) return;
nodeMap.put(nodeId, node);
}
public static void addNode(String nodeId, String cmpClazzStr) throws Exception{
+ if (containNode(nodeId)) return;
Class cmpClazz = (Class)Class.forName(cmpClazzStr);
addNode(nodeId, cmpClazz);
}
public static void addNode(String nodeId, Class extends NodeComponent> cmpClazz){
+ if (containNode(nodeId)) return;
try{
- Node node = new Node();
- node.setId(nodeId);
- node.setClazz(cmpClazz.getName());
//以node方式配置,本质上是为了适配无spring的环境,如果有spring环境,其实不用这么配置
//这里的逻辑是判断是否能从spring上下文中取到,如果没有spring,则就是new instance了
NodeComponent cmpInstance = SpringAware.registerOrGet(cmpClazz);
@@ -83,8 +82,7 @@ public class FlowBus {
}
cmpInstance.setNodeId(nodeId);
cmpInstance.setSelf(cmpInstance);
- node.setInstance(cmpInstance);
- nodeMap.put(nodeId,node);
+ nodeMap.put(nodeId, new Node(nodeId, cmpClazz.getName(), cmpInstance));
}catch (Exception e){
String error = StrUtil.format("component[{}] register error", cmpClazz.getName());
LOG.error(error, e);
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/FlowParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/FlowParser.java
index 9f6705c7a..7d89d3443 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/FlowParser.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/FlowParser.java
@@ -1,11 +1,18 @@
package com.yomahub.liteflow.parser;
import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ArrayUtil;
import com.yomahub.liteflow.entity.flow.Condition;
import com.yomahub.liteflow.entity.flow.ThenCondition;
import com.yomahub.liteflow.entity.flow.WhenCondition;
import com.yomahub.liteflow.enums.ConditionTypeEnum;
+import com.yomahub.liteflow.exception.ConfigErrorException;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.util.Assert;
+import org.springframework.util.ResourceUtils;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
@@ -59,5 +66,24 @@ public abstract class FlowParser {
}
}
}
-
+
+ /**
+ * 根据配置的ruleSource查找匹配的资源
+ * @param ruleSource
+ * @return
+ * @throws IOException
+ */
+ protected Resource[] matchRuleResources(final String ruleSource) throws IOException {
+ Assert.notNull(ruleSource, "rule source must not be null");
+ String locationPattern = ruleSource;
+ if (!locationPattern.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
+ locationPattern = ResourceUtils.CLASSPATH_URL_PREFIX + locationPattern;
+ }
+ PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+ Resource[] resources = resolver.getResources(locationPattern);
+ if(ArrayUtil.isEmpty(resources)) {
+ throw new ConfigErrorException("config error,please check rule source property");
+ }
+ return resources;
+ }
}
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalJsonFlowParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalJsonFlowParser.java
index 9b2537656..ed2d6297c 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalJsonFlowParser.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalJsonFlowParser.java
@@ -1,8 +1,8 @@
package com.yomahub.liteflow.parser;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.io.resource.ResourceUtil;
-import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.CharsetUtil;
+import org.springframework.core.io.Resource;
/**
* @author guodongqing
@@ -12,7 +12,10 @@ public class LocalJsonFlowParser extends JsonFlowParser{
@Override
public void parseMain(String rulePath) throws Exception {
- String ruleContent = ResourceUtil.readUtf8Str(StrUtil.format("classpath:{}",rulePath));
- parse(ruleContent);
+ Resource[] resources = matchRuleResources(rulePath);
+ for (Resource resource : resources) {
+ String content = IoUtil.read(resource.getInputStream(), CharsetUtil.CHARSET_UTF_8);
+ parse(content);
+ }
}
}
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalXmlFlowParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalXmlFlowParser.java
index 5e9c696ab..952212a4c 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalXmlFlowParser.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalXmlFlowParser.java
@@ -7,9 +7,9 @@
*/
package com.yomahub.liteflow.parser;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.io.resource.ResourceUtil;
-import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.CharsetUtil;
+import org.springframework.core.io.Resource;
/**
* 基于本地的xml方式解析器
@@ -18,7 +18,10 @@ import cn.hutool.core.util.StrUtil;
public class LocalXmlFlowParser extends XmlFlowParser{
public void parseMain(String rulePath) throws Exception {
- String ruleContent = ResourceUtil.readUtf8Str(StrUtil.format("classpath:{}",rulePath));
- parse(ruleContent);
+ Resource[] resources = matchRuleResources(rulePath);
+ for (Resource resource : resources) {
+ String content = IoUtil.read(resource.getInputStream(), CharsetUtil.CHARSET_UTF_8);
+ parse(content);
+ }
}
}
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalYmlFlowParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalYmlFlowParser.java
index 99f03a404..12bd98c1a 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalYmlFlowParser.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/LocalYmlFlowParser.java
@@ -1,5 +1,9 @@
package com.yomahub.liteflow.parser;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.CharsetUtil;
+import org.springframework.core.io.Resource;
+
/**
* Yaml格式转换
*
@@ -10,7 +14,11 @@ public class LocalYmlFlowParser extends YmlFlowParser {
@Override
public void parseMain(String rulePath) throws Exception {
- super.parseMain(rulePath);
+ Resource[] resources = matchRuleResources(rulePath);
+ for (Resource resource : resources) {
+ String content = IoUtil.read(resource.getInputStream(), CharsetUtil.CHARSET_UTF_8);
+ parse(content);
+ }
}
}
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/YmlFlowParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/YmlFlowParser.java
index c8b44c09a..75e82e9b7 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/YmlFlowParser.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/YmlFlowParser.java
@@ -1,7 +1,5 @@
package com.yomahub.liteflow.parser;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
@@ -20,13 +18,12 @@ public abstract class YmlFlowParser extends JsonFlowParser{
private final Logger LOG = LoggerFactory.getLogger(YmlFlowParser.class);
@Override
- public void parseMain(String rulePath) throws Exception {
- String ruleContent = ResourceUtil.readUtf8Str(StrUtil.format("classpath:{}",rulePath));
- if (StrUtil.isBlank(ruleContent)){
+ public void parse(String content) throws Exception {
+ if (StrUtil.isBlank(content)){
return;
}
- JSONObject ruleObject = convertToJson(ruleContent);
- parse(ruleObject.toJSONString());
+ JSONObject ruleObject = convertToJson(content);
+ super.parse(ruleObject.toJSONString());
}
protected JSONObject convertToJson(String yamlString) {
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spring/ComponentScanner.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spring/ComponentScanner.java
index 9cdce584c..eac9fa6d3 100644
--- a/liteflow-core/src/main/java/com/yomahub/liteflow/spring/ComponentScanner.java
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spring/ComponentScanner.java
@@ -7,23 +7,22 @@
*/
package com.yomahub.liteflow.spring;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
-
import com.yomahub.liteflow.aop.ICmpAroundAspect;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.util.LOGOPrinter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+import java.util.HashMap;
+import java.util.Map;
/**
* 组件扫描类,只要是NodeComponent的实现类,都可以被这个扫描器扫到
* @author Bryan.Zhang
*/
-public class ComponentScanner implements InstantiationAwareBeanPostProcessor {
+public class ComponentScanner implements BeanPostProcessor {
private static final Logger LOG = LoggerFactory.getLogger(ComponentScanner.class);
diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigNoSpringTest.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigNoSpringTest.java
index b633e6ec9..6a7076380 100644
--- a/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigNoSpringTest.java
+++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/LiteflowConfigNoSpringTest.java
@@ -40,4 +40,62 @@ public class LiteflowConfigNoSpringTest extends BaseTest {
Assert.assertEquals(100, config.getWhenQueueLimit().longValue());
}
+ /**
+ * rule source支持的通配符
+ * 匹配的文件
+ * config/nospringgroup0/flow0.xml
+ * config/nospringgroup1/flow.xml
+ */
+ @Test
+ public void testLocalXmlRuleSourcePatternMatch() {
+ FlowExecutor executor = new FlowExecutor();
+ LiteflowConfig config = new LiteflowConfig();
+ config.setRuleSource("config/nospring*/flow*.xml");
+ executor.setLiteflowConfig(config);
+ executor.init();
+ LiteflowResponse response0 = executor.execute2Resp("chain1", "arg");
+ Assert.assertEquals("a==>b==>c", response0.getSlot().printStep());
+
+ LiteflowResponse response1 = executor.execute2Resp("chain3", "arg");
+ Assert.assertEquals("a==>c==>f==>g", response1.getSlot().printStep());
+
+ }
+
+ /**
+ * rule source支持的通配符
+ * 匹配的文件
+ * config/nospringgroup0/flow0.json
+ * config/nospringgroup1/flow0.json
+ */
+ @Test
+ public void testLocalJsonRuleSourcePatternMatch() {
+ FlowExecutor executor = new FlowExecutor();
+ LiteflowConfig config = new LiteflowConfig();
+ config.setRuleSource("config/nospring*/flow*.json");
+ executor.setLiteflowConfig(config);
+ executor.init();
+ LiteflowResponse response0 = executor.execute2Resp("chain1", "arg");
+ Assert.assertEquals("a==>b==>c", response0.getSlot().printStep());
+ LiteflowResponse response1 = executor.execute2Resp("chain3", "arg");
+ Assert.assertEquals("a==>c==>f==>g", response1.getSlot().printStep());
+ }
+
+ /**
+ * rule source支持的通配符
+ * 匹配的文件
+ * config/nospringgroup0/flow0.yml
+ * config/nospringgroup1/flow.yml
+ */
+ @Test
+ public void testLocalYmlRuleSourcePatternMatch() {
+ FlowExecutor executor = new FlowExecutor();
+ LiteflowConfig config = new LiteflowConfig();
+ config.setRuleSource("config/nospring*/flow*.yml");
+ executor.setLiteflowConfig(config);
+ executor.init();
+ LiteflowResponse response0 = executor.execute2Resp("chain1", "arg");
+ Assert.assertEquals("a==>b==>c", response0.getSlot().printStep());
+ LiteflowResponse response = executor.execute2Resp("chain3", "arg");
+ Assert.assertEquals("a==>c==>f==>g", response.getSlot().printStep());
+ }
}
diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchSpringTest.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchSpringTest.java
new file mode 100644
index 000000000..f1389f892
--- /dev/null
+++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/LocalRuleSourcePatternMatchSpringTest.java
@@ -0,0 +1,39 @@
+package com.yomahub.liteflow.test.config;
+
+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.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+
+/**
+ * spring环境下 rule-source 参数支持通配符,支持模式匹配
+ * @author zendwang
+ * @since 2.5.0
+ */
+@RunWith(SpringRunner.class)
+@ContextConfiguration("classpath:/config/local-rule-source-pattern-match.xml")
+public class LocalRuleSourcePatternMatchSpringTest extends BaseTest {
+
+ @Resource
+ private FlowExecutor executor;
+
+ /**
+ * 匹配的文件
+ * config/springgroup0/flow0.json
+ * config/springgroup1/flow0.json
+ */
+ @Test
+ public void testLocalJsonRuleSourcePatternMatch() {
+ LiteflowResponse response0 = executor.execute2Resp("chain1", "arg");
+ Assert.assertEquals("a==>b==>c", response0.getSlot().printStep());
+ LiteflowResponse response1 = executor.execute2Resp("chain3", "arg");
+ Assert.assertEquals("a==>c==>f==>g", response1.getSlot().printStep());
+ }
+}
diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/DCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/DCmp.java
new file mode 100644
index 000000000..ee710d1d6
--- /dev/null
+++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/DCmp.java
@@ -0,0 +1,21 @@
+/**
+ * Title: liteflow
+ * Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.config.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.stereotype.Component;
+
+@Component("d")
+public class DCmp extends NodeComponent {
+
+ @Override
+ public void process() {
+ System.out.println("DCmp executed!");
+ }
+
+}
diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/ECmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/ECmp.java
new file mode 100644
index 000000000..cda3d96ac
--- /dev/null
+++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/ECmp.java
@@ -0,0 +1,20 @@
+/**
+ * Title: liteflow
+ * Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.config.cmp;
+
+import com.yomahub.liteflow.core.NodeCondComponent;
+import org.springframework.stereotype.Component;
+
+@Component("e")
+public class ECmp extends NodeCondComponent {
+
+ @Override
+ public String processCond() throws Exception {
+ return "g";
+ }
+}
diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/FCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/FCmp.java
new file mode 100644
index 000000000..dfa32d344
--- /dev/null
+++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/FCmp.java
@@ -0,0 +1,21 @@
+/**
+ * Title: liteflow
+ * Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.config.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.stereotype.Component;
+
+@Component("f")
+public class FCmp extends NodeComponent {
+
+ @Override
+ public void process() {
+ System.out.println("FCmp executed!");
+ }
+
+}
diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/GCmp.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/GCmp.java
new file mode 100644
index 000000000..dd7ba071d
--- /dev/null
+++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/config/cmp/GCmp.java
@@ -0,0 +1,21 @@
+/**
+ * Title: liteflow
+ * Description: 轻量级的组件式流程框架
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.config.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+import org.springframework.stereotype.Component;
+
+@Component("g")
+public class GCmp extends NodeComponent {
+
+ @Override
+ public void process() {
+ System.out.println("GCmp executed!");
+ }
+
+}
diff --git a/liteflow-core/src/test/java/com/yomahub/liteflow/test/executor/FlowExecutorTest.java b/liteflow-core/src/test/java/com/yomahub/liteflow/test/executor/FlowExecutorTest.java
index f01bd0da8..cc0115eb0 100644
--- a/liteflow-core/src/test/java/com/yomahub/liteflow/test/executor/FlowExecutorTest.java
+++ b/liteflow-core/src/test/java/com/yomahub/liteflow/test/executor/FlowExecutorTest.java
@@ -31,7 +31,7 @@ public class FlowExecutorTest extends BaseTest {
@Test(expected=RuntimeException.class)
public void testMethodExecute2RespWithException() throws Exception{
LiteflowConfig config = new LiteflowConfig();
- config.setRuleSource("executor/flow.json");
+ config.setRuleSource("executor/flow0.json");
FlowExecutor executor = new FlowExecutor();
executor.setLiteflowConfig(config);
executor.init();
@@ -54,7 +54,7 @@ public class FlowExecutorTest extends BaseTest {
@Test(expected=RuntimeException.class)
public void testMethodExecuteWithException() throws Exception {
LiteflowConfig config = new LiteflowConfig();
- config.setRuleSource("executor/flow.json");
+ config.setRuleSource("executor/flow0.json");
FlowExecutor executor = new FlowExecutor();
executor.setLiteflowConfig(config);
executor.init();
diff --git a/liteflow-core/src/test/resources/config/local-rule-source-pattern-match.xml b/liteflow-core/src/test/resources/config/local-rule-source-pattern-match.xml
new file mode 100644
index 000000000..4f8b013c5
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/local-rule-source-pattern-match.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/liteflow-core/src/test/resources/config/nospringgroup0/flow0.json b/liteflow-core/src/test/resources/config/nospringgroup0/flow0.json
new file mode 100644
index 000000000..c3a7a8763
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/nospringgroup0/flow0.json
@@ -0,0 +1,28 @@
+{
+ "flow": {
+ "nodes": {
+ "node": [
+ {
+ "id": "a",
+ "class": "com.yomahub.liteflow.test.config.cmp.ACmp"
+ },
+ {
+ "id": "b",
+ "class": "com.yomahub.liteflow.test.config.cmp.BCmp"
+ },
+ {
+ "id": "c",
+ "class": "com.yomahub.liteflow.test.config.cmp.CCmp"
+ }
+ ]
+ },
+ "chain": [
+ {
+ "name": "chain1",
+ "condition": [
+ {"type": "then", "value": "a,b,c"}
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/liteflow-core/src/test/resources/config/nospringgroup0/flow0.xml b/liteflow-core/src/test/resources/config/nospringgroup0/flow0.xml
new file mode 100644
index 000000000..ee5d47f24
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/nospringgroup0/flow0.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/liteflow-core/src/test/resources/config/nospringgroup0/flow0.yml b/liteflow-core/src/test/resources/config/nospringgroup0/flow0.yml
new file mode 100644
index 000000000..5424e94fd
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/nospringgroup0/flow0.yml
@@ -0,0 +1,14 @@
+flow:
+ nodes:
+ node:
+ - id: a
+ class: com.yomahub.liteflow.test.config.cmp.ACmp
+ - id: b
+ class: com.yomahub.liteflow.test.config.cmp.BCmp
+ - id: c
+ class: com.yomahub.liteflow.test.config.cmp.CCmp
+ chain:
+ - name: chain1
+ condition:
+ - type: then
+ value: 'a,b,c'
diff --git a/liteflow-core/src/test/resources/config/nospringgroup1/flow.json b/liteflow-core/src/test/resources/config/nospringgroup1/flow.json
new file mode 100644
index 000000000..52dd794ad
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/nospringgroup1/flow.json
@@ -0,0 +1,32 @@
+{
+ "flow": {
+ "nodes": {
+ "node": [
+ {
+ "id": "d",
+ "class": "com.yomahub.liteflow.test.config.cmp.DCmp"
+ },
+ {
+ "id": "e",
+ "class": "com.yomahub.liteflow.test.config.cmp.ECmp"
+ },
+ {
+ "id": "f",
+ "class": "com.yomahub.liteflow.test.config.cmp.FCmp"
+ },
+ {
+ "id": "g",
+ "class": "com.yomahub.liteflow.test.config.cmp.GCmp"
+ }
+ ]
+ },
+ "chain": [
+ {
+ "name": "chain3",
+ "condition": [
+ {"type": "then", "value": "a,c,f,g"}
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/liteflow-core/src/test/resources/config/nospringgroup1/flow.xml b/liteflow-core/src/test/resources/config/nospringgroup1/flow.xml
new file mode 100644
index 000000000..d3d2afbf3
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/nospringgroup1/flow.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/liteflow-core/src/test/resources/config/nospringgroup1/flow.yml b/liteflow-core/src/test/resources/config/nospringgroup1/flow.yml
new file mode 100644
index 000000000..b6af2e455
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/nospringgroup1/flow.yml
@@ -0,0 +1,16 @@
+flow:
+ nodes:
+ node:
+ - id: d
+ class: com.yomahub.liteflow.test.config.cmp.DCmp
+ - id: e
+ class: com.yomahub.liteflow.test.config.cmp.ECmp
+ - id: f
+ class: com.yomahub.liteflow.test.config.cmp.FCmp
+ - id: g
+ class: com.yomahub.liteflow.test.config.cmp.GCmp
+ chain:
+ - name: chain3
+ condition:
+ - type: then
+ value: 'a,c,f,g'
diff --git a/liteflow-core/src/test/resources/config/springgroup0/flow0.json b/liteflow-core/src/test/resources/config/springgroup0/flow0.json
new file mode 100644
index 000000000..24615d628
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/springgroup0/flow0.json
@@ -0,0 +1,12 @@
+{
+ "flow": {
+ "chain": [
+ {
+ "name": "chain1",
+ "condition": [
+ {"type": "then", "value": "a,b,c"}
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/liteflow-core/src/test/resources/config/springgroup0/flow0.xml b/liteflow-core/src/test/resources/config/springgroup0/flow0.xml
new file mode 100644
index 000000000..22870d94f
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/springgroup0/flow0.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/liteflow-core/src/test/resources/config/springgroup0/flow0.yml b/liteflow-core/src/test/resources/config/springgroup0/flow0.yml
new file mode 100644
index 000000000..3cdaced3e
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/springgroup0/flow0.yml
@@ -0,0 +1,6 @@
+flow:
+ chain:
+ - name: chain1
+ condition:
+ - type: then
+ value: 'a,b,c'
diff --git a/liteflow-core/src/test/resources/config/springgroup1/flow.json b/liteflow-core/src/test/resources/config/springgroup1/flow.json
new file mode 100644
index 000000000..2821316b6
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/springgroup1/flow.json
@@ -0,0 +1,12 @@
+{
+ "flow": {
+ "chain": [
+ {
+ "name": "chain3",
+ "condition": [
+ {"type": "then", "value": "a,c,f,g"}
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/liteflow-core/src/test/resources/config/springgroup1/flow.xml b/liteflow-core/src/test/resources/config/springgroup1/flow.xml
new file mode 100644
index 000000000..5b23639aa
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/springgroup1/flow.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/liteflow-core/src/test/resources/config/springgroup1/flow.yml b/liteflow-core/src/test/resources/config/springgroup1/flow.yml
new file mode 100644
index 000000000..7a089fb8f
--- /dev/null
+++ b/liteflow-core/src/test/resources/config/springgroup1/flow.yml
@@ -0,0 +1,6 @@
+flow:
+ chain:
+ - name: chain3
+ condition:
+ - type: then
+ value: 'a,c,f,g'
diff --git a/liteflow-spring-boot-starter/pom.xml b/liteflow-spring-boot-starter/pom.xml
index 5e456be6c..ae8f68100 100644
--- a/liteflow-spring-boot-starter/pom.xml
+++ b/liteflow-spring-boot-starter/pom.xml
@@ -10,7 +10,7 @@
liteflow
com.yomahub
- 2.5.4
+ 2.5.5
diff --git a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowPropertyAutoConfiguration.java b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowPropertyAutoConfiguration.java
index 9cb48d441..802bc2d84 100644
--- a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowPropertyAutoConfiguration.java
+++ b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowPropertyAutoConfiguration.java
@@ -1,7 +1,6 @@
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;
@@ -15,7 +14,6 @@ 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")
diff --git a/liteflow-test-spring/pom.xml b/liteflow-test-spring/pom.xml
index 48f8cbeff..e24e07f74 100644
--- a/liteflow-test-spring/pom.xml
+++ b/liteflow-test-spring/pom.xml
@@ -9,7 +9,7 @@
liteflow
com.yomahub
- 2.5.4
+ 2.5.5
diff --git a/liteflow-test-springboot/pom.xml b/liteflow-test-springboot/pom.xml
index 7cf2adcaf..9899d523a 100644
--- a/liteflow-test-springboot/pom.xml
+++ b/liteflow-test-springboot/pom.xml
@@ -9,7 +9,7 @@
liteflow
com.yomahub
- 2.5.4
+ 2.5.5
diff --git a/pom.xml b/pom.xml
index 6c9f85658..21289929f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.yomahub
liteflow
pom
- 2.5.4
+ 2.5.5
liteflow
a lightweight and practical micro-process framework
https://github.com/bryan31/liteflow