From 95bd677dc46e46a04c435f473420c8ee9ffa2dfb Mon Sep 17 00:00:00 2001 From: zhangzhiyong Date: Thu, 21 Sep 2023 10:30:52 +0800 Subject: [PATCH] Docean-spring-starter needs to support multiple extension points (close issue #725) --- jcommon/docean-spring-starter/pom.xml | 2 +- .../spring/config/DoceanAutoConfigure.java | 22 +++++++++++-------- jcommon/pom.xml | 1 + 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/jcommon/docean-spring-starter/pom.xml b/jcommon/docean-spring-starter/pom.xml index 2cc80448f..dcc4f1173 100644 --- a/jcommon/docean-spring-starter/pom.xml +++ b/jcommon/docean-spring-starter/pom.xml @@ -6,7 +6,7 @@ run.mone jcommon - 1.4-SNAPSHOT + 1.4-jdk20-SNAPSHOT docean-spring-starter diff --git a/jcommon/docean-spring-starter/src/main/java/run/mone/docean/spring/config/DoceanAutoConfigure.java b/jcommon/docean-spring-starter/src/main/java/run/mone/docean/spring/config/DoceanAutoConfigure.java index 7807697b3..0095a0722 100644 --- a/jcommon/docean-spring-starter/src/main/java/run/mone/docean/spring/config/DoceanAutoConfigure.java +++ b/jcommon/docean-spring-starter/src/main/java/run/mone/docean/spring/config/DoceanAutoConfigure.java @@ -13,6 +13,7 @@ import javax.annotation.PostConstruct; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -38,16 +39,19 @@ public class DoceanAutoConfigure { @PostConstruct public void initConfig() { - List list = Splitter.on(":").splitToList(extensionsConfig); - if (list.size() == 3) { + List packageList = new ArrayList<>(); + Splitter.on(",").splitToList(extensionsConfig).forEach(it -> { + List list = Splitter.on(":").splitToList(extensionsConfig); extensionMap.put(list.get(0), list.get(1)); - ioc = Ioc.ins().name("extension").setContextFunction(name -> { - if (ac.containsBean(name)) { - return ac.getBean(name); - } - return Safe.callAndLog(() -> ac.getBean(Class.forName(name)), null); - }).init(list.get(2), "run.mone.docean.plugin.spring"); - } + packageList.add(list.get(2)); + }); + packageList.add("run.mone.docean.plugin.spring"); + ioc = Ioc.ins().name("extension").setContextFunction(name -> { + if (ac.containsBean(name)) { + return ac.getBean(name); + } + return Safe.callAndLog(() -> ac.getBean(Class.forName(name)), null); + }).init(packageList.toArray(new String[0])); } diff --git a/jcommon/pom.xml b/jcommon/pom.xml index f591a6520..c01170996 100644 --- a/jcommon/pom.xml +++ b/jcommon/pom.xml @@ -85,6 +85,7 @@ excel match infra-common + docean-spring-starter