Package com.helger.config
Class ConfigFactory
java.lang.Object
com.helger.config.ConfigFactory
Factory for creating
IConfig objects.- Author:
- Philip Helger
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic com.helger.io.resourceprovider.ReadableResourceProviderChainCreate a configuration value provider, with the following configuration sources: Query system properties - names are takes "as are" - priority 400. Environment variables.Create a configuration value provider, with the following configuration sources: Query system properties - names are takes "as are" - priority 400. Environment variables.static IConfigGet the defaultIConfiginstance.static IConfigGet a specialIConfiginstance that is only intended to be used to setup other config instances.
-
Field Details
-
PRIVATE_APPLICATION_PROPERTIES_NAME
- See Also:
-
PRIVATE_APPLICATION_PROPERTIES_PRIORITY
public static final int PRIVATE_APPLICATION_PROPERTIES_PRIORITY -
APPLICATION_PROPERTIES_NAME
- See Also:
-
APPLICATION_PROPERTIES_PRIORITY
public static final int APPLICATION_PROPERTIES_PRIORITY -
REFERENCE_PROPERTIES_NAME
- See Also:
-
REFERENCE_PROPERTIES_PRIORITY
public static final int REFERENCE_PROPERTIES_PRIORITY- See Also:
-
-
Method Details
-
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
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
ReadableResourceProviderChainused to resolve resource based configuration items. - Since:
- 9.4.8
-
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.resourceexists and it points to an existing classpath resource, the first one matching is used - priority 200 or determined by system propertyconfig.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 propertyconfig.resources.priority(also see the "s") (since v9.4.5) - If a system property
config.fileexists and it points to an existing file, it is used - priority 200 or determined by system propertyconfig.file.priority(since v9.4.5) - If a system property
config.urlexists and it points to an existing URL, it is used - priority 200 or determined by system propertyconfig.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.jsonare looked up on the classpath (only!). All of them share priority 185 - Than all instances of
application.propertiesare looked up on the classpath (only!). All of them share priority 180 - Than all instances of
reference.propertiesare 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
Get a specialIConfiginstance that is only intended to be used to setup other config instances. Usually you are looking forgetDefaultConfig().- Returns:
- The system configuration to be used. Never
null. - Since:
- 9.4.5
- See Also:
-
getDefaultConfig
Get the defaultIConfiginstance. This call has linear effort. SeecreateDefaultValueProvider()on the resolutions that are attempted.- Returns:
- The default configuration to be used. Never
null. - See Also:
-