mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
Merge branch 'v2.5.5' into master
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>liteflow</artifactId>
|
||||
<version>2.5.4</version>
|
||||
<version>2.5.5</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<NodeComponent> cmpClazz = (Class<NodeComponent>)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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<DefaultSlot> response0 = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertEquals("a==>b==>c", response0.getSlot().printStep());
|
||||
|
||||
LiteflowResponse<DefaultSlot> 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<DefaultSlot> response0 = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertEquals("a==>b==>c", response0.getSlot().printStep());
|
||||
LiteflowResponse<DefaultSlot> 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<DefaultSlot> response0 = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertEquals("a==>b==>c", response0.getSlot().printStep());
|
||||
LiteflowResponse<DefaultSlot> response = executor.execute2Resp("chain3", "arg");
|
||||
Assert.assertEquals("a==>c==>f==>g", response.getSlot().printStep());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<DefaultSlot> response0 = executor.execute2Resp("chain1", "arg");
|
||||
Assert.assertEquals("a==>b==>c", response0.getSlot().printStep());
|
||||
LiteflowResponse<DefaultSlot> response1 = executor.execute2Resp("chain3", "arg");
|
||||
Assert.assertEquals("a==>c==>f==>g", response1.getSlot().printStep());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
|
||||
|
||||
<context:component-scan base-package="com.yomahub.liteflow.test.config.cmp" />
|
||||
|
||||
<bean id="springAware" class="com.yomahub.liteflow.util.SpringAware"/>
|
||||
|
||||
<bean class="com.yomahub.liteflow.spring.ComponentScanner"/>
|
||||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="config/spring*/flow*.json"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
<property name="liteflowConfig" ref="liteflowConfig"/>
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -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"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<nodes>
|
||||
<node id="a" class="com.yomahub.liteflow.test.config.cmp.ACmp"/>
|
||||
<node id="b" class="com.yomahub.liteflow.test.config.cmp.BCmp"/>
|
||||
<node id="c" class="com.yomahub.liteflow.test.config.cmp.CCmp"/>
|
||||
<node id="d" class="com.yomahub.liteflow.test.config.cmp.DCmp"/>
|
||||
<node id="e" class="com.yomahub.liteflow.test.config.cmp.ECmp"/>
|
||||
<node id="f" class="com.yomahub.liteflow.test.config.cmp.FCmp"/>
|
||||
<node id="g" class="com.yomahub.liteflow.test.config.cmp.GCmp"/>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -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'
|
||||
@@ -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"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<nodes>
|
||||
<node id="a" class="com.yomahub.liteflow.test.parser.cmp.ACmp"/>
|
||||
<node id="b" class="com.yomahub.liteflow.test.parser.cmp.BCmp"/>
|
||||
<node id="c" class="com.yomahub.liteflow.test.parser.cmp.CCmp"/>
|
||||
<node id="d" class="com.yomahub.liteflow.test.parser.cmp.DCmp"/>
|
||||
<node id="e" class="com.yomahub.liteflow.test.parser.cmp.ECmp"/>
|
||||
<node id="f" class="com.yomahub.liteflow.test.parser.cmp.FCmp"/>
|
||||
<node id="g" class="com.yomahub.liteflow.test.parser.cmp.GCmp"/>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain3">
|
||||
<then value="a,c"/>
|
||||
<then value="f,g"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -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'
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"flow": {
|
||||
"chain": [
|
||||
{
|
||||
"name": "chain1",
|
||||
"condition": [
|
||||
{"type": "then", "value": "a,b,c"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<then value="a,b,c"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,6 @@
|
||||
flow:
|
||||
chain:
|
||||
- name: chain1
|
||||
condition:
|
||||
- type: then
|
||||
value: 'a,b,c'
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"flow": {
|
||||
"chain": [
|
||||
{
|
||||
"name": "chain3",
|
||||
"condition": [
|
||||
{"type": "then", "value": "a,c,f,g"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain3">
|
||||
<then value="a,c"/>
|
||||
<then value="f,g"/>
|
||||
</chain>
|
||||
</flow>
|
||||
@@ -0,0 +1,6 @@
|
||||
flow:
|
||||
chain:
|
||||
- name: chain3
|
||||
condition:
|
||||
- type: then
|
||||
value: 'a,c,f,g'
|
||||
@@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<artifactId>liteflow</artifactId>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<version>2.5.4</version>
|
||||
<version>2.5.5</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<artifactId>liteflow</artifactId>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<version>2.5.4</version>
|
||||
<version>2.5.5</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<artifactId>liteflow</artifactId>
|
||||
<groupId>com.yomahub</groupId>
|
||||
<version>2.5.4</version>
|
||||
<version>2.5.5</version>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
||||
<groupId>com.yomahub</groupId>
|
||||
<artifactId>liteflow</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>2.5.4</version>
|
||||
<version>2.5.5</version>
|
||||
<name>liteflow</name>
|
||||
<description>a lightweight and practical micro-process framework</description>
|
||||
<url>https://github.com/bryan31/liteflow</url>
|
||||
|
||||
Reference in New Issue
Block a user