diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 000000000..fa7cc9cb6 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1 @@ +### \ No newline at end of file diff --git a/docs/images/architecture.png b/docs/images/architecture.png new file mode 100644 index 000000000..e0cf70d4c Binary files /dev/null and b/docs/images/architecture.png differ diff --git a/docs/quickstart.md b/docs/quickstart.md new file mode 100644 index 000000000..eab6d0a46 --- /dev/null +++ b/docs/quickstart.md @@ -0,0 +1,62 @@ +# 快速开始 +liteflow需要你的项目使用maven +## 依赖 +```xml + + com.thebeastshop.liteflow + liteflow + ${liteFlow.version} + +``` +## 流程配置文件 +```xml + + + + + + + + + + + + + + + +``` + +component为组件,这里你需要实现这些组件,每个组件继承`NodeComponent`类 +```java +public class AComponent extends NodeComponent { + + @Override + public void process() { + String str = this.getSlot().getRequestData(); + System.out.println(str); + System.out.println("Acomponent executed!"); + } +} +``` + +chain为流程链,每个链上可配置多个组件节点。目前执行的模式分串行和并行2种。 +串行标签为`then`,并行标签为`when`。 +在串行的模式下,以下2种写法是等价的,可以根据业务需要来把不同种类的节点放一行里。 +```xml + +``` +```xml + + +``` + +## 执行流程链 +```java +FlowExecutor executor = new FlowExecutor(); +executor.setRulePath(Arrays.asList(new String[]{"/config/flow.xml"})); +executor.init(); +Slot slot = executor.execute("demoChain", "arg"); +``` + +如果你的项目使用spring,推荐参考[和Spring进行集成](http://123.206.92.144:3000/#/runwithspring) \ No newline at end of file diff --git a/docs/runwithcustom.md b/docs/runwithcustom.md new file mode 100644 index 000000000..71963b000 --- /dev/null +++ b/docs/runwithcustom.md @@ -0,0 +1,29 @@ +## 使用自定义的方式配置 +如果你不想用本地的配置,也不打算使用zk作为配置持久化工具。liteFlow支持自定义的配置的扩展点。 + +# 创建自定义的配置的类 +在你的项目中创建一个类继承`ClassXmlFlowParser`这个类 +```java +public class TestCustomParser extends ClassXmlFlowParser { + + @Override + public String parseCustom() { + System.out.println("进入自定义parser"); + String xmlContent = null; + //这里需要自己扩展从自定义的地方获取配置 + return xmlContent; + } +} +``` + +# spring配置 +spring中需要改的地方还是执行器的配置,只需要在配置的路径地方放入自定义类的类路径即可 +```xml + + + + com.thebeastshop.liteflow.test.TestCustomParser + + + +``` \ No newline at end of file diff --git a/docs/runwithspring.md b/docs/runwithspring.md new file mode 100644 index 000000000..292290319 --- /dev/null +++ b/docs/runwithspring.md @@ -0,0 +1,34 @@ +# 和spring进行集成 +如果你的项目中使用了spring,liteFlow可以很方便和spring进行集成 + +## 流程配置可以省略的部分 +流程配置中的`nodes`节点,可以不用配置了,支持spring的自动扫描方式。你需要在你的spring配置文件中定义 +```xml + + +``` + +当然,你的组件节点也需要注册进spirng容器 +```java +@Component("a") +public class AComponent extends NodeComponent + @Override + public void process() { + String str = this.getSlot().getRequestData(); + System.out.println(str); + System.out.println("Acomponent executed!"); + } +} +``` + +## spring中执行器的配置 +```xml + + + + /config/flow.xml + + + +``` +然后你的项目中通过spring拿到执行器进行调用流程。 \ No newline at end of file diff --git a/docs/runwithzookeeper.md b/docs/runwithzookeeper.md new file mode 100644 index 000000000..c364d63b1 --- /dev/null +++ b/docs/runwithzookeeper.md @@ -0,0 +1,20 @@ +## 和zookeeper进行集成 +liteFlow支持把配置放在zk集群中,并支持实时修改流程 + +# spring配置 +你只需在原来配置执行器的地方,把本地xml路径换成zk地址就ok了 +```xml + + + + + 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183 + + + + + +``` + +如果你不加zkNode这个标签,就用默认的节点路径进行读取配置。 +使用这种方式加载配置,在zk上进行更改配置。liteFlow会实时刷新配置。 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 1b490e37e..e09a9a044 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ liteflow jar 4.0.0 - 1.3.1 + 2.0.1 UTF-8