更新到v2.0,更新文档

This commit is contained in:
bryan.zhang
2018-02-28 16:11:10 +08:00
parent 6bf72e3655
commit 0645bcbcd8
7 changed files with 147 additions and 1 deletions

1
docs/architecture.md Normal file
View File

@@ -0,0 +1 @@
###

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

62
docs/quickstart.md Normal file
View File

@@ -0,0 +1,62 @@
# 快速开始
liteflow需要你的项目使用maven
## 依赖
```xml
<dependency>
<groupId>com.thebeastshop.liteflow</groupId>
<artifactId>liteflow</artifactId>
<version>${liteFlow.version}</version>
</dependency>
```
## 流程配置文件
```xml
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<nodes>
<node id="a" class="com.thebeastshop.liteflow.test.component.AComponent"/>
<node id="b" class="com.thebeastshop.liteflow.test.component.BComponent"/>
<node id="c" class="com.thebeastshop.liteflow.test.component.CComponent"/>
<node id="d" class="com.thebeastshop.liteflow.test.component.DComponent"/>
<node id="e" class="com.thebeastshop.liteflow.test.component.EComponent"/>
</nodes>
<chain name="demoChain">
<then value="a,b,c"/> <!-- then表示串行 -->
<when value="d,e"/> <!-- when表示并行 -->
</chain>
</flow>
```
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
<then value="a,b,c,d"/>
```
```xml
<then value="a,b"/>
<then value="c,d"/>
```
## 执行流程链
```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)

29
docs/runwithcustom.md Normal file
View File

@@ -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
<bean id="flowExecutor" class="com.thebeastshop.liteflow.core.FlowExecutor">
<property name="rulePath">
<list>
<value>com.thebeastshop.liteflow.test.TestCustomParser</value>
</list>
</property>
</bean>
```

34
docs/runwithspring.md Normal file
View File

@@ -0,0 +1,34 @@
# 和spring进行集成
如果你的项目中使用了springliteFlow可以很方便和spring进行集成
## 流程配置可以省略的部分
流程配置中的`nodes`节点可以不用配置了支持spring的自动扫描方式。你需要在你的spring配置文件中定义
```xml
<context:component-scan base-package="com.thebeastshop.liteflow.test.component" />
<bean class="com.thebeastshop.liteflow.spring.ComponentScaner"/>
```
当然你的组件节点也需要注册进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
<bean id="flowExecutor" class="com.thebeastshop.liteflow.core.FlowExecutor">
<property name="rulePath">
<list>
<value>/config/flow.xml</value>
</list>
</property>
</bean>
```
然后你的项目中通过spring拿到执行器进行调用流程。

20
docs/runwithzookeeper.md Normal file
View File

@@ -0,0 +1,20 @@
## 和zookeeper进行集成
liteFlow支持把配置放在zk集群中并支持实时修改流程
# spring配置
你只需在原来配置执行器的地方把本地xml路径换成zk地址就ok了
```xml
<!-- 这种是zk方式配置 -->
<bean id="flowExecutor" class="com.thebeastshop.liteflow.core.FlowExecutor">
<property name="rulePath">
<list>
<value>127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183</value>
</list>
</property>
<!--这个不配置就用默认的/lite-flow/flow节点 -->
<property name="zkNode" value="/lite-flow/customFlow"/>
</bean>
```
如果你不加zkNode这个标签就用默认的节点路径进行读取配置。
使用这种方式加载配置在zk上进行更改配置。liteFlow会实时刷新配置。

View File

@@ -5,7 +5,7 @@
<artifactId>liteflow</artifactId>
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<version>1.3.1</version>
<version>2.0.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>