Class MpConfigSources

java.lang.Object
io.helidon.config.mp.MpConfigSources

public final class MpConfigSources extends Object
Utilities for MicroProfile Config ConfigSource.

The following methods create MicroProfile config sources to help with manual setup of Config from ConfigProviderResolver.getBuilder():

The following methods add integration with Helidon SE Config:
  • Method Details

    • create

      public static ConfigSource create(String name, Map<String,String> theMap)
      In memory config source based on the provided map. The config source queries the map each time ConfigSource.getValue(String) is called.
      Parameters:
      name - name of the source
      theMap - map serving as configuration data
      Returns:
      a new config source
    • create

      public static ConfigSource create(Map<String,String> theMap)
      In memory config source based on the provided map. The config source queries the map each time ConfigSource.getValue(String) is called.
      Parameters:
      theMap - map serving as configuration data
      Returns:
      a new config source
    • create

      public static ConfigSource create(Path path)
      Properties config source based on a file on file system. The file is read just once, when the source is created and further changes to the underlying file are ignored.
      Parameters:
      path - path of the properties file on the file system
      Returns:
      a new config source
    • create

      public static ConfigSource create(URL url)
      Properties config source based on a URL. The URL is read just once, when the source is created and further changes to the underlying resource are ignored.
      Parameters:
      url - url of the properties file (any URL scheme supported by JVM can be used)
      Returns:
      a new config source
    • create

      public static ConfigSource create(URL url, URL profileUrl)
      Properties config source based on a URL with a profile override. The URL is read just once, when the source is created and further changes to the underlying resource are ignored.
      Parameters:
      url - url of the properties file (any URL scheme supported by JVM can be used)
      profileUrl - url of the properties file of profile specific configuration
      Returns:
      a new config source
    • create

      public static ConfigSource create(String name, Path path)
      Properties config source based on a file on file system. The file is read just once, when the source is created and further changes to the underlying file are ignored.
      Parameters:
      name - name of the config source
      path - path of the properties file on the file system
      Returns:
      a new config source
    • create

      public static ConfigSource create(Properties properties)
      In memory config source based on the provided properties. The config source queries the properties each time ConfigSource.getValue(String) is called.
      Parameters:
      properties - serving as configuration data
      Returns:
      a new config source
    • create

      public static ConfigSource create(String name, Properties properties)
      In memory config source based on the provided properties. The config source queries the properties each time ConfigSource.getValue(String) is called.
      Parameters:
      name - name of the config source
      properties - serving as configuration data
      Returns:
      a new config source
    • environmentVariables

      public static ConfigSource environmentVariables()
      Environment variables config source. This source takes care of replacement of properties by environment variables as defined in MicroProfile Config specification. This config source is immutable and caching.
      Returns:
      a new config source
    • systemProperties

      public static ConfigSource systemProperties()
      In memory config source based on system properties. The config source queries the properties each time ConfigSource.getValue(String) is called.
      Returns:
      a new config source
    • classPath

      public static List<ConfigSource> classPath(String resource)
      Find all resources on classpath and return a config source for each. Order is kept as provided by class loader.
      Parameters:
      resource - resource to find
      Returns:
      a config source for each resource on classpath, empty if none found
    • classPath

      public static List<ConfigSource> classPath(String resource, String profile)
      Find all resources on classpath and return a config source for each. Order is kept as provided by class loader. The profile will be used to locate a source with -${profile} name, such as microprofile-config-dev.properties for dev profile.
      Parameters:
      resource - resource to find
      profile - configuration profile to use, must not be null
      Returns:
      a config source for each resource on classpath, empty if none found
    • classPath

      public static List<ConfigSource> classPath(ClassLoader classLoader, String resource)
      Find all resources on classpath and return a config source for each. Order is kept as provided by class loader.
      Parameters:
      classLoader - class loader to use to locate the resources
      resource - resource to find
      Returns:
      a config source for each resource on classpath, empty if none found
    • classPath

      public static List<ConfigSource> classPath(ClassLoader classLoader, String resource, String profile)
      Find all resources on classpath and return a config source for each with a profile. Order is kept as provided by class loader. The profile will be used to locate a source with -${profile} name, such as microprofile-config-dev.properties for dev profile.
      Parameters:
      classLoader - class loader to use to locate the resources
      resource - resource to find
      profile - configuration profile to use, must not be null
      Returns:
      a config source for each resource on classpath, empty if none found
    • create

      public static ConfigSource create(ConfigSource helidonConfigSource)
      Config source based on a Helidon SE config source. This is to support Helidon SE features in Helidon MP. The config source will be immutable regardless of configured polling strategy or change watchers.
      Parameters:
      helidonConfigSource - config source to use
      Returns:
      a new MicroProfile Config config source
    • create

      public static ConfigSource create(Config config)
      Config source base on a Helidon SE config instance. This is to support advanced Helidon SE features in Helidon MP. The config source will be mutable if the config uses polling strategy and/or change watchers. Each time the ConfigSource.getValue(String) is called, the latest config version will be queried.
      Parameters:
      config - Helidon SE configuration
      Returns:
      a new MicroProfile Config config source
    • create

      public static ConfigSource create(String type, Reader reader)
      Config source base on a Reader instance for the given type. This method will not close the reader.
      Parameters:
      type - of the given reader (properties, YAML, etc).
      reader - with the configuration.
      Returns:
      a new MicroProfile config source
    • create

      public static ConfigSource create(String type, URL url)
      Config source base on a URL for the given type. This method will not close the reader.
      Parameters:
      type - of the given URL (properties, YAML, etc).
      url - with resource.
      Returns:
      a new MicroProfile config source