From 3f453dedd9bf280ceeb514aac976fd7a9d45fdec Mon Sep 17 00:00:00 2001 From: bryan31 Date: Sat, 11 Dec 2021 20:58:45 +0800 Subject: [PATCH] =?UTF-8?q?enhancement=20#I4M3Q4=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteflow-core/pom.xml | 2 +- .../yomahub/liteflow/parser/FlowParser.java | 15 +++++-- liteflow-script-common/pom.xml | 2 +- liteflow-script-groovy/pom.xml | 2 +- liteflow-script-qlexpress/pom.xml | 2 +- liteflow-spring-boot-starter/pom.xml | 2 +- liteflow-testcase-script-groovy/pom.xml | 2 +- liteflow-testcase-script-qlexpress/pom.xml | 2 +- liteflow-testcase-springboot/pom.xml | 2 +- .../AbsoluteConfigPathSpringbootTest.java | 42 +++++++++++++++++++ .../test/absoluteConfigPath/cmp/ACmp.java | 20 +++++++++ .../test/absoluteConfigPath/cmp/BCmp.java | 21 ++++++++++ .../test/absoluteConfigPath/cmp/CCmp.java | 21 ++++++++++ .../absoluteConfigPath/application.properties | 1 + .../resources/absoluteConfigPath/flow.xml | 6 +++ liteflow-testcase-springnative/pom.xml | 2 +- pom.xml | 2 +- 17 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java create mode 100644 liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/ACmp.java create mode 100644 liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/BCmp.java create mode 100644 liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/CCmp.java create mode 100644 liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/application.properties create mode 100644 liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/flow.xml diff --git a/liteflow-core/pom.xml b/liteflow-core/pom.xml index 61bd55b94..806fcea03 100644 --- a/liteflow-core/pom.xml +++ b/liteflow-core/pom.xml @@ -9,7 +9,7 @@ com.yomahub liteflow - 2.6.6 + 2.6.6-BETA diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/FlowParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/FlowParser.java index 2485efe50..b1087ddb7 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/FlowParser.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/FlowParser.java @@ -72,10 +72,19 @@ public abstract class FlowParser { List allResource = new ArrayList<>(); for (String path : pathList) { - String locationPattern = path; - if (!locationPattern.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) { - locationPattern = ResourceUtils.CLASSPATH_URL_PREFIX + locationPattern; + String locationPattern; + + //如果path是绝对路径且这个文件存在时,我们认为这是一个本地文件路径,而并非classpath路径 + if (FileUtil.isAbsolutePath(path) && FileUtil.isFile(path)){ + locationPattern = ResourceUtils.FILE_URL_PREFIX + path; + } else { + if (!path.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) { + locationPattern = ResourceUtils.CLASSPATH_URL_PREFIX + path; + }else{ + locationPattern = path; + } } + PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); Resource[] resources = resolver.getResources(locationPattern); if (ArrayUtil.isEmpty(resources)) { diff --git a/liteflow-script-common/pom.xml b/liteflow-script-common/pom.xml index 6d30718c1..e402ee631 100644 --- a/liteflow-script-common/pom.xml +++ b/liteflow-script-common/pom.xml @@ -5,7 +5,7 @@ liteflow com.yomahub - 2.6.6 + 2.6.6-BETA 4.0.0 diff --git a/liteflow-script-groovy/pom.xml b/liteflow-script-groovy/pom.xml index e43948db7..46086fbdd 100644 --- a/liteflow-script-groovy/pom.xml +++ b/liteflow-script-groovy/pom.xml @@ -5,7 +5,7 @@ liteflow com.yomahub - 2.6.6 + 2.6.6-BETA 4.0.0 diff --git a/liteflow-script-qlexpress/pom.xml b/liteflow-script-qlexpress/pom.xml index 3df8a9be7..de326fbac 100644 --- a/liteflow-script-qlexpress/pom.xml +++ b/liteflow-script-qlexpress/pom.xml @@ -5,7 +5,7 @@ liteflow com.yomahub - 2.6.6 + 2.6.6-BETA 4.0.0 diff --git a/liteflow-spring-boot-starter/pom.xml b/liteflow-spring-boot-starter/pom.xml index bc008ba32..861a01f32 100644 --- a/liteflow-spring-boot-starter/pom.xml +++ b/liteflow-spring-boot-starter/pom.xml @@ -10,7 +10,7 @@ liteflow com.yomahub - 2.6.6 + 2.6.6-BETA diff --git a/liteflow-testcase-script-groovy/pom.xml b/liteflow-testcase-script-groovy/pom.xml index 2479fe686..81dab46de 100644 --- a/liteflow-testcase-script-groovy/pom.xml +++ b/liteflow-testcase-script-groovy/pom.xml @@ -5,7 +5,7 @@ liteflow com.yomahub - 2.6.6 + 2.6.6-BETA 4.0.0 diff --git a/liteflow-testcase-script-qlexpress/pom.xml b/liteflow-testcase-script-qlexpress/pom.xml index f84f0cedd..018be4ddb 100644 --- a/liteflow-testcase-script-qlexpress/pom.xml +++ b/liteflow-testcase-script-qlexpress/pom.xml @@ -5,7 +5,7 @@ liteflow com.yomahub - 2.6.6 + 2.6.6-BETA 4.0.0 diff --git a/liteflow-testcase-springboot/pom.xml b/liteflow-testcase-springboot/pom.xml index d2cbf56fa..faa0e8e4d 100644 --- a/liteflow-testcase-springboot/pom.xml +++ b/liteflow-testcase-springboot/pom.xml @@ -5,7 +5,7 @@ liteflow com.yomahub - 2.6.6 + 2.6.6-BETA 4.0.0 diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java new file mode 100644 index 000000000..09b6de2a0 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/AbsoluteConfigPathSpringbootTest.java @@ -0,0 +1,42 @@ +package com.yomahub.liteflow.test.absoluteConfigPath; + +import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.entity.data.DefaultSlot; +import com.yomahub.liteflow.entity.data.LiteflowResponse; +import com.yomahub.liteflow.test.BaseTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; + +/** + * springboot环境下异步线程超时日志打印测试 + * @author Bryan.Zhang + * @since 2.6.4 + */ +@RunWith(SpringRunner.class) +@TestPropertySource(value = "classpath:/absoluteConfigPath/application.properties") +@SpringBootTest(classes = AbsoluteConfigPathSpringbootTest.class) +@EnableAutoConfiguration +@ComponentScan({"com.yomahub.liteflow.test.absoluteConfigPath.cmp"}) +public class AbsoluteConfigPathSpringbootTest extends BaseTest { + + private final Logger log = LoggerFactory.getLogger(this.getClass()); + + @Resource + private FlowExecutor flowExecutor; + + @Test + public void testAbsoluteConfig() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg"); + Assert.assertTrue(response.isSuccess()); + } +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/ACmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/ACmp.java new file mode 100644 index 000000000..74091479f --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/ACmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.absoluteConfigPath.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("a") +public class ACmp extends NodeComponent { + + @Override + public void process() { + System.out.println("ACmp executed!"); + } +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/BCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/BCmp.java new file mode 100644 index 000000000..0f162d805 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/BCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.absoluteConfigPath.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("b") +public class BCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("BCmp executed!"); + } + +} diff --git a/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/CCmp.java b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/CCmp.java new file mode 100644 index 000000000..2da1ea352 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/CCmp.java @@ -0,0 +1,21 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.absoluteConfigPath.cmp; + +import com.yomahub.liteflow.core.NodeComponent; +import org.springframework.stereotype.Component; + +@Component("c") +public class CCmp extends NodeComponent { + + @Override + public void process() { + System.out.println("CCmp executed!"); + } + +} diff --git a/liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/application.properties b/liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/application.properties new file mode 100644 index 000000000..55fe91fd8 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/application.properties @@ -0,0 +1 @@ +liteflow.rule-source=/usr/local/flow.xml \ No newline at end of file diff --git a/liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/flow.xml b/liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/flow.xml new file mode 100644 index 000000000..657f64cc3 --- /dev/null +++ b/liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/flow.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/liteflow-testcase-springnative/pom.xml b/liteflow-testcase-springnative/pom.xml index 3c3fc7809..6a6d3cbbd 100644 --- a/liteflow-testcase-springnative/pom.xml +++ b/liteflow-testcase-springnative/pom.xml @@ -5,7 +5,7 @@ liteflow com.yomahub - 2.6.6 + 2.6.6-BETA 4.0.0 diff --git a/pom.xml b/pom.xml index 15e723dd6..fa8974b86 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.yomahub liteflow pom - 2.6.6 + 2.6.6-BETA liteflow a lightweight and practical micro-process framework https://github.com/bryan31/liteflow