改变LiteflowExecutorInit的spring生命周期,使其更合理

This commit is contained in:
everywhere.z
2023-12-20 19:24:29 +08:00
parent 41ad52c35f
commit cbdfa61134

View File

@@ -2,24 +2,22 @@ package com.yomahub.liteflow.springboot;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.FlowBus;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.CommandLineRunner;
import org.springframework.beans.factory.SmartInitializingSingleton;
/**
* 执行器初始化类 主要用于在启动时执行执行器的初始化方法,避免在运行执行器时第一次初始化而耗费时间
*
* @author Bryan.Zhang
*/
public class LiteflowExecutorInit implements CommandLineRunner {
public class LiteflowExecutorInit implements SmartInitializingSingleton {
private final FlowExecutor flowExecutor;
public LiteflowExecutorInit(FlowExecutor flowExecutor) {
this.flowExecutor = flowExecutor;
}
@Override
public void run(String... args) throws Exception {
public void afterSingletonsInstantiated() {
flowExecutor.init(true);
FlowBus.needInit();
}