From e4cd09b716f68992986272f3daa6e6ac87816562 Mon Sep 17 00:00:00 2001 From: yuanyuan Date: Tue, 24 Sep 2024 17:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4biz=E5=8F=AF=E8=A7=81?= =?UTF-8?q?=E5=85=A8=E9=83=A8plugins=EF=BC=8Csofa.ark.biz.specify.dependen?= =?UTF-8?q?t.plugins.enable=3Dtrue=E6=97=B6=EF=BC=8C=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E5=8F=AF=E8=A7=81=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/biz/BizFactoryServiceImpl.java | 16 ++++++++-------- .../service/biz/BizFactoryServiceTest.java | 1 - .../java/com/alipay/sofa/ark/api/ArkConfigs.java | 4 ++-- .../alipay/sofa/ark/spi/constant/Constants.java | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/service/biz/BizFactoryServiceImpl.java b/sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/service/biz/BizFactoryServiceImpl.java index b380ca77a..399b51aa7 100644 --- a/sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/service/biz/BizFactoryServiceImpl.java +++ b/sofa-ark-parent/core-impl/container/src/main/java/com/alipay/sofa/ark/container/service/biz/BizFactoryServiceImpl.java @@ -37,11 +37,9 @@ import com.alipay.sofa.ark.spi.service.plugin.PluginManagerService; import com.google.inject.Inject; import com.google.inject.Singleton; -import org.codehaus.plexus.util.CollectionUtils; import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; @@ -216,13 +214,15 @@ private URL[] getMergedBizClassPath(URL[] bizArchiveUrls, URL[] extensionUrls) { private void resolveExportMapIfNecessary(BizModel bizModel, List dependentPlugins) { Set plugins = new HashSet<>(); - if (ArkConfigs.areAllPluginsVisibleForBiz()) { - plugins.addAll(pluginManagerService.getPluginsInOrder()); - } else if (dependentPlugins != null && !dependentPlugins.isEmpty()) { - for (String pluginName : dependentPlugins) { - Plugin plugin = pluginManagerService.getPluginByName(pluginName); - plugins.add(plugin); + if (ArkConfigs.isBizSpecifyDependentPluginsEnable()) { + if (dependentPlugins != null && !dependentPlugins.isEmpty()) { + for (String pluginName : dependentPlugins) { + Plugin plugin = pluginManagerService.getPluginByName(pluginName); + plugins.add(plugin); + } } + } else { + plugins.addAll(pluginManagerService.getPluginsInOrder()); } bizModel.setDependentPlugins(plugins); diff --git a/sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/service/biz/BizFactoryServiceTest.java b/sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/service/biz/BizFactoryServiceTest.java index 7a6d5c520..9294009c5 100644 --- a/sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/service/biz/BizFactoryServiceTest.java +++ b/sofa-ark-parent/core-impl/container/src/test/java/com/alipay/sofa/ark/container/service/biz/BizFactoryServiceTest.java @@ -68,7 +68,6 @@ public void test() throws Throwable { Plugin plugin = pluginFactoryService.createPlugin(FileUtils.file(samplePlugin.getFile())); pluginManagerService.registerPlugin(plugin); - System.setProperty(ALL_PLUGINS_VISIBLE_FOR_BIZ, Boolean.TRUE.toString()); URL sampleBiz = cl.getResource("sample-biz.jar"); Biz biz = bizFactoryService.createBiz(FileUtils.file(sampleBiz.getFile())); bizManagerService.registerBiz(biz); diff --git a/sofa-ark-parent/core/api/src/main/java/com/alipay/sofa/ark/api/ArkConfigs.java b/sofa-ark-parent/core/api/src/main/java/com/alipay/sofa/ark/api/ArkConfigs.java index 8de566b67..3c2f26b73 100644 --- a/sofa-ark-parent/core/api/src/main/java/com/alipay/sofa/ark/api/ArkConfigs.java +++ b/sofa-ark-parent/core/api/src/main/java/com/alipay/sofa/ark/api/ArkConfigs.java @@ -168,7 +168,7 @@ public static void setEmbedStaticBizEnable(boolean enable) { System.setProperty(Constants.EMBED_STATIC_BIZ_ENABLE, enable ? "true" : "false"); } - public static boolean areAllPluginsVisibleForBiz() { - return Boolean.getBoolean(Constants.ALL_PLUGINS_VISIBLE_FOR_BIZ); + public static boolean isBizSpecifyDependentPluginsEnable() { + return Boolean.getBoolean(Constants.BIZ_SPECIFY_DEPENDENT_PLUGINS_ENABLE); } } \ No newline at end of file diff --git a/sofa-ark-parent/core/spi/src/main/java/com/alipay/sofa/ark/spi/constant/Constants.java b/sofa-ark-parent/core/spi/src/main/java/com/alipay/sofa/ark/spi/constant/Constants.java index 8eacc8099..73b15497d 100644 --- a/sofa-ark-parent/core/spi/src/main/java/com/alipay/sofa/ark/spi/constant/Constants.java +++ b/sofa-ark-parent/core/spi/src/main/java/com/alipay/sofa/ark/spi/constant/Constants.java @@ -204,7 +204,7 @@ public class Constants { public final static String EMBED_STATIC_BIZ_IN_RESOURCE_ENABLE = "sofa.ark.embed.static.biz.in.resource.enable"; public final static String ACTIVATE_NEW_MODULE = "activate.new.module"; public final static String PLUGIN_CLASS_ISOLATION_ENABLE = "sofa.ark.plugin.class.isolation.enable"; - public final static String ALL_PLUGINS_VISIBLE_FOR_BIZ = "sofa.ark.all.plugins.visible.for.biz"; + public final static String BIZ_SPECIFY_DEPENDENT_PLUGINS_ENABLE = "sofa.ark.biz.specify.dependent.plugins.enable"; public final static String AUTO_UNINSTALL_WHEN_FAILED_ENABLE = "sofa.ark.auto.uninstall.when.failed.enable";