|
@@ -5,9 +5,9 @@ import com.yomahub.liteflow.annotation.LiteflowMethod;
|
|
import com.yomahub.liteflow.core.NodeComponent;
|
|
import com.yomahub.liteflow.core.NodeComponent;
|
|
import com.yomahub.liteflow.core.proxy.DeclWarpBean;
|
|
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.flow.FlowBus;
|
|
|
|
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.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,6 +43,8 @@ public class XPluginImpl implements Plugin {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ SolonNodeIdHolder nodeIdHolder = SolonNodeIdHolder.of(context);
|
|
|
|
+
|
|
// 放到前面
|
|
// 放到前面
|
|
context.beanMake(LiteflowProperty.class);
|
|
context.beanMake(LiteflowProperty.class);
|
|
context.beanMake(LiteflowMonitorProperty.class);
|
|
context.beanMake(LiteflowMonitorProperty.class);
|
|
@@ -51,20 +54,22 @@ public class XPluginImpl implements Plugin {
|
|
// 订阅生命周期实现类
|
|
// 订阅生命周期实现类
|
|
context.subBeansOfType(LifeCycle.class, LifeCycleHolder::addLifeCycle);
|
|
context.subBeansOfType(LifeCycle.class, LifeCycleHolder::addLifeCycle);
|
|
|
|
|
|
- // 订阅 NodeComponent 组件
|
|
|
|
- context.lifecycle(()-> {
|
|
|
|
- //扫描完成后,收集组件
|
|
|
|
- context.beanForeach(bw -> {
|
|
|
|
- if (bw.raw() instanceof NodeComponent) {
|
|
|
|
- FlowBus.addManagedNode(bw.name(), bw.raw());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ // 订阅 @Component 或别的方式产生的 NodeComponent
|
|
|
|
+ context.subWrapsOfType(NodeComponent.class, bw->{
|
|
|
|
+ if (Utils.isNotEmpty(bw.name())) {
|
|
|
|
+ NodeComponent node1 = bw.raw();
|
|
|
|
+ node1.setNodeId(bw.name());
|
|
|
|
+
|
|
|
|
+ nodeIdHolder.add(node1.getNodeId());
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
Set<Class<?>> liteflowMethodClassSet = new HashSet<>();
|
|
Set<Class<?>> liteflowMethodClassSet = new HashSet<>();
|
|
|
|
|
|
|
|
+ //添加 @LiteflowMethod 注解处理
|
|
context.beanExtractorAdd(LiteflowMethod.class, (bw, method, anno) -> {
|
|
context.beanExtractorAdd(LiteflowMethod.class, (bw, method, anno) -> {
|
|
if (liteflowMethodClassSet.contains(bw.clz())) {
|
|
if (liteflowMethodClassSet.contains(bw.clz())) {
|
|
|
|
+ //避免重复处理类
|
|
return;
|
|
return;
|
|
} else {
|
|
} else {
|
|
liteflowMethodClassSet.add(bw.clz());
|
|
liteflowMethodClassSet.add(bw.clz());
|
|
@@ -76,22 +81,31 @@ public class XPluginImpl implements Plugin {
|
|
|
|
|
|
for (DeclWarpBean declWarpBean : declWarpBeanList) {
|
|
for (DeclWarpBean declWarpBean : declWarpBeanList) {
|
|
NodeComponent node1 = LiteFlowProxyUtil.proxy2NodeComponent(declWarpBean);
|
|
NodeComponent node1 = LiteFlowProxyUtil.proxy2NodeComponent(declWarpBean);
|
|
- FlowBus.addManagedNode(node1.getNodeId(), node1);
|
|
|
|
|
|
+
|
|
|
|
+ BeanWrap node1Bw = context.wrap(node1.getNodeId(), node1);
|
|
|
|
+ context.putWrap(node1.getNodeId(), node1Bw);
|
|
|
|
+
|
|
|
|
+ nodeIdHolder.add(node1.getNodeId());
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ //添加 @LiteflowComponent 注解处理
|
|
context.beanBuilderAdd(LiteflowComponent.class, (clz, bw, anno) -> {
|
|
context.beanBuilderAdd(LiteflowComponent.class, (clz, bw, anno) -> {
|
|
- if (NodeComponent.class.isAssignableFrom(clz)) {
|
|
|
|
- NodeComponent node1 = bw.raw();
|
|
|
|
|
|
+ if(NodeComponent.class.isAssignableFrom(clz)) {
|
|
String nodeId = Utils.annoAlias(anno.id(), anno.value());
|
|
String nodeId = Utils.annoAlias(anno.id(), anno.value());
|
|
|
|
+ if (Utils.isNotEmpty(nodeId)) {
|
|
|
|
+ NodeComponent node1 = bw.raw();
|
|
|
|
+ node1.setNodeId(nodeId);
|
|
|
|
+ node1.setName(anno.name());
|
|
|
|
|
|
- node1.setNodeId(nodeId);
|
|
|
|
- node1.setName(anno.name());
|
|
|
|
|
|
+ context.putWrap(node1.getNodeId(), bw);
|
|
|
|
|
|
- FlowBus.addManagedNode(nodeId, node1);
|
|
|
|
- } else {
|
|
|
|
- context.beanExtractOrProxy(bw); // 尝试提取 LiteflowMethod 函数,并支持自动代理
|
|
|
|
|
|
+ nodeIdHolder.add(node1.getNodeId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 支持动态代理与函数提取
|
|
|
|
+ context.beanExtractOrProxy(bw);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|