Config.
A Config provides access to the application's configuration. It may have been automatically discovered, or
manually created and registered.
The default usage is to use getConfig() to automatically pick up the configuration for the current
thread's context class loader.
A configuration consists of information collected from the registered configuration sources, combined with the set of registered converters. The configuration sources get sorted according to their ordinal value. Thus it is possible to override a lower-priority configuration source with a higher-priority one.
It is also possible to register custom configuration sources to flexibly extend the configuration mechanism. For example, a configuration source could be provided which reads configuration values from a database table.
Example:
String restUrl = ConfigProvider.getConfig().getValue("myproject.some.remote.service.url", String.class);
Integer port = ConfigProvider.getConfig().getValue("myproject.some.remote.service.port", Integer.class);
For more advanced use cases (e.g. registering a manually created Config instance), please see
ConfigProviderResolver#registerConfig(Config, ClassLoader) and ConfigProviderResolver#getBuilder().
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Config | Returns: the configuration instance for the thread context class loaderGet the configuration corresponding to the current application, as defined by the calling thread's context class loader. |
| public static Config | Returns: the configuration instance for the given class loaderthe Classloader used to register the configuration instance cl)Get the configuration for the application corresponding to the given class loader instance. |
| ConfigProvider | back to summary |
|---|---|
| private ConfigProvider() | |
| getConfig | back to summary |
|---|---|
| public static Config getConfig() Get the configuration corresponding to the current application, as defined by the calling thread's context class loader.
The Each class loader corresponds to exactly one configuration.
| |
| getConfig | back to summary |
|---|---|
| public static Config getConfig(ClassLoader cl) Get the configuration for the application corresponding to the given class loader instance.
The Each class loader corresponds to exactly one configuration.
| |