java.lang.Object
io.helidon.config.mp.MpConfigSources
Utilities for MicroProfile Config
ConfigSource
.
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
Modifier and TypeMethodDescriptionstatic 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> Find all resources on classpath and return a config source for each.static List
<ConfigSource> Find all resources on classpath and return a config source for each.static ConfigSource
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
Config source base on a Reader instance for the given type.static ConfigSource
Config source base on a URL for the given type.static ConfigSource
Properties
config source based on a file on file system.static ConfigSource
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
Properties
config source based on a URL.static ConfigSource
Properties
config source based on a URL with a profile override.static ConfigSource
Properties
config source based on a file on file system.static ConfigSource
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
Environment variables config source.static ConfigSource
In memory config source based on system properties.
-
Method Details
-
create
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
-
create
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
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
-