Class ConfigProviderResolver

  • public abstract class ConfigProviderResolver
    extends java.lang.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 Detail

      • ConfigProviderResolver

        protected ConfigProviderResolver()
        Construct a new instance.
    • Method Detail

      • getConfig

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

        public abstract Config getConfig​(java.lang.ClassLoader loader)
        Get the configuration instance for the current application in the manner described by ConfigProvider.getConfig(ClassLoader).
        loader - the class loader identifying the application
        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.

        a new configuration builder instance
      • registerConfig

        public abstract void registerConfig​(Config config,
                                            java.lang.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.
        config - the configuration to register
        classLoader - the class loader identifying the application
        java.lang.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.
        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.
        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.

        resolver - the instance to set, or null to unset the instance