📙Custom source
# 说明
If you don't want to use the local configuration, and don't plan to use zk as the configuration source. LiteFlow supports extension points for custom configuration sources.
Rule files in XML form, please inherit ClassXmlFlowELParser
For rule files in JSON format, please inherit ClassJsonFlowELParser
For rule files in YML format, please inherit ClassYmlFlowELParser
The following is an example of a custom source configuration class in XML form:
public class TestCustomParser extends ClassXmlFlowELParser {
@Override
public String parseCustom() {
System.out.println("进入自定义parser");
String xmlContent = null;
//Here you need to extend it yourself to get the configuration from a custom place
return xmlContent;
}
}
tip one
The custom configuration source class is also automatically injected into the spring context, so you can freely inject beans in the spring context in this class, you can use annotation such as @Autowired
and @Resources
tip two
The custom configuration source implementation class requires you to return all the configuration file text content. This also means that if you store in a database, you store all the rules file text.
If you want to store the rule details in the database instead of the entire rule text, please refer to the Dynamic rules chapter.
# Configuration path
The following uses the configuration of Springboot as an example. For the configuration of Spring and non-Spring environments, you can read the Configuration Items chapter in detail.
You just need to change rule-source to the class of your custom rule configuration source
liteflow.rule-source=el_xml:com.yomahub.liteflow.test.TestCustomParser
About the el_xml tag header
LiteFlow not only supports xml configuration, but also json and yml configuration. The beginning of el_xml:
indicates that the content read here is the configuration in xml and parsed in EL. Please read the Rule File Format chapter for details about the supported format of the rule file.