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接口:
ConfigSourceProvider- Custom source provider - 自定义配置源提供者ConfigConverterProvider- Custom converter provider - 自定义转换器提供者ConfigSourceFactory- Source factory with URI support - 支持URI的配置源工厂
Advanced Components | 高级组件:
MultiProfileConfig- Multi-environment loading - 多环境加载TenantConfigManager- Multi-tenant management - 多租户管理EncryptedConfigProcessor- Encrypted value handling - 加密值处理HttpConfigSourceProvider- HTTP source provider - HTTP配置源提供者
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:
-
ClassDescriptionConfiguration Converter Provider SPI 配置转换器提供者SPIConfiguration Source Factory 配置源工厂Configuration Source Provider SPI 配置源提供者SPIEncrypted Configuration Processor 加密配置处理器HTTP Configuration Source Provider HTTP配置源提供者Multi-Profile Configuration Loader 多环境配置加载器Multi-Tenant Configuration Manager 多租户配置管理器