Class SystemPropertiesConfigSource

java.lang.Object
cloud.opencode.base.config.source.SystemPropertiesConfigSource
All Implemented Interfaces:
ConfigSource

public class SystemPropertiesConfigSource extends Object implements ConfigSource
System Properties Configuration Source 系统属性配置源

Loads configuration from Java system properties (System.getProperties()).

从Java系统属性加载配置(System.getProperties())。

Features | 主要功能:

  • Java system properties access - Java系统属性访问
  • JVM arguments support (-Dkey=value) - JVM参数支持
  • Medium priority (50) - 中等优先级(50)

Usage Examples | 使用示例:

// Create source
ConfigSource source = new SystemPropertiesConfigSource();

// Set via JVM args
// java -Dapp.name=MyApp -Dserver.port=8080 Main

// Or programmatically
System.setProperty("app.name", "MyApp");

Performance | 性能特性:

  • Time complexity: O(n) for loading - 时间复杂度: 加载为O(n)
  • Properties snapshot at creation - 创建时的属性快照

Security | 安全性:

  • Thread-safe: Yes - 线程安全: 是
  • Immutable snapshot - 不可变快照
Since:
JDK 25, opencode-base-config V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • SystemPropertiesConfigSource

      public SystemPropertiesConfigSource()
      Create system properties config source 创建系统属性配置源
  • Method Details

    • getName

      public String getName()
      Description copied from interface: ConfigSource
      Get configuration source name 获取配置源名称
      Specified by:
      getName in interface ConfigSource
      Returns:
      source name | 源名称
    • getProperties

      public Map<String,String> getProperties()
      Description copied from interface: ConfigSource
      Get all configuration properties 获取所有配置属性

      Performance | 性能:

      This method should return a cached immutable map for best performance.

      此方法应返回缓存的不可变映射以获得最佳性能。

      Specified by:
      getProperties in interface ConfigSource
      Returns:
      configuration properties map | 配置属性映射
    • getPriority

      public int getPriority()
      Description copied from interface: ConfigSource
      Get configuration source priority (higher number = higher priority) 获取配置源优先级(数值越大优先级越高)

      Default Priorities | 默认优先级:

      • CommandLine: 200
      • Environment: 100
      • Properties/YAML: 50
      • InMemory: 10
      Specified by:
      getPriority in interface ConfigSource
      Returns:
      priority value | 优先级值