mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
litefolw-solon-plugin 调整适配,节点组件保持与 Spring 相似
This commit is contained in:
@@ -1,35 +0,0 @@
|
|||||||
package com.yomahub.liteflow.process.holder;
|
|
||||||
|
|
||||||
import com.yomahub.liteflow.core.NodeComponent;
|
|
||||||
import org.noear.solon.core.AppContext;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 节点持有人(用于收集 Node 后统一注册)
|
|
||||||
*
|
|
||||||
* @author noear 2024/10/12 created
|
|
||||||
*/
|
|
||||||
public class SolonNodeHolder {
|
|
||||||
/**
|
|
||||||
* 作为 AppContext 附件(避免静态化)
|
|
||||||
* */
|
|
||||||
public static SolonNodeHolder of(AppContext context) {
|
|
||||||
return context.attachOf(SolonNodeHolder.class, SolonNodeHolder::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
private SolonNodeHolder() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, NodeComponent> nodeMap = new HashMap<>();
|
|
||||||
|
|
||||||
public void put(String nodeId, NodeComponent nodeComponent) {
|
|
||||||
this.nodeMap.put(nodeId, nodeComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, NodeComponent> getNodeMap() {
|
|
||||||
return nodeMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.yomahub.liteflow.process.holder;
|
||||||
|
|
||||||
|
import org.noear.solon.core.AppContext;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点持有人(用于收集 Node 后统一注册)
|
||||||
|
*
|
||||||
|
* @author noear 2024/10/12 created
|
||||||
|
*/
|
||||||
|
public class SolonNodeIdHolder {
|
||||||
|
/**
|
||||||
|
* 作为 AppContext 附件(避免静态化)
|
||||||
|
* */
|
||||||
|
public static SolonNodeIdHolder of(AppContext context) {
|
||||||
|
return context.attachOf(SolonNodeIdHolder.class, SolonNodeIdHolder::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SolonNodeIdHolder() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<String> nodeIdSet = new HashSet<>();
|
||||||
|
|
||||||
|
public void add(String nodeId) {
|
||||||
|
this.nodeIdSet.add(nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getNodeIdSet() {
|
||||||
|
return nodeIdSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import com.yomahub.liteflow.core.proxy.DeclWarpBean;
|
|||||||
import com.yomahub.liteflow.core.proxy.LiteFlowProxyUtil;
|
import com.yomahub.liteflow.core.proxy.LiteFlowProxyUtil;
|
||||||
import com.yomahub.liteflow.lifecycle.LifeCycle;
|
import com.yomahub.liteflow.lifecycle.LifeCycle;
|
||||||
import com.yomahub.liteflow.lifecycle.LifeCycleHolder;
|
import com.yomahub.liteflow.lifecycle.LifeCycleHolder;
|
||||||
import com.yomahub.liteflow.process.holder.SolonNodeHolder;
|
import com.yomahub.liteflow.process.holder.SolonNodeIdHolder;
|
||||||
import com.yomahub.liteflow.solon.config.LiteflowAutoConfiguration;
|
import com.yomahub.liteflow.solon.config.LiteflowAutoConfiguration;
|
||||||
import com.yomahub.liteflow.solon.config.LiteflowMainAutoConfiguration;
|
import com.yomahub.liteflow.solon.config.LiteflowMainAutoConfiguration;
|
||||||
import com.yomahub.liteflow.solon.config.LiteflowMonitorProperty;
|
import com.yomahub.liteflow.solon.config.LiteflowMonitorProperty;
|
||||||
@@ -15,6 +15,7 @@ import com.yomahub.liteflow.solon.config.LiteflowProperty;
|
|||||||
import com.yomahub.liteflow.spi.holder.DeclComponentParserHolder;
|
import com.yomahub.liteflow.spi.holder.DeclComponentParserHolder;
|
||||||
import org.noear.solon.Utils;
|
import org.noear.solon.Utils;
|
||||||
import org.noear.solon.core.AppContext;
|
import org.noear.solon.core.AppContext;
|
||||||
|
import org.noear.solon.core.BeanWrap;
|
||||||
import org.noear.solon.core.Plugin;
|
import org.noear.solon.core.Plugin;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -42,7 +43,7 @@ public class XPluginImpl implements Plugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SolonNodeHolder solonNodeHolder = SolonNodeHolder.of(context);
|
SolonNodeIdHolder nodeIdHolder = SolonNodeIdHolder.of(context);
|
||||||
|
|
||||||
// 放到前面
|
// 放到前面
|
||||||
context.beanMake(LiteflowProperty.class);
|
context.beanMake(LiteflowProperty.class);
|
||||||
@@ -61,7 +62,7 @@ public class XPluginImpl implements Plugin {
|
|||||||
NodeComponent node1 = bw.raw();
|
NodeComponent node1 = bw.raw();
|
||||||
node1.setNodeId(bw.name());
|
node1.setNodeId(bw.name());
|
||||||
|
|
||||||
solonNodeHolder.put(node1.getNodeId(), node1);
|
nodeIdHolder.add(node1.getNodeId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -83,7 +84,10 @@ public class XPluginImpl implements Plugin {
|
|||||||
for (DeclWarpBean declWarpBean : declWarpBeanList) {
|
for (DeclWarpBean declWarpBean : declWarpBeanList) {
|
||||||
NodeComponent node1 = LiteFlowProxyUtil.proxy2NodeComponent(declWarpBean);
|
NodeComponent node1 = LiteFlowProxyUtil.proxy2NodeComponent(declWarpBean);
|
||||||
|
|
||||||
solonNodeHolder.put(node1.getNodeId(), node1);
|
BeanWrap node1Bw = context.wrap(node1.getNodeId(), node1);
|
||||||
|
context.putWrap(node1.getNodeId(), node1Bw);
|
||||||
|
|
||||||
|
nodeIdHolder.add(node1.getNodeId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -96,7 +100,9 @@ public class XPluginImpl implements Plugin {
|
|||||||
node1.setNodeId(nodeId);
|
node1.setNodeId(nodeId);
|
||||||
node1.setName(anno.name());
|
node1.setName(anno.name());
|
||||||
|
|
||||||
solonNodeHolder.put(nodeId, node1);
|
context.putWrap(node1.getNodeId(), bw);
|
||||||
|
|
||||||
|
nodeIdHolder.add(node1.getNodeId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.yomahub.liteflow.spi.solon;
|
package com.yomahub.liteflow.spi.solon;
|
||||||
|
|
||||||
import com.yomahub.liteflow.flow.FlowBus;
|
import com.yomahub.liteflow.flow.FlowBus;
|
||||||
import com.yomahub.liteflow.process.holder.SolonNodeHolder;
|
import com.yomahub.liteflow.process.holder.SolonNodeIdHolder;
|
||||||
import com.yomahub.liteflow.spi.ContextCmpInit;
|
import com.yomahub.liteflow.spi.ContextCmpInit;
|
||||||
import org.noear.solon.Solon;
|
import org.noear.solon.Solon;
|
||||||
|
|
||||||
@@ -15,9 +15,7 @@ public class SolonContextCmpInit implements ContextCmpInit {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initCmp() {
|
public void initCmp() {
|
||||||
SolonNodeHolder solonNodeHolder = SolonNodeHolder.of(Solon.context());
|
SolonNodeIdHolder.of(Solon.context()).getNodeIdSet().forEach(FlowBus::addManagedNode);
|
||||||
|
|
||||||
solonNodeHolder.getNodeMap().forEach(FlowBus::addManagedNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user