Class TenantConfigManager

java.lang.Object
cloud.opencode.base.config.advanced.TenantConfigManager

public class TenantConfigManager extends Object
Multi-Tenant Configuration Manager 多租户配置管理器

Manages configuration for multiple tenants with inheritance from base configuration. Each tenant can have its own configuration that overrides the base configuration.

管理多租户配置,支持从基础配置继承。每个租户可以有自己的配置覆盖基础配置。

Features | 主要功能:

  • Tenant-specific configuration - 租户特定配置
  • Base configuration inheritance - 基础配置继承
  • Lazy loading per tenant - 每个租户的懒加载
  • Thread-safe tenant cache - 线程安全的租户缓存

Usage Examples | 使用示例:

TenantConfigManager manager = new TenantConfigManager(OpenConfig.getGlobal());

// Get tenant-specific configuration
Config tenantConfig = manager.getConfig("tenant-123");
String apiKey = tenantConfig.getString("api.key");

// Or directly get typed value
String apiKey = manager.get("tenant-123", "api.key", String.class);

Security | 安全性:

  • Thread-safe: Yes - 线程安全: 是
  • Tenant isolation: Configuration level - 租户隔离: 配置级别
Since:
JDK 25, opencode-base-config V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • TenantConfigManager

      public TenantConfigManager(Config baseConfig)
      Create tenant config manager with base configuration 使用基础配置创建租户配置管理器
      Parameters:
      baseConfig - base configuration | 基础配置
  • Method Details

    • getConfig

      public Config getConfig(String tenantId)
      Get configuration for tenant 获取租户的配置

      Loads tenant-specific configuration from classpath and merges with base configuration.

      从类路径加载租户特定配置并与基础配置合并。

      Parameters:
      tenantId - tenant identifier | 租户标识符
      Returns:
      tenant configuration | 租户配置
    • get

      public <T> T get(String tenantId, String key, Class<T> type)
      Get typed configuration value for tenant 获取租户的类型化配置值
      Type Parameters:
      T - value type | 值类型
      Parameters:
      tenantId - tenant identifier | 租户标识符
      key - configuration key | 配置键
      type - value type class | 值类型类
      Returns:
      configuration value | 配置值
    • clearCache

      public void clearCache(String tenantId)
      Clear cached configuration for tenant 清除租户的缓存配置
      Parameters:
      tenantId - tenant identifier | 租户标识符
    • clearAllCaches

      public void clearAllCaches()
      Clear all cached configurations 清除所有缓存配置