Class ConfigProviderResolver
- java.lang.Object
-
- org.eclipse.microprofile.config.spi.ConfigProviderResolver
-
public abstract class ConfigProviderResolver extends Object
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.- Author:
- Mark Struberg, Romain Manni-Bucau, Emily Jiang
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConfigProviderResolver()
Construct a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ConfigBuilder
getBuilder()
Create aConfigBuilder
instance for the current application.abstract Config
getConfig()
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.
-
-
-
Method Detail
-
getConfig
public abstract Config getConfig()
Get the configuration instance for the current application in the manner described byConfigProvider.getConfig()
.- Returns:
- the configuration instance
-
getConfig
public abstract Config getConfig(ClassLoader loader)
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
public abstract ConfigBuilder 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
public abstract void registerConfig(Config config, ClassLoader classLoader)
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
public abstract void releaseConfig(Config config)
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
public static ConfigProviderResolver 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
public static void setInstance(ConfigProviderResolver resolver)
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
-
-