Package org.eclipse.microprofile.config.spi

# 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

Modifier and Type
Method
Description
`abstract ConfigBuilder`
`getBuilder()`
Create a `ConfigBuilder` instance for the current application.
`abstract Config`
`getConfig()`
Get the configuration instance for the current application in the manner described by `ConfigProvider.getConfig()`.
`abstract Config`
`getConfig(ClassLoader loader)`
Get the configuration instance for the current application in the manner described by `ConfigProvider.getConfig(ClassLoader)`.
`static ConfigProviderResolver`
`instance()`
Find and return the provider resolver instance.
`abstract void`
`registerConfig(Config config, ClassLoader classLoader)`
Register the given `Config` instance to the application identified by the given class loader.
`abstract void`
`releaseConfig(Config config)`
A `Config` normally gets released if the Application it is associated with gets destroyed.
`static void`
`setInstance(ConfigProviderResolver resolver)`
Set the instance.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ConfigProviderResolver

protected ConfigProviderResolver()
Construct a new instance.

## Method Details

### getConfig

public abstract Config getConfig()
Get the configuration instance for the current application in the manner described by `ConfigProvider.getConfig()`.

Returns:
  the configuration instance

### getConfig

public abstract Config getConfig(ClassLoader loader)
Get the configuration instance for the current application in the manner described by `ConfigProvider.getConfig(ClassLoader)`.

Parameters:
  `loader` - the class loader identifying the application
Returns:
  the configuration instance

### getBuilder

public abstract ConfigBuilder getBuilder()
Create a `ConfigBuilder` 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 given `Config` instance to the application identified by the given class loader. If the class loader is `null`, then the current application (as identified by the thread context class loader) will be used.

Parameters:
  `config` - the configuration to register
  `classLoader` - 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)
A `Config` 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, or `null` to unset the instance