Package cloud.opencode.base.config.advanced


package cloud.opencode.base.config.advanced
Advanced Features and SPI Extension Package 高级功能和SPI扩展包

This package provides advanced configuration features and SPI extension points for custom implementations.

此包提供高级配置功能和用于自定义实现的SPI扩展点。

Features | 主要功能:

  • Configuration source SPI - 配置源SPI
  • Type converter SPI - 类型转换器SPI
  • Multi-profile configuration - 多环境配置
  • Multi-tenant configuration - 多租户配置
  • Encrypted configuration - 加密配置
  • Remote configuration sources - 远程配置源

SPI Interfaces | SPI接口:

Advanced Components | 高级组件:

URI Formats | URI格式:

file:/path/to/config.properties   - File system
classpath:application.properties  - Classpath
env:APP_                          - Environment variables with prefix
http://config-server/config       - Remote HTTP (via SPI)
consul://localhost:8500/myapp     - Consul (via SPI)

SPI Registration Example | SPI注册示例:

# META-INF/services/cloud.opencode.base.config.advanced.ConfigSourceProvider
com.example.ConsulConfigSourceProvider
com.example.RedisConfigSourceProvider

Multi-Profile Example | 多环境示例:

Config config = MultiProfileConfig.load(args);
// Loads: application.properties → application-{profile}.properties
// Profile from: APP_PROFILE env var or app.profile system property

Encrypted Config Example | 加密配置示例:

// application.properties
database.password=ENC(base64EncodedEncryptedValue)

// Usage
SecretKey key = loadSecretKey();
Config config = EncryptedConfigProcessor.createEncryptedConfig(
    OpenConfig.getGlobal(), key);
String password = config.getString("database.password"); // Auto-decrypted
Since:
JDK 25, opencode-base-config V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also: