Package cloud.opencode.base.config
package cloud.opencode.base.config
Configuration Management Core Package
配置管理核心包
This package provides unified configuration management capabilities including multi-source configuration loading, type-safe access, hot reload, and configuration binding.
此包提供统一的配置管理能力,包括多配置源加载、类型安全访问、热更新和配置绑定。
Features | 主要功能:
- Multi-source configuration: Properties, YAML, Environment, System Properties, Command Line - 多配置源: Properties、YAML、环境变量、系统属性、命令行
- Priority-based source merging - 基于优先级的配置源合并
- Type-safe configuration retrieval with 30+ built-in converters - 内置30+转换器的类型安全配置读取
- Placeholder resolution (${key} syntax) - 占位符解析 (${key} 语法)
- Hot reload with file change monitoring - 文件变更监听的热更新
- Configuration validation - 配置验证
- Record and POJO binding - Record和POJO绑定
Architecture | 架构概览:
┌─────────────────────────────────────────────────────────────────┐
│ Application Layer │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ OpenConfig Facade │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ get/bind │ │ Listeners │ │ Placeholder ${key} │ │
│ └─────────────┘ └─────────────┘ └─────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
┌───────────────────────┼───────────────────────┐
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Converters │ │ ConfigBinder │ │ Validators │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Quick Start | 快速开始:
// Use default configuration
String dbUrl = OpenConfig.getString("database.url");
int port = OpenConfig.getInt("server.port", 8080);
// Build custom configuration
Config config = OpenConfig.builder()
.addClasspathResource("application.properties")
.addEnvironmentVariables()
.addSystemProperties()
.enableHotReload()
.build();
Package Structure | 包结构:
cloud.opencode.base.config.source- Configuration sources - 配置源cloud.opencode.base.config.converter- Type converters - 类型转换器cloud.opencode.base.config.bind- Configuration binding - 配置绑定cloud.opencode.base.config.validation- Configuration validation - 配置验证cloud.opencode.base.config.placeholder- Placeholder resolution - 占位符解析cloud.opencode.base.config.jdk25- JDK 25 enhanced features - JDK 25增强特性cloud.opencode.base.config.advanced- Advanced features and SPI - 高级功能和SPI
Thread Safety | 线程安全:
- All public APIs are thread-safe - 所有公开API都是线程安全的
- Configuration snapshots are immutable - 配置快照不可变
- Hot reload uses atomic reference switching - 热更新使用原子引用切换
- Since:
- JDK 25, opencode-base-config V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
ClassDescriptionUnified Configuration Access Interface 统一配置访问接口Configuration Builder 配置构建器Configuration Change Event 配置变更事件Configuration Change Type 配置变更类型Configuration Change Type Enumeration 配置变更类型枚举Configuration Change Listener 配置变更监听器Global Configuration Manager Facade 全局配置管理器门面Configuration Component Exception 配置组件异常