初步完成 liteflow-solon-plugin 适配

This commit is contained in:
noear
2022-12-22 12:46:01 +08:00
parent 77d2c12485
commit e579540e3a
13 changed files with 79 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
package com.yomahub.liteflow.solon;
import org.noear.solon.Utils;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
@@ -84,7 +85,11 @@ public class LiteflowProperty {
}
public void setRuleSource(String ruleSource) {
this.ruleSource = ruleSource;
if (ruleSource.contains("*")) {
this.ruleSource = String.join(",", Utils.resolvePaths(ruleSource));
} else {
this.ruleSource = ruleSource;
}
}
public int getSlotSize() {

View File

@@ -48,19 +48,18 @@ public class XPluginImpl implements Plugin {
node1.setNodeId(nodeId);
node1.setType(anno.nodeType());
FlowBus.addSpringScanNode(bw.name(), node1);
FlowBus.addSpringScanNode(nodeId, node1);
});
context.beanBuilderAdd(LiteflowComponent.class, (clz, bw, anno) -> {
if(NodeComponent.class.isAssignableFrom(clz)) {
NodeComponent node1 = bw.raw();
String id1 = Utils.annoAlias(anno.id(), anno.value());
String name1 =Utils.annoAlias(anno.name(), id1);
String nodeId = Utils.annoAlias(anno.id(), anno.value());
node1.setNodeId(id1);
node1.setName(name1);
node1.setNodeId(nodeId);
node1.setName(anno.name());
FlowBus.addSpringScanNode(node1.getNodeId(), node1);
FlowBus.addSpringScanNode(nodeId, node1);
}else{
context.beanExtract(bw); //尝试提取 LiteflowMethod 函数
}

View File

@@ -23,7 +23,6 @@ import java.util.Set;
*/
@RunWith(SolonJUnit4ClassRunner.class)
@TestPropertySource(value = "classpath:/subflow/application-implicit.properties")
@Import(scanPackages = {"com.yomahub.liteflow.test.subflow.cmp2"})
public class ImplicitSubFlowELSpringbootTest extends BaseTest {
@Inject
private FlowExecutor flowExecutor;

View File

@@ -21,7 +21,6 @@ import org.noear.solon.test.annotation.TestPropertySource;
*/
@RunWith(SolonJUnit4ClassRunner.class)
@TestPropertySource("classpath:/subflow/application-subInDifferentConfig1.properties")
@Import(scanPackages = {"com.yomahub.liteflow.test.subflow.cmp1","com.yomahub.liteflow.test.subflow.cmp2"})
public class SubflowInDifferentConfigELSpringbootTest extends BaseTest {
@Inject
private FlowExecutor flowExecutor;

View File

@@ -19,7 +19,6 @@ import org.noear.solon.test.annotation.TestPropertySource;
*/
@RunWith(SolonJUnit4ClassRunner.class)
@TestPropertySource(value = "classpath:/subflow/application-xml.properties")
@Import(scanPackages = {"com.yomahub.liteflow.test.subflow.cmp1"})
public class SubflowXMLELSpringBootTest extends BaseTest {
@Inject
private FlowExecutor flowExecutor;

View File

@@ -19,7 +19,6 @@ import org.noear.solon.test.annotation.TestPropertySource;
*/
@RunWith(SolonJUnit4ClassRunner.class)
@TestPropertySource(value = "classpath:/subflow/application-yml.properties")
@Import(scanPackages = {"com.yomahub.liteflow.test.subflow.cmp1"})
public class SubflowYmlELSpringBootTest extends BaseTest {
@Inject
private FlowExecutor flowExecutor;

View File

@@ -1,4 +1,4 @@
package com.yomahub.liteflow.test.subflow;
package com.yomahub.liteflow.test.subflow2;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
@@ -6,7 +6,6 @@ import com.yomahub.liteflow.test.BaseTest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.noear.solon.annotation.Import;
import org.noear.solon.annotation.Inject;
import org.noear.solon.test.SolonJUnit4ClassRunner;
import org.noear.solon.test.annotation.TestPropertySource;
@@ -19,7 +18,6 @@ import org.noear.solon.test.annotation.TestPropertySource;
*/
@RunWith(SolonJUnit4ClassRunner.class)
@TestPropertySource(value = "classpath:/subflow/application-json.properties")
@Import(scanPackages = {"com.yomahub.liteflow.test.subflow.cmp1"})
public class SubflowJsonELSpringBootTest extends BaseTest {
@Inject
private FlowExecutor flowExecutor;

View File

@@ -0,0 +1,13 @@
package com.yomahub.liteflow.test.subflow2.cmp1;
import com.yomahub.liteflow.core.NodeComponent;
import org.noear.solon.annotation.Component;
@Component("a")
public class ACmp extends NodeComponent {
@Override
public void process() {
System.out.println("Acomp executed!");
}
}

View File

@@ -0,0 +1,13 @@
package com.yomahub.liteflow.test.subflow2.cmp1;
import com.yomahub.liteflow.core.NodeComponent;
import org.noear.solon.annotation.Component;
@Component("b")
public class BCmp extends NodeComponent {
@Override
public void process() {
System.out.println("Bcomp executed!");
}
}

View File

@@ -0,0 +1,13 @@
package com.yomahub.liteflow.test.subflow2.cmp1;
import com.yomahub.liteflow.core.NodeComponent;
import org.noear.solon.annotation.Component;
@Component("c")
public class CCmp extends NodeComponent {
@Override
public void process() throws Exception {
System.out.println("Ccomp executed!");
}
}

View File

@@ -0,0 +1,13 @@
package com.yomahub.liteflow.test.subflow2.cmp1;
import com.yomahub.liteflow.core.NodeComponent;
import org.noear.solon.annotation.Component;
@Component("d")
public class DCmp extends NodeComponent {
@Override
public void process() throws Exception {
System.out.println("Dcomp executed!");
}
}

View File

@@ -0,0 +1,14 @@
package com.yomahub.liteflow.test.subflow2.cmp1;
import com.yomahub.liteflow.core.NodeComponent;
import org.noear.solon.annotation.Component;
@Component("e")
public class ECmp extends NodeComponent {
@Override
public void process() throws Exception {
System.out.println("Ecomp executed!");
}
}

View File

@@ -65,7 +65,7 @@
<aspectjweaver.version>1.8.13</aspectjweaver.version>
<logback-classic.version>1.2.3</logback-classic.version>
<solon.version>1.11.7-M1</solon.version>
<solon.version>1.11.7-M2</solon.version>
<netty.version>4.1.84.Final</netty.version>
<guava.version>31.1-jre</guava.version>