mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-06-10 03:07:32 +08:00
feature #IAJD9H 期望liteflow 有自己的生命周期扩展
This commit is contained in:
@@ -25,6 +25,8 @@ import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.flow.element.Rollbackable;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
||||
import com.yomahub.liteflow.lifecycle.LifeCycleHolder;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessFlowExecuteLifeCycle;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.monitor.MonitorFile;
|
||||
@@ -43,6 +45,7 @@ import com.yomahub.liteflow.thread.ExecutorHelper;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
@@ -407,6 +410,13 @@ public class FlowExecutor {
|
||||
throw new NoAvailableSlotException(StrUtil.format("the slot[{}] is not exist", slotIndex));
|
||||
}
|
||||
|
||||
// 如果有FlowExecute生命周期实现,则执行
|
||||
if (CollUtil.isNotEmpty(LifeCycleHolder.getPostProcessFlowExecuteLifeCycleList())){
|
||||
LifeCycleHolder.getPostProcessFlowExecuteLifeCycleList().forEach(
|
||||
postProcessFlowExecuteLifeCycle -> postProcessFlowExecuteLifeCycle.postProcessBeforeFlowExecute(chainId, slot)
|
||||
);
|
||||
}
|
||||
|
||||
//如果传入了用户的RequestId,则用这个请求Id,如果没传入,则进行生成
|
||||
if (StrUtil.isNotBlank(requestId)){
|
||||
slot.putRequestId(requestId);
|
||||
@@ -515,6 +525,13 @@ public class FlowExecutor {
|
||||
DataBus.releaseSlot(slotIndex);
|
||||
LFLoggerManager.removeRequestId();
|
||||
}
|
||||
|
||||
// 如果有FlowExecute生命周期实现,则执行
|
||||
if (CollUtil.isNotEmpty(LifeCycleHolder.getPostProcessFlowExecuteLifeCycleList())){
|
||||
LifeCycleHolder.getPostProcessFlowExecuteLifeCycleList().forEach(
|
||||
postProcessFlowExecuteLifeCycle -> postProcessFlowExecuteLifeCycle.postProcessAfterFlowExecute(chainId, slot)
|
||||
);
|
||||
}
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package com.yomahub.liteflow.flow;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.annotation.FallbackCmp;
|
||||
@@ -91,11 +92,21 @@ public class FlowBus {
|
||||
|
||||
// 这个方法主要用于第二阶段的替换chain
|
||||
public static void addChain(Chain chain) {
|
||||
chainMap.put(chain.getChainId(), chain);
|
||||
//如果有生命周期则执行相应生命周期实现
|
||||
LifeCycleHolder.getPostProcessAfterChainBuildLifeCycleList().forEach(
|
||||
postProcessAfterChainBuildLifeCycle -> postProcessAfterChainBuildLifeCycle.postProcessAfterChainBuild(chain)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(LifeCycleHolder.getPostProcessChainBuildLifeCycleList())){
|
||||
LifeCycleHolder.getPostProcessChainBuildLifeCycleList().forEach(
|
||||
postProcessAfterChainBuildLifeCycle -> postProcessAfterChainBuildLifeCycle.postProcessBeforeChainBuild(chain)
|
||||
);
|
||||
}
|
||||
|
||||
chainMap.put(chain.getChainId(), chain);
|
||||
|
||||
//如果有生命周期则执行相应生命周期实现
|
||||
if (CollUtil.isNotEmpty(LifeCycleHolder.getPostProcessChainBuildLifeCycleList())){
|
||||
LifeCycleHolder.getPostProcessChainBuildLifeCycleList().forEach(
|
||||
postProcessAfterChainBuildLifeCycle -> postProcessAfterChainBuildLifeCycle.postProcessAfterChainBuild(chain)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containChain(String chainId) {
|
||||
@@ -374,11 +385,21 @@ public class FlowBus {
|
||||
}
|
||||
|
||||
private static void put2NodeMap(String nodeId, Node node){
|
||||
nodeMap.put(nodeId, node);
|
||||
// 如果有生命周期则执行相应生命周期实现
|
||||
LifeCycleHolder.getPostProcessAfterNodeBuildLifeCycleList().forEach(
|
||||
postProcessAfterNodeBuildLifeCycle -> postProcessAfterNodeBuildLifeCycle.postProcessAfterNodeBuild(node)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(LifeCycleHolder.getPostProcessNodeBuildLifeCycleList())){
|
||||
LifeCycleHolder.getPostProcessNodeBuildLifeCycleList().forEach(
|
||||
postProcessAfterNodeBuildLifeCycle -> postProcessAfterNodeBuildLifeCycle.postProcessBeforeNodeBuild(node)
|
||||
);
|
||||
}
|
||||
|
||||
nodeMap.put(nodeId, node);
|
||||
|
||||
// 如果有生命周期则执行相应生命周期实现
|
||||
if (CollUtil.isNotEmpty(LifeCycleHolder.getPostProcessNodeBuildLifeCycleList())){
|
||||
LifeCycleHolder.getPostProcessNodeBuildLifeCycleList().forEach(
|
||||
postProcessAfterNodeBuildLifeCycle -> postProcessAfterNodeBuildLifeCycle.postProcessAfterNodeBuild(node)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
|
||||
import com.yomahub.liteflow.exception.ChainEndException;
|
||||
import com.yomahub.liteflow.lifecycle.LifeCycleHolder;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessChainExecuteLifeCycle;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.slot.DataBus;
|
||||
@@ -20,6 +22,7 @@ import com.yomahub.liteflow.enums.ExecuteableTypeEnum;
|
||||
import com.yomahub.liteflow.exception.FlowSystemException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* chain对象,实现可执行器
|
||||
@@ -98,6 +101,13 @@ public class Chain implements Executable{
|
||||
}
|
||||
Slot slot = DataBus.getSlot(slotIndex);
|
||||
try {
|
||||
//如果有生命周期则执行相应生命周期实现
|
||||
if (CollUtil.isNotEmpty(LifeCycleHolder.getPostProcessChainExecuteLifeCycleList())){
|
||||
LifeCycleHolder.getPostProcessChainExecuteLifeCycleList().forEach(
|
||||
postProcessChainExecuteLifeCycle -> postProcessChainExecuteLifeCycle.postProcessBeforeChainExecute(chainId, slot)
|
||||
);
|
||||
}
|
||||
|
||||
// 设置主ChainName
|
||||
slot.setChainId(chainId);
|
||||
// 执行主体Condition
|
||||
@@ -105,6 +115,13 @@ public class Chain implements Executable{
|
||||
condition.setCurrChainId(chainId);
|
||||
condition.execute(slotIndex);
|
||||
}
|
||||
|
||||
//如果有生命周期则执行相应生命周期实现
|
||||
if (CollUtil.isNotEmpty(LifeCycleHolder.getPostProcessChainExecuteLifeCycleList())){
|
||||
LifeCycleHolder.getPostProcessChainExecuteLifeCycleList().forEach(
|
||||
postProcessChainExecuteLifeCycle -> postProcessChainExecuteLifeCycle.postProcessAfterChainExecute(chainId, slot)
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (ChainEndException e) {
|
||||
// 这里单独catch ChainEndException是因为ChainEndException是用户自己setIsEnd抛出的异常
|
||||
|
||||
@@ -12,32 +12,48 @@ import java.util.List;
|
||||
*/
|
||||
public class LifeCycleHolder {
|
||||
|
||||
private static final List<PostProcessAfterScriptEngineInitLifeCycle> postProcessAfterScriptEngineInitLifeCycleList = new ArrayList<>();
|
||||
private static final List<PostProcessScriptEngineInitLifeCycle> POST_PROCESS_SCRIPT_ENGINE_INIT_LIFE_CYCLE_LIST = new ArrayList<>();
|
||||
|
||||
private static final List<PostProcessAfterChainBuildLifeCycle> postProcessAfterChainBuildLifeCycleList = new ArrayList<>();
|
||||
private static final List<PostProcessChainBuildLifeCycle> POST_PROCESS_CHAIN_BUILD_LIFE_CYCLE_LIST = new ArrayList<>();
|
||||
|
||||
private static final List<PostProcessAfterNodeBuildLifeCycle> postProcessAfterNodeBuildLifeCycleList = new ArrayList<>();
|
||||
private static final List<PostProcessNodeBuildLifeCycle> POST_PROCESS_NODE_BUILD_LIFE_CYCLE_LIST = new ArrayList<>();
|
||||
|
||||
private static final List<PostProcessFlowExecuteLifeCycle> POST_PROCESS_FLOW_EXECUTE_LIFE_CYCLE_LIST = new ArrayList<>();
|
||||
|
||||
private static final List<PostProcessChainExecuteLifeCycle> POST_PROCESS_CHAIN_EXECUTE_LIFE_CYCLE_LIST = new ArrayList<>();
|
||||
|
||||
|
||||
public static void addLifeCycle(LifeCycle lifeCycle){
|
||||
if (PostProcessAfterScriptEngineInitLifeCycle.class.isAssignableFrom(lifeCycle.getClass())){
|
||||
postProcessAfterScriptEngineInitLifeCycleList.add((PostProcessAfterScriptEngineInitLifeCycle)lifeCycle);
|
||||
}else if(PostProcessAfterChainBuildLifeCycle.class.isAssignableFrom(lifeCycle.getClass())){
|
||||
postProcessAfterChainBuildLifeCycleList.add((PostProcessAfterChainBuildLifeCycle)lifeCycle);
|
||||
}else if(PostProcessAfterNodeBuildLifeCycle.class.isAssignableFrom(lifeCycle.getClass())){
|
||||
postProcessAfterNodeBuildLifeCycleList.add((PostProcessAfterNodeBuildLifeCycle)lifeCycle);
|
||||
if (PostProcessScriptEngineInitLifeCycle.class.isAssignableFrom(lifeCycle.getClass())){
|
||||
POST_PROCESS_SCRIPT_ENGINE_INIT_LIFE_CYCLE_LIST.add((PostProcessScriptEngineInitLifeCycle)lifeCycle);
|
||||
}else if(PostProcessChainBuildLifeCycle.class.isAssignableFrom(lifeCycle.getClass())){
|
||||
POST_PROCESS_CHAIN_BUILD_LIFE_CYCLE_LIST.add((PostProcessChainBuildLifeCycle)lifeCycle);
|
||||
}else if(PostProcessNodeBuildLifeCycle.class.isAssignableFrom(lifeCycle.getClass())){
|
||||
POST_PROCESS_NODE_BUILD_LIFE_CYCLE_LIST.add((PostProcessNodeBuildLifeCycle)lifeCycle);
|
||||
}else if(PostProcessFlowExecuteLifeCycle.class.isAssignableFrom(lifeCycle.getClass())){
|
||||
POST_PROCESS_FLOW_EXECUTE_LIFE_CYCLE_LIST.add((PostProcessFlowExecuteLifeCycle)lifeCycle);
|
||||
}else if(PostProcessChainExecuteLifeCycle.class.isAssignableFrom(lifeCycle.getClass())){
|
||||
POST_PROCESS_CHAIN_EXECUTE_LIFE_CYCLE_LIST.add((PostProcessChainExecuteLifeCycle)lifeCycle);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<PostProcessAfterScriptEngineInitLifeCycle> getPostProcessAfterScriptEngineInitLifeCycleList() {
|
||||
return postProcessAfterScriptEngineInitLifeCycleList;
|
||||
public static List<PostProcessScriptEngineInitLifeCycle> getPostProcessScriptEngineInitLifeCycleList() {
|
||||
return POST_PROCESS_SCRIPT_ENGINE_INIT_LIFE_CYCLE_LIST;
|
||||
}
|
||||
|
||||
public static List<PostProcessAfterChainBuildLifeCycle> getPostProcessAfterChainBuildLifeCycleList() {
|
||||
return postProcessAfterChainBuildLifeCycleList;
|
||||
public static List<PostProcessChainBuildLifeCycle> getPostProcessChainBuildLifeCycleList() {
|
||||
return POST_PROCESS_CHAIN_BUILD_LIFE_CYCLE_LIST;
|
||||
}
|
||||
|
||||
public static List<PostProcessAfterNodeBuildLifeCycle> getPostProcessAfterNodeBuildLifeCycleList() {
|
||||
return postProcessAfterNodeBuildLifeCycleList;
|
||||
public static List<PostProcessNodeBuildLifeCycle> getPostProcessNodeBuildLifeCycleList() {
|
||||
return POST_PROCESS_NODE_BUILD_LIFE_CYCLE_LIST;
|
||||
}
|
||||
|
||||
public static List<PostProcessFlowExecuteLifeCycle> getPostProcessFlowExecuteLifeCycleList() {
|
||||
return POST_PROCESS_FLOW_EXECUTE_LIFE_CYCLE_LIST;
|
||||
}
|
||||
|
||||
public static List<PostProcessChainExecuteLifeCycle> getPostProcessChainExecuteLifeCycleList() {
|
||||
return POST_PROCESS_CHAIN_EXECUTE_LIFE_CYCLE_LIST;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import com.yomahub.liteflow.flow.element.Chain;
|
||||
|
||||
/**
|
||||
* 生命周期接口
|
||||
* 在Chain构造后执行,如果有实现的话
|
||||
* 在Chain构造时期,如果有实现的话
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.12.4
|
||||
*/
|
||||
public interface PostProcessAfterChainBuildLifeCycle extends LifeCycle {
|
||||
public interface PostProcessChainBuildLifeCycle extends LifeCycle {
|
||||
|
||||
void postProcessBeforeChainBuild(Chain chain);
|
||||
|
||||
void postProcessAfterChainBuild(Chain chain);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yomahub.liteflow.lifecycle;
|
||||
|
||||
import com.yomahub.liteflow.slot.Slot;
|
||||
|
||||
/**
|
||||
* 生命周期接口
|
||||
* 执行Chain的时候
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.12.4
|
||||
*/
|
||||
public interface PostProcessChainExecuteLifeCycle extends LifeCycle{
|
||||
|
||||
void postProcessBeforeChainExecute(String chainId, Slot slot);
|
||||
|
||||
void postProcessAfterChainExecute(String chainId, Slot slot);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yomahub.liteflow.lifecycle;
|
||||
|
||||
import com.yomahub.liteflow.slot.Slot;
|
||||
|
||||
/**
|
||||
* 生命周期接口
|
||||
* 执行FLowExecutor的时候
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.12.4
|
||||
*/
|
||||
public interface PostProcessFlowExecuteLifeCycle extends LifeCycle{
|
||||
|
||||
void postProcessBeforeFlowExecute(String chainId, Slot slot);
|
||||
|
||||
void postProcessAfterFlowExecute(String chainId, Slot slot);
|
||||
}
|
||||
@@ -4,12 +4,14 @@ import com.yomahub.liteflow.flow.element.Node;
|
||||
|
||||
/**
|
||||
* 生命周期接口
|
||||
* 在Node构造后执行,如果有实现的话
|
||||
* 在Node构造时期,如果有实现的话
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.12.4
|
||||
*/
|
||||
public interface PostProcessAfterNodeBuildLifeCycle extends LifeCycle {
|
||||
public interface PostProcessNodeBuildLifeCycle extends LifeCycle {
|
||||
|
||||
void postProcessBeforeNodeBuild(Node node);
|
||||
|
||||
void postProcessAfterNodeBuild(Node node);
|
||||
}
|
||||
@@ -2,12 +2,12 @@ package com.yomahub.liteflow.lifecycle;
|
||||
|
||||
/**
|
||||
* 生命周期接口
|
||||
* 在初始化Script执行器后执行,如果有实现的话
|
||||
* 在初始化Script执行器时期,如果有实现的话
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.12.4
|
||||
*/
|
||||
public interface PostProcessAfterScriptEngineInitLifeCycle extends LifeCycle{
|
||||
public interface PostProcessScriptEngineInitLifeCycle extends LifeCycle{
|
||||
|
||||
void postProcessAfterScriptEngineInit(Object engine);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.yomahub.liteflow.script;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yomahub.liteflow.enums.ScriptTypeEnum;
|
||||
import com.yomahub.liteflow.exception.LiteFlowException;
|
||||
@@ -26,9 +27,11 @@ public abstract class ScriptExecutor {
|
||||
}
|
||||
|
||||
public void lifeCycle(Object engine){
|
||||
LifeCycleHolder.getPostProcessAfterScriptEngineInitLifeCycleList().forEach(
|
||||
postProcessAfterScriptEngineInitLifeCycle -> postProcessAfterScriptEngineInitLifeCycle.postProcessAfterScriptEngineInit(engine)
|
||||
);
|
||||
if (CollUtil.isNotEmpty(LifeCycleHolder.getPostProcessScriptEngineInitLifeCycleList())){
|
||||
LifeCycleHolder.getPostProcessScriptEngineInitLifeCycleList().forEach(
|
||||
postProcessAfterScriptEngineInitLifeCycle -> postProcessAfterScriptEngineInitLifeCycle.postProcessAfterScriptEngineInit(engine)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void load(String nodeId, String script);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.yomahub.liteflow.script.jsr223;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.lifecycle.LifeCycleHolder;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessAfterScriptEngineInitLifeCycle;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.script.ScriptExecuteWrap;
|
||||
@@ -20,7 +18,6 @@ import javax.script.ScriptException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* JSR223 script engine的统一实现抽象类
|
||||
|
||||
@@ -2,13 +2,18 @@ package com.yomahub.liteflow.test.lifecycle.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.flow.element.Chain;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessAfterChainBuildLifeCycle;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessChainBuildLifeCycle;
|
||||
import org.noear.solon.annotation.Component;
|
||||
|
||||
@Component
|
||||
public class TestChainLifeCycle implements PostProcessAfterChainBuildLifeCycle {
|
||||
public class TestChainLifeCycle implements PostProcessChainBuildLifeCycle {
|
||||
@Override
|
||||
public void postProcessBeforeChainBuild(Chain chain) {
|
||||
System.out.println(StrUtil.format("Chain Build(前)生命周期——[{}]已被加载",chain.getChainId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessAfterChainBuild(Chain chain) {
|
||||
System.out.println(StrUtil.format("Chain生命周期——[{}]已被加载",chain.getChainId()));
|
||||
System.out.println(StrUtil.format("Chain Build(后)生命周期——[{}]已被加载",chain.getChainId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.yomahub.liteflow.test.lifecycle.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessAfterNodeBuildLifeCycle;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessNodeBuildLifeCycle;
|
||||
import org.noear.solon.annotation.Component;
|
||||
|
||||
@Component
|
||||
public class TestNodeLifeCycle implements PostProcessAfterNodeBuildLifeCycle {
|
||||
public class TestNodeLifeCycle implements PostProcessNodeBuildLifeCycle {
|
||||
@Override
|
||||
public void postProcessAfterNodeBuild(Node node) {
|
||||
System.out.println(StrUtil.format("Node生命周期——[{}]已被加载",node.getId()));
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yomahub.liteflow.test.lifecycle.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessChainExecuteLifeCycle;
|
||||
import com.yomahub.liteflow.slot.Slot;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestChainExecuteLifeCycle implements PostProcessChainExecuteLifeCycle {
|
||||
@Override
|
||||
public void postProcessBeforeChainExecute(String chainId, Slot slot) {
|
||||
System.out.println(StrUtil.format("Chain Execute 生命周期(前)——[{}]已被加载",chainId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessAfterChainExecute(String chainId, Slot slot) {
|
||||
System.out.println(StrUtil.format("Chain Execute 生命周期(后)——[{}]已被加载",chainId));
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,18 @@ package com.yomahub.liteflow.test.lifecycle.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.flow.element.Chain;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessAfterChainBuildLifeCycle;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessChainBuildLifeCycle;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestChainLifeCycle implements PostProcessAfterChainBuildLifeCycle {
|
||||
public class TestChainLifeCycle implements PostProcessChainBuildLifeCycle {
|
||||
@Override
|
||||
public void postProcessBeforeChainBuild(Chain chain) {
|
||||
System.out.println(StrUtil.format("Chain Build生命周期(前)——[{}]已被加载",chain.getChainId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessAfterChainBuild(Chain chain) {
|
||||
System.out.println(StrUtil.format("Chain生命周期——[{}]已被加载",chain.getChainId()));
|
||||
System.out.println(StrUtil.format("Chain Build生命周期(后)——[{}]已被加载",chain.getChainId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yomahub.liteflow.test.lifecycle.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessFlowExecuteLifeCycle;
|
||||
import com.yomahub.liteflow.slot.Slot;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestFlowExecuteLifeCycle implements PostProcessFlowExecuteLifeCycle {
|
||||
@Override
|
||||
public void postProcessBeforeFlowExecute(String chainId, Slot slot) {
|
||||
System.out.println(StrUtil.format("FlowExecutor 生命周期(前)——[{}]已被加载",chainId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessAfterFlowExecute(String chainId, Slot slot) {
|
||||
System.out.println(StrUtil.format("FlowExecutor 生命周期(后)——[{}]已被加载",chainId));
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,18 @@ package com.yomahub.liteflow.test.lifecycle.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessAfterNodeBuildLifeCycle;
|
||||
import com.yomahub.liteflow.lifecycle.PostProcessNodeBuildLifeCycle;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestNodeLifeCycle implements PostProcessAfterNodeBuildLifeCycle {
|
||||
public class TestNodeLifeCycle implements PostProcessNodeBuildLifeCycle {
|
||||
@Override
|
||||
public void postProcessBeforeNodeBuild(Node node) {
|
||||
System.out.println(StrUtil.format("Node Build生命周期(前)——[{}]已被加载",node.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessAfterNodeBuild(Node node) {
|
||||
System.out.println(StrUtil.format("Node生命周期——[{}]已被加载",node.getId()));
|
||||
System.out.println(StrUtil.format("Node Build生命周期(后)——[{}]已被加载",node.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user