feature #I5CW7I 【版本特性】构造全新的EL规则表达式
This commit is contained in:
parent
5a21adad6d
commit
2e82deec29
|
@ -49,14 +49,31 @@ public class FlowExecutor {
|
||||||
private static final String ZK_CONFIG_REGEX = "[\\w\\d][\\w\\d\\.]+\\:(\\d)+(\\,[\\w\\d][\\w\\d\\.]+\\:(\\d)+)*";
|
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_XML_CONFIG_REGEX = "^[\\w\\:\\-\\@\\/\\\\\\*]+\\.xml$";
|
||||||
|
|
||||||
|
private static final String LOCAL_EL_XML_CONFIG_REGEX = "^[\\w\\:\\-\\@\\/\\\\\\*]+\\.el\\.xml$";
|
||||||
private static final String LOCAL_JSON_CONFIG_REGEX = "^[\\w\\:\\-\\@\\/\\\\\\*]+\\.json$";
|
private static final String LOCAL_JSON_CONFIG_REGEX = "^[\\w\\:\\-\\@\\/\\\\\\*]+\\.json$";
|
||||||
|
|
||||||
|
private static final String LOCAL_EL_JSON_CONFIG_REGEX = "^[\\w\\:\\-\\@\\/\\\\\\*]+\\.el\\.json$";
|
||||||
private static final String LOCAL_YML_CONFIG_REGEX = "^[\\w\\:\\-\\@\\/\\\\\\*]+\\.yml$";
|
private static final String LOCAL_YML_CONFIG_REGEX = "^[\\w\\:\\-\\@\\/\\\\\\*]+\\.yml$";
|
||||||
|
|
||||||
|
private static final String LOCAL_EL_YML_CONFIG_REGEX = "^[\\w\\:\\-\\@\\/\\\\\\*]+\\el.\\.yml$";
|
||||||
|
|
||||||
private static final String FORMATE_XML_CONFIG_REGEX = "xml:.+";
|
private static final String FORMATE_XML_CONFIG_REGEX = "xml:.+";
|
||||||
|
|
||||||
|
private static final String FORMATE_EL_XML_CONFIG_REGEX = "el_xml:.+";
|
||||||
|
|
||||||
private static final String FORMATE_JSON_CONFIG_REGEX = "json:.+";
|
private static final String FORMATE_JSON_CONFIG_REGEX = "json:.+";
|
||||||
|
|
||||||
|
private static final String FORMATE_EL_JSON_CONFIG_REGEX = "el_json:.+";
|
||||||
|
|
||||||
private static final String FORMATE_YML_CONFIG_REGEX = "yml:.+";
|
private static final String FORMATE_YML_CONFIG_REGEX = "yml:.+";
|
||||||
|
|
||||||
|
private static final String FORMATE_EL_YML_CONFIG_REGEX = "el_yml:.+";
|
||||||
|
|
||||||
private static final String PREFIX_FORMATE_CONFIG_REGEX = "xml:|json:|yml:";
|
private static final String PREFIX_FORMATE_CONFIG_REGEX = "xml:|json:|yml:";
|
||||||
|
|
||||||
|
private static final String PREFIX_EL_FORMATE_CONFIG_REGEX = "el_xml:|el_json:|el_yml:";
|
||||||
|
|
||||||
private static final String CLASS_CONFIG_REGEX = "^\\w+(\\.\\w+)*$";
|
private static final String CLASS_CONFIG_REGEX = "^\\w+(\\.\\w+)*$";
|
||||||
|
|
||||||
private LiteflowConfig liteflowConfig;
|
private LiteflowConfig liteflowConfig;
|
||||||
|
@ -100,36 +117,30 @@ public class FlowExecutor {
|
||||||
List<String> rulePathList = new ArrayList<>();
|
List<String> rulePathList = new ArrayList<>();
|
||||||
for (String path : sourceRulePathList) {
|
for (String path : sourceRulePathList) {
|
||||||
try {
|
try {
|
||||||
|
//根据path获得pattern类型
|
||||||
FlowParserTypeEnum pattern = matchFormatConfig(path);
|
FlowParserTypeEnum pattern = matchFormatConfig(path);
|
||||||
if (ObjectUtil.isNotNull(pattern)) {
|
if (pattern == null){
|
||||||
path = ReUtil.replaceAll(path, PREFIX_FORMATE_CONFIG_REGEX, "");
|
String errorMsg = StrUtil.format("can't support the path:{}", path);
|
||||||
switch (pattern) {
|
throw new ErrorSupportPathException(errorMsg);
|
||||||
case TYPE_XML:
|
|
||||||
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_XML);
|
|
||||||
parserNameSet.add(parser.getClass().getName());
|
|
||||||
break;
|
|
||||||
case TYPE_JSON:
|
|
||||||
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_JSON);
|
|
||||||
parserNameSet.add(parser.getClass().getName());
|
|
||||||
break;
|
|
||||||
case TYPE_YML:
|
|
||||||
parser = matchFormatParser(path, FlowParserTypeEnum.TYPE_YML);
|
|
||||||
parserNameSet.add(parser.getClass().getName());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
String errorMsg = StrUtil.format("can't support the format {}", path);
|
|
||||||
throw new ErrorSupportPathException(errorMsg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = ReUtil.replaceAll(path, PREFIX_FORMATE_CONFIG_REGEX, "");
|
||||||
|
|
||||||
|
//获得parser
|
||||||
|
parser = matchFormatParser(path, pattern);
|
||||||
|
|
||||||
|
if (parser == null){
|
||||||
|
String errorMsg = StrUtil.format("can't find the parser for path:{}", path);
|
||||||
|
throw new ErrorSupportPathException(errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
parserNameSet.add(parser.getClass().getName());
|
||||||
|
|
||||||
rulePathList.add(path);
|
rulePathList.add(path);
|
||||||
|
|
||||||
//支持多类型的配置文件,分别解析
|
//支持多类型的配置文件,分别解析
|
||||||
if (BooleanUtil.isTrue(liteflowConfig.isSupportMultipleType())) {
|
if (BooleanUtil.isTrue(liteflowConfig.isSupportMultipleType())) {
|
||||||
if (ObjectUtil.isNotNull(parser)) {
|
parser.parseMain(ListUtil.toList(path));
|
||||||
parser.parseMain(ListUtil.toList(path));
|
|
||||||
} else {
|
|
||||||
throw new ConfigErrorException("parse error, please check liteflow config property");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (CyclicDependencyException e) {
|
} catch (CyclicDependencyException e) {
|
||||||
LOG.error(e.getMessage());
|
LOG.error(e.getMessage());
|
||||||
|
@ -152,7 +163,7 @@ public class FlowExecutor {
|
||||||
|
|
||||||
//进行多个配置文件的一起解析
|
//进行多个配置文件的一起解析
|
||||||
try {
|
try {
|
||||||
if (ObjectUtil.isNotNull(parser)) {
|
if (parser != null) {
|
||||||
parser.parseMain(rulePathList);
|
parser.parseMain(rulePathList);
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigErrorException("parse error, please check liteflow config property");
|
throw new ConfigErrorException("parse error, please check liteflow config property");
|
||||||
|
@ -248,7 +259,16 @@ public class FlowExecutor {
|
||||||
return FlowParserTypeEnum.TYPE_JSON;
|
return FlowParserTypeEnum.TYPE_JSON;
|
||||||
} else if (ReUtil.isMatch(LOCAL_YML_CONFIG_REGEX, path) || ReUtil.isMatch(FORMATE_YML_CONFIG_REGEX, path)) {
|
} else if (ReUtil.isMatch(LOCAL_YML_CONFIG_REGEX, path) || ReUtil.isMatch(FORMATE_YML_CONFIG_REGEX, path)) {
|
||||||
return FlowParserTypeEnum.TYPE_YML;
|
return FlowParserTypeEnum.TYPE_YML;
|
||||||
|
} else if (ReUtil.isMatch(LOCAL_EL_XML_CONFIG_REGEX, path) || ReUtil.isMatch(FORMATE_EL_XML_CONFIG_REGEX, path)) {
|
||||||
|
return FlowParserTypeEnum.TYPE_EL_XML;
|
||||||
|
} else if (ReUtil.isMatch(LOCAL_EL_JSON_CONFIG_REGEX, path) || ReUtil.isMatch(FORMATE_EL_JSON_CONFIG_REGEX, path)) {
|
||||||
|
return FlowParserTypeEnum.TYPE_EL_JSON;
|
||||||
|
} else if (ReUtil.isMatch(LOCAL_EL_YML_CONFIG_REGEX, path) || ReUtil.isMatch(FORMATE_EL_YML_CONFIG_REGEX, path)) {
|
||||||
|
return FlowParserTypeEnum.TYPE_EL_YML;
|
||||||
} else if (isClassConfig(path)) {
|
} else if (isClassConfig(path)) {
|
||||||
|
//其实整个这个判断块代码可以不要,因为如果是自定义配置源的话,标准写法也要在前面加xml:/json:/yml:这种
|
||||||
|
//但是这块可能是考虑到有些人忘加了,所以再来判断下。如果写了标准的话,是不会走到这块来的
|
||||||
|
//不过el形式的已经不支持这块了,需要标准写法,这点注意
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName(path);
|
Class<?> clazz = Class.forName(path);
|
||||||
if (ClassXmlFlowParser.class.isAssignableFrom(clazz)) {
|
if (ClassXmlFlowParser.class.isAssignableFrom(clazz)) {
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -262,6 +262,7 @@
|
||||||
<module>liteflow-testcase-nospring</module>
|
<module>liteflow-testcase-nospring</module>
|
||||||
<module>liteflow-spring</module>
|
<module>liteflow-spring</module>
|
||||||
<module>liteflow-testcase-declare-component</module>
|
<module>liteflow-testcase-declare-component</module>
|
||||||
|
<module>liteflow-testcase-el-springboot</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
|
|
Loading…
Reference in New Issue