Class ConfigProviderResolver
java.lang.Object
org.eclipse.microprofile.config.spi.ConfigProviderResolver
The service provider for implementations of the MicroProfile Configuration specification.
This class is not intended to be used by end-users.
The implementation of this class should register itself via the ServiceLoader
mechanism.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract ConfigBuilder
Create aConfigBuilder
instance for the current application.abstract Config
Get the configuration instance for the current application in the manner described byConfigProvider.getConfig()
.abstract Config
getConfig
(ClassLoader loader) Get the configuration instance for the current application in the manner described byConfigProvider.getConfig(ClassLoader)
.static ConfigProviderResolver
instance()
Find and return the provider resolver instance.abstract void
registerConfig
(Config config, ClassLoader classLoader) Register the givenConfig
instance to the application identified by the given class loader.abstract void
releaseConfig
(Config config) AConfig
normally gets released if the Application it is associated with gets destroyed.static void
setInstance
(ConfigProviderResolver resolver) Set the instance.
-
Constructor Details
-
ConfigProviderResolver
protected ConfigProviderResolver()Construct a new instance.
-
-
Method Details
-
getConfig
Get the configuration instance for the current application in the manner described byConfigProvider.getConfig()
.- Returns:
- the configuration instance
-
getConfig
Get the configuration instance for the current application in the manner described byConfigProvider.getConfig(ClassLoader)
.- Parameters:
loader
- the class loader identifying the application- Returns:
- the configuration instance
-
getBuilder
Create aConfigBuilder
instance for the current application.The returned configuration builder must initially contain no registered configuration sources.
The returned configuration builder must initially contain only built in converters.
- Returns:
- a new configuration builder instance
-
registerConfig
Register the givenConfig
instance to the application identified by the given class loader. If the class loader isnull
, then the current application (as identified by the thread context class loader) will be used.- Parameters:
config
- the configuration to registerclassLoader
- the class loader identifying the application- Throws:
IllegalStateException
- if there is already a configuration registered for the application
-
releaseConfig
AConfig
normally gets released if the Application it is associated with gets destroyed. Invoke this method if you like to destroy the Config prematurely. If the given Config is associated within an Application then it will be unregistered.- Parameters:
config
- the config to be released
-
instance
Find and return the provider resolver instance. If the provider resolver instance was already found, or was manually specified, that instance is returned. Otherwise,ServiceLoader
is used to locate the first implementation that is visible from the class loader that defined this class.- Returns:
- the provider resolver instance
-
setInstance
Set the instance. It is used by OSGi environments that do not support the service loader pattern.Note that calling this method after a different provider instance was already retrieved can lead to inconsistent results. Mixing usage of this method with the service loader pattern is for this reason strongly discouraged.
- Parameters:
resolver
- the instance to set, ornull
to unset the instance
-