Class ConfigFactory

java.lang.Object
com.helger.config.ConfigFactory

@Immutable public final class ConfigFactory extends Object
Factory for creating IConfig objects.
Author:
Philip Helger
  • Field Details

    • PRIVATE_APPLICATION_PROPERTIES_NAME

      public static final String PRIVATE_APPLICATION_PROPERTIES_NAME
      See Also:
    • PRIVATE_APPLICATION_PROPERTIES_PRIORITY

      public static final int PRIVATE_APPLICATION_PROPERTIES_PRIORITY
    • APPLICATION_PROPERTIES_NAME

      public static final String APPLICATION_PROPERTIES_NAME
      See Also:
    • APPLICATION_PROPERTIES_PRIORITY

      public static final int APPLICATION_PROPERTIES_PRIORITY
    • REFERENCE_PROPERTIES_NAME

      public static final String REFERENCE_PROPERTIES_NAME
      See Also:
    • REFERENCE_PROPERTIES_PRIORITY

      public static final int REFERENCE_PROPERTIES_PRIORITY
      See Also:
  • Method Details

    • createValueProviderSystemOnly

      @Nonnull public static MultiConfigurationValueProvider createValueProviderSystemOnly()
      Create a configuration value provider, with the following configuration sources:
      • Query system properties - names are takes "as are" - priority 400.
      • Environment variables. All non-alphanumeric characters are replaced with underscores. So e.g. the property 'a.b' resolves to the environment variable "A_B" - priority 300
      Usually this is not what you are looking for but createDefaultValueProvider()
      Returns:
      A new value provider. Never null.
      Since:
      9.4.5
      See Also:
    • createDefaultResourceProviderChain

      @Nonnull public static com.helger.io.resourceprovider.ReadableResourceProviderChain createDefaultResourceProviderChain()
      Returns:
      A new instance of ReadableResourceProviderChain used to resolve resource based configuration items.
      Since:
      9.4.8
    • createDefaultValueProvider

      @Nonnull public static MultiConfigurationValueProvider createDefaultValueProvider()
      Create a configuration value provider, with the following configuration sources:
      • Query system properties - names are takes "as are" - priority 400.
      • Environment variables. All non-alphanumeric characters are replaced with underscores. So e.g. the property 'a.b' resolves to the environment variable "A_B" - priority 300
      • If a system property config.resource exists and it points to an existing classpath resource, the first one matching is used - priority 200 or determined by system property config.resource.priority (since v9.4.5)
      • If a system property config.resources (note the trailing "s") exists and it points to an existing classpath resource, all matching ones are used - priority 200 or determined by system property config.resources.priority (also see the "s") (since v9.4.5)
      • If a system property config.file exists and it points to an existing file, it is used - priority 200 or determined by system property config.file.priority (since v9.4.5)
      • If a system property config.url exists and it points to an existing URL, it is used - priority 200 or determined by system property config.url.priority (since v9.4.5)
      • A file or classpath entry with the name private-application.json - priority 195
      • A file or classpath entry with the name private-application.properties - priority 190
      • Than all instances of application.json are looked up on the classpath (only!). All of them share priority 185
      • Than all instances of application.properties are looked up on the classpath (only!). All of them share priority 180
      • Than all instances of reference.properties are looked up on the classpath (only!). All of them share priority 1

      Note: the default configuration does NOT contain any custom configuration files.

      Note: JSON and Properties files are expected to be UTF-8 encoded.

      Returns:
      A new value provider. Never null.
    • getSystemConfig

      @Nonnull public static IConfig getSystemConfig()
      Get a special IConfig instance that is only intended to be used to setup other config instances. Usually you are looking for getDefaultConfig().
      Returns:
      The system configuration to be used. Never null.
      Since:
      9.4.5
      See Also:
    • getDefaultConfig

      @Nonnull public static IConfig getDefaultConfig()
      Get the default IConfig instance. This call has linear effort. See createDefaultValueProvider() on the resolutions that are attempted.
      Returns:
      The default configuration to be used. Never null.
      See Also: