mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-21 10:48:10 +08:00
初步完成 liteflow-solon-plugin 适配
This commit is contained in:
@@ -7,6 +7,7 @@ import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import org.noear.solon.annotation.Bean;
|
||||
import org.noear.solon.annotation.Configuration;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
import org.noear.solon.core.AopContext;
|
||||
|
||||
/**
|
||||
* 主要的业务装配器
|
||||
@@ -26,6 +27,9 @@ public class LiteflowMainAutoConfiguration {
|
||||
@Inject("${liteflow.monitor.enable-log}")
|
||||
boolean enableLog;
|
||||
|
||||
@Inject
|
||||
AopContext aopContext;
|
||||
|
||||
//实例化FlowExecutor
|
||||
@Bean
|
||||
public FlowExecutor flowExecutor(LiteflowConfig liteflowConfig) {
|
||||
@@ -33,12 +37,15 @@ public class LiteflowMainAutoConfiguration {
|
||||
flowExecutor.setLiteflowConfig(liteflowConfig);
|
||||
|
||||
if (parseOnStart) {
|
||||
flowExecutor.init();
|
||||
aopContext.beanOnloaded((c) -> {
|
||||
flowExecutor.init(true);
|
||||
});
|
||||
}
|
||||
|
||||
return flowExecutor;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public MonitorBus monitorBus(LiteflowConfig liteflowConfig) {
|
||||
if (enableLog) {
|
||||
|
||||
@@ -9,8 +9,6 @@ import org.noear.solon.Utils;
|
||||
import org.noear.solon.core.AopContext;
|
||||
import org.noear.solon.core.Plugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -18,9 +16,6 @@ import java.util.Properties;
|
||||
* @since 2.9
|
||||
*/
|
||||
public class XPluginImpl implements Plugin {
|
||||
|
||||
public static Map<String, NodeComponent> nodeComponentMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void start(AopContext context) {
|
||||
//加载默认配置
|
||||
@@ -40,15 +35,14 @@ public class XPluginImpl implements Plugin {
|
||||
|
||||
//订阅 NodeComponent 组件
|
||||
context.subWrapsOfType(NodeComponent.class, bw -> {
|
||||
// NodeComponent node1 = bw.raw();
|
||||
//
|
||||
// if (Utils.isNotEmpty(bw.name())) {
|
||||
// node1.setName(bw.name());
|
||||
// node1.setNodeId(bw.name());
|
||||
// }
|
||||
NodeComponent node1 = bw.raw();
|
||||
|
||||
nodeComponentMap.put(bw.name(), bw.raw());
|
||||
//FlowBus.addSpringScanNode(bw.name(), bw.raw());
|
||||
if (Utils.isNotEmpty(bw.name())) {
|
||||
node1.setName(bw.name());
|
||||
node1.setNodeId(bw.name());
|
||||
}
|
||||
|
||||
FlowBus.addSpringScanNode(bw.name(), bw.raw());
|
||||
});
|
||||
|
||||
context.beanBuilderAdd(LiteflowComponent.class, (clz, bw, anno) -> {
|
||||
|
||||
@@ -67,6 +67,11 @@ public class SolonContextAware implements ContextAware {
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBean(String beanName) {
|
||||
return Solon.context().hasWrap(beanName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int priority() {
|
||||
return 1;
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package com.yomahub.liteflow.spi.solon;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.solon.integration.XPluginImpl;
|
||||
import com.yomahub.liteflow.spi.ContextCmpInit;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Solon 环境容器上下文组件初始化实现
|
||||
@@ -16,11 +11,7 @@ import java.util.Map;
|
||||
public class SolonContextCmpInit implements ContextCmpInit {
|
||||
@Override
|
||||
public void initCmp() {
|
||||
for (Map.Entry<String, NodeComponent> componentEntry : XPluginImpl.nodeComponentMap.entrySet()) {
|
||||
if (!FlowBus.containNode(componentEntry.getKey())) {
|
||||
FlowBus.addSpringScanNode(componentEntry.getKey(), componentEntry.getValue());
|
||||
}
|
||||
}
|
||||
//已在 XPluginImpl 添加组件
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user