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.

  • 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