From c3f712c2e1d09307e0ea381eb3cf9981b5b3e9a8 Mon Sep 17 00:00:00 2001 From: dialYun <1552333077@qq.com> Date: Thu, 13 Feb 2025 13:06:09 +0000 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=AD=E8=8E=B7=E5=8F=96=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=A7=9F=E6=88=B7=E7=BC=93=E5=AD=98=E7=9A=84=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dialYun <1552333077@qq.com> --- .../src/main/java/io/nop/core/CoreConfigs.java | 3 +++ .../resource/tenant/ResourceTenantManager.java | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/nop-core/src/main/java/io/nop/core/CoreConfigs.java b/nop-core/src/main/java/io/nop/core/CoreConfigs.java index aa847d073..be2e11234 100644 --- a/nop-core/src/main/java/io/nop/core/CoreConfigs.java +++ b/nop-core/src/main/java/io/nop/core/CoreConfigs.java @@ -228,4 +228,7 @@ public interface CoreConfigs { @Description("开发工程的根目录,子模块全部存放在此目录下") IConfigReference CFG_DEV_ROOT_PATH = varRef(s_loc, "nop.core.dev-root-path", String.class, null); + + @Description("资源不支持租户缓存") + IConfigReference CFG_RESOURCE_NOT_SUPPORT_TENANT_CACHE = varRef(s_loc, "nop.core.resource.not-support-tenant-cache", Set.class, null); } \ No newline at end of file diff --git a/nop-core/src/main/java/io/nop/core/resource/tenant/ResourceTenantManager.java b/nop-core/src/main/java/io/nop/core/resource/tenant/ResourceTenantManager.java index 192e0d9cc..a60062e99 100644 --- a/nop-core/src/main/java/io/nop/core/resource/tenant/ResourceTenantManager.java +++ b/nop-core/src/main/java/io/nop/core/resource/tenant/ResourceTenantManager.java @@ -6,6 +6,7 @@ import io.nop.api.core.exceptions.NopException; import io.nop.api.core.util.Guard; import io.nop.commons.cache.GlobalCacheRegistry; import io.nop.commons.lang.ICreationListener; +import io.nop.commons.util.CollectionHelper; import io.nop.commons.util.StringHelper; import io.nop.core.resource.IResourceObjectLoader; import io.nop.core.resource.IResourceStore; @@ -29,6 +30,7 @@ import java.util.Set; import java.util.TreeSet; import java.util.function.Supplier; +import static io.nop.core.CoreConfigs.CFG_RESOURCE_NOT_SUPPORT_TENANT_CACHE; import static io.nop.core.CoreConfigs.CFG_TENANT_RESOURCE_DISABLED_PATHS; import static io.nop.core.CoreConfigs.CFG_TENANT_RESOURCE_ENABLED; import static io.nop.core.CoreConfigs.CFG_TENANT_RESOURCE_ENABLED_PATHS; @@ -131,8 +133,21 @@ public class ResourceTenantManager implements ITenantResourceStoreSupplier { String moduleName = ResourceHelper.getModuleName(resourcePath); if (StringHelper.isEmpty(moduleName)) return false; + // nop资源不支持租户缓存 - return !moduleName.startsWith("nop-"); + if(moduleName.startsWith("nop-")) { + return false; + } + + // 从配置中获取不支持租户缓存的资源路径 + Set setPath = CFG_RESOURCE_NOT_SUPPORT_TENANT_CACHE.get(); + if(!CollectionHelper.isEmpty(setPath)) { + for (String path : setPath) { + if (moduleName.startsWith(path)) + return false; + } + } + return true; } public Set getUsedTenants() { -- Gitee