From 32e24769b0875cfdb5ce05ceee25b7812ff7ec7c Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Fri, 3 Feb 2023 11:32:08 +0800 Subject: [PATCH] =?UTF-8?q?feat=20#I6BDLN=20=E8=A7=A3=E6=9E=90=E5=99=A8?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E8=A7=A3=E6=9E=90=E5=99=A8=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/spi/local/LocalPathContentParser.java | 9 +++++++-- .../liteflow/spi/solon/SolonPathContentParser.java | 11 ++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java index 5dc0bf808..d8d34d5ad 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java @@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.resource.ClassPathResource; import cn.hutool.core.io.resource.FileResource; import cn.hutool.core.io.resource.ResourceUtil; +import cn.hutool.core.util.ClassLoaderUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.exception.ConfigErrorException; import com.yomahub.liteflow.spi.PathContentParser; @@ -52,13 +53,17 @@ public class LocalPathContentParser implements PathContentParser { List result = new ArrayList<>(); for (String path : pathList) { - if (FileUtil.isAbsolutePath(path) && FileUtil.isFile(path)) { + if (FileUtil.isAbsolutePath(path) && FileUtil.isFile(path)) { path = FILE_URL_PREFIX + path; result.add(new FileResource(path).getFile().getAbsolutePath()); } else { if (!path.startsWith(CLASSPATH_URL_PREFIX)) { path = CLASSPATH_URL_PREFIX + path; - result.add(new ClassPathResource(path).getAbsolutePath()); + + // 这里会有自定义解析器 + if(ClassLoaderUtil.isPresent(path)){ + result.add(new ClassPathResource(path).getAbsolutePath()); + } } } } diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonPathContentParser.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonPathContentParser.java index fa14632a3..e25dbe9ae 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonPathContentParser.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonPathContentParser.java @@ -39,7 +39,10 @@ public class SolonPathContentParser implements PathContentParser { @Override public List getFileAbsolutePath(List pathList) throws Exception { List allResource = getUrls(pathList); - return StreamUtil.of(allResource).map(URL::getPath).collect(Collectors.toList()); + return StreamUtil.of(allResource) + .map(URL::getPath) + .filter(FileUtil::isFile) + .collect(Collectors.toList()); } private static List getUrls(List pathList) throws MalformedURLException { @@ -57,14 +60,16 @@ public class SolonPathContentParser implements PathContentParser { path = path.substring(ResourceUtils.CLASSPATH_URL_PREFIX.length()); } - allResource.add(Utils.getResource(path)); + if (Utils.getResource(path) != null) { + allResource.add(Utils.getResource(path)); + } } } //如果有多个资源,检查资源都是同一个类型,如果出现不同类型的配置,则抛出错误提示 Set fileTypeSet = new HashSet<>(); allResource.forEach(resource -> fileTypeSet.add(FileUtil.extName(resource.getPath()))); - if (fileTypeSet.size() != 1) { + if (fileTypeSet.size() > 1) { throw new ConfigErrorException("config error,please use the same type of configuration"); } return allResource;