Pārlūkot izejas kodu

enhancement #I4M3Q4 支持配置绝对路径的配置文件

bryan31 3 gadi atpakaļ
vecāks
revīzija
3f453dedd9

+ 1 - 1
liteflow-core/pom.xml

@@ -9,7 +9,7 @@
     <parent>
 		<groupId>com.yomahub</groupId>
 		<artifactId>liteflow</artifactId>
-		<version>2.6.6</version>
+		<version>2.6.6-BETA</version>
 	</parent>
 
 	<dependencies>

+ 12 - 3
liteflow-core/src/main/java/com/yomahub/liteflow/parser/FlowParser.java

@@ -72,10 +72,19 @@ public abstract class FlowParser {
 
         List<Resource> 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)) {

+ 1 - 1
liteflow-script-common/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>liteflow</artifactId>
         <groupId>com.yomahub</groupId>
-        <version>2.6.6</version>
+        <version>2.6.6-BETA</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
liteflow-script-groovy/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>liteflow</artifactId>
         <groupId>com.yomahub</groupId>
-        <version>2.6.6</version>
+        <version>2.6.6-BETA</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
liteflow-script-qlexpress/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>liteflow</artifactId>
         <groupId>com.yomahub</groupId>
-        <version>2.6.6</version>
+        <version>2.6.6-BETA</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
liteflow-spring-boot-starter/pom.xml

@@ -10,7 +10,7 @@
     <parent>
         <artifactId>liteflow</artifactId>
         <groupId>com.yomahub</groupId>
-        <version>2.6.6</version>
+        <version>2.6.6-BETA</version>
     </parent>
 
     <dependencies>

+ 1 - 1
liteflow-testcase-script-groovy/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>liteflow</artifactId>
         <groupId>com.yomahub</groupId>
-        <version>2.6.6</version>
+        <version>2.6.6-BETA</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
liteflow-testcase-script-qlexpress/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>liteflow</artifactId>
         <groupId>com.yomahub</groupId>
-        <version>2.6.6</version>
+        <version>2.6.6-BETA</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
liteflow-testcase-springboot/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>liteflow</artifactId>
         <groupId>com.yomahub</groupId>
-        <version>2.6.6</version>
+        <version>2.6.6-BETA</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 42 - 0
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<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
+        Assert.assertTrue(response.isSuccess());
+    }
+}

+ 20 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/ACmp.java

@@ -0,0 +1,20 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @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!");
+	}
+}

+ 21 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/BCmp.java

@@ -0,0 +1,21 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @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!");
+	}
+
+}

+ 21 - 0
liteflow-testcase-springboot/src/test/java/com/yomahub/liteflow/test/absoluteConfigPath/cmp/CCmp.java

@@ -0,0 +1,21 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ * @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!");
+	}
+
+}

+ 1 - 0
liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/application.properties

@@ -0,0 +1 @@
+liteflow.rule-source=/usr/local/flow.xml

+ 6 - 0
liteflow-testcase-springboot/src/test/resources/absoluteConfigPath/flow.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1">
+        <when value="a,b,c"/>
+    </chain>
+</flow>

+ 1 - 1
liteflow-testcase-springnative/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>liteflow</artifactId>
         <groupId>com.yomahub</groupId>
-        <version>2.6.6</version>
+        <version>2.6.6-BETA</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
pom.xml

@@ -5,7 +5,7 @@
 	<groupId>com.yomahub</groupId>
     <artifactId>liteflow</artifactId>
     <packaging>pom</packaging>
-    <version>2.6.6</version>
+    <version>2.6.6-BETA</version>
 	<name>liteflow</name>
 	<description>a lightweight and practical micro-process framework</description>
 	<url>https://github.com/bryan31/liteflow</url>