This commit is contained in:
dongguo.tao
2021-04-07 15:04:44 +08:00
4 changed files with 51 additions and 15 deletions

View File

@@ -72,19 +72,21 @@ public class FlowExecutor {
for (String path : rulePath) {
try {
FlowParserTypeEnum pattern = matchFormatConfig(path);
path = ReUtil.replaceAll(path, PREFIX_FORMATE_CONFIG_REGEX, "");
switch (pattern) {
case TYPE_XML:
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_XML);
break;
case TYPE_JSON:
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_JSON);
break;
case TYPE_YML:
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_YML);
break;
default:
LOG.error("can't surport the format {}", path);
if(ObjectUtil.isNotNull(pattern)) {
path = ReUtil.replaceAll(path, PREFIX_FORMATE_CONFIG_REGEX, "");
switch (pattern) {
case TYPE_XML:
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_XML);
break;
case TYPE_JSON:
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_JSON);
break;
case TYPE_YML:
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_YML);
break;
default:
LOG.error("can't surport the format {}", path);
}
}
if(ObjectUtil.isNotNull(parser)) {
parser.parseMain(path);
@@ -183,6 +185,19 @@ public class FlowExecutor {
return FlowParserTypeEnum.TYPE_JSON;
} else if(ReUtil.isMatch(LOCAL_YML_CONFIG_REGEX, path) || ReUtil.isMatch(FORMATE_YML_CONFIG_REGEX, path)) {
return FlowParserTypeEnum.TYPE_YML;
} else if(isClassConfig(path)) {
try {
Class clazz = Class.forName(path);
if(ClassXmlFlowParser.class.isAssignableFrom(clazz)) {
return FlowParserTypeEnum.TYPE_XML;
} else if(ClassJsonFlowParser.class.isAssignableFrom(clazz)) {
return FlowParserTypeEnum.TYPE_JSON;
} else if(ClassYmlFlowParser.class.isAssignableFrom(clazz)) {
return FlowParserTypeEnum.TYPE_YML;
}
} catch (ClassNotFoundException e) {
LOG.error(e.getMessage());
}
}
return null;
}

View File

@@ -15,7 +15,7 @@ public class TestFlow implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
LiteflowResponse response= flowExecutor.execute("chain1", "it's a request");
LiteflowResponse response= flowExecutor.execute("chain4", "it's a request");
System.out.println(response);
}
}

View File

@@ -0,0 +1,21 @@
package com.yomahub.flowtest.custom;
import com.yomahub.liteflow.parser.ClassXmlFlowParser;
/**
* @Author: guodongqing
* @since: 2.5.0
*/
public class CustomXmlClass extends ClassXmlFlowParser {
@Override
public String parseCustom() {
String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<flow>\n" +
"\t<chain name=\"chain4\">\n" +
"\t\t<then value=\"a,cond(b|d)\"/>\n" +
"\t\t<then value=\"e,f,g\"/>\n" +
"\t</chain>\n" +
"</flow>";
return content;
}
}

View File

@@ -1,6 +1,6 @@
#liteflow.rule-source=config/flow.xml
#liteflow.rule-source=config/flow.yml
liteflow.rule-source=config/flow.json
liteflow.rule-source=config/flow.json;com.yomahub.flowtest.custom.CustomXmlClass
#liteflow.slot-size=2048
liteflow.when-max-wait-seconds=20
liteflow.monitor.enable-log=true