官网地址:https://liteflow.cc/

1 Springboot场景安装运行

1.1 添加依赖

<dependency>
    <groupId>com.yomahub</groupId>
    <artifactId>liteflow-spring-boot-starter</artifactId>
    <version>2.12.4.1</version>
</dependency>

1.2 配置

@Component("a")
public class ACmp extends NodeComponent {

	@Override
	public void process() {
		//do your business
	}
}
@Component("b")
public class BCmp extends NodeComponent {

	@Override
	public void process() {
		//do your business
	}
}

@Component("c")
public class CCmp extends NodeComponent {

	@Override
	public void process() {
		//do your business
	}
}

然后,在你的SpringBoot的application.properties或者application.yml里添加配置

liteflow.rule-source=config/flow.el.xml

同时,在resources下的config/flow.el.xml中定义规则:

<?xml version="1.0" encoding="UTF-8"?>
<flow>
    <chain name="chain1">
        THEN(a, b, c);
    </chain>
</flow>

1.3 执行

声明启动类:

@SpringBootApplication
public class Main {

    public static void main(String[] args) {
        SpringApplication.run(Main.class);
    }
}

然后就可以在Springboot任意被Spring托管的类中拿到flowExecutor,进行执行链路:

@SpringBootTest(classes = Main.class)
@RunWith(SpringRunner.class)
public class MainTest {

    @Resource
    private FlowExecutor flowExecutor;

    @Test
    public void test(ReqDto reqDto){
		    // 执行xml中定义的链条, 将reqDto中的数据做到流程上下文中
		    // reqDto 转 customContext
        LiteflowResponse response = flowExecutor.execute2Resp("chain1", reqDto, customContext);
        System.out.println("1111111111");
    }

}

2 EL规则的写法