- java.lang.Object
-
- io.helidon.config.mp.MpConfigSources
-
public final class MpConfigSources extends Object
Utilities for MicroProfile ConfigConfigSource
.The following methods create MicroProfile config sources to help with manual setup of Config from
ConfigProviderResolver.getBuilder()
:systemProperties()
- system properties config sourceenvironmentVariables()
- environment variables config sourcecreate(java.nio.file.Path)
- load a properties file from file systemcreate(String, java.nio.file.Path)
- load a properties file from file system with custom namecreate(java.util.Map)
- create an in-memory source from mapcreate(String, java.util.Map)
- create an in-memory source from map with custom namecreate(java.util.Properties)
- create an in-memory source from propertiescreate(String, java.util.Properties)
- create an in-memory source from properties with custom name
create(io.helidon.config.spi.ConfigSource)
- create a MicroProfile config source from Helidon SE config sourcecreate(io.helidon.config.Config)
- create a MicroProfile config source from Helidon SE Config instance
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<ConfigSource>
classPath(ClassLoader classLoader, String resource)
Find all resources on classpath and return a config source for each.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.static List<ConfigSource>
classPath(String resource)
Find all resources on classpath and return a config source for each.static List<ConfigSource>
classPath(String resource, String profile)
Find all resources on classpath and return a config source for each.static ConfigSource
create(Config config)
Config source base on a Helidon SE config instance.static ConfigSource
create(ConfigSource helidonConfigSource)
Config source based on a Helidon SE config source.static ConfigSource
create(String name, Path path)
Properties
config source based on a file on file system.static ConfigSource
create(String name, Map<String,String> theMap)
In memory config source based on the provided map.static ConfigSource
create(String name, Properties properties)
In memory config source based on the provided properties.static ConfigSource
create(URL url)
Properties
config source based on a URL.static ConfigSource
create(URL url, URL profileUrl)
Properties
config source based on a URL with a profile override.static ConfigSource
create(Path path)
Properties
config source based on a file on file system.static ConfigSource
create(Map<String,String> theMap)
In memory config source based on the provided map.static ConfigSource
create(Properties properties)
In memory config source based on the provided properties.static ConfigSource
environmentVariables()
Environment variables config source.static ConfigSource
systemProperties()
In memory config source based on system properties.
-
-
-
Method Detail
-
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 timeConfigSource.getValue(String)
is called.- Parameters:
name
- name of the sourcetheMap
- 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 timeConfigSource.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 sourcepath
- 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 timeConfigSource.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 timeConfigSource.getValue(String)
is called.- Parameters:
name
- name of the config sourceproperties
- 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 timeConfigSource.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 asmicroprofile-config-dev.properties
for dev profile.- Parameters:
resource
- resource to findprofile
- 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 resourcesresource
- 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 asmicroprofile-config-dev.properties
for dev profile.- Parameters:
classLoader
- class loader to use to locate the resourcesresource
- resource to findprofile
- 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 theConfigSource.getValue(String)
is called, the latest config version will be queried.- Parameters:
config
- Helidon SE configuration- Returns:
- a new MicroProfile Config config source
-
-