- 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<org.eclipse.microprofile.config.spi.ConfigSource>classPath(ClassLoader classLoader, String resource)Find all resources on classpath and return a config source for each.static List<org.eclipse.microprofile.config.spi.ConfigSource>classPath(String resource)Find all resources on classpath and return a config source for each.static org.eclipse.microprofile.config.spi.ConfigSourcecreate(Config config)Config source base on a Helidon SE config instance.static org.eclipse.microprofile.config.spi.ConfigSourcecreate(ConfigSource helidonConfigSource)Config source based on a Helidon SE config source.static org.eclipse.microprofile.config.spi.ConfigSourcecreate(String name, Path path)Propertiesconfig source based on a file on file system.static org.eclipse.microprofile.config.spi.ConfigSourcecreate(String name, Map<String,String> theMap)In memory config source based on the provided map.static org.eclipse.microprofile.config.spi.ConfigSourcecreate(String name, Properties properties)In memory config source based on the provided properties.static org.eclipse.microprofile.config.spi.ConfigSourcecreate(URL url)Propertiesconfig source based on a URL.static org.eclipse.microprofile.config.spi.ConfigSourcecreate(Path path)Propertiesconfig source based on a file on file system.static org.eclipse.microprofile.config.spi.ConfigSourcecreate(Map<String,String> theMap)In memory config source based on the provided map.static org.eclipse.microprofile.config.spi.ConfigSourcecreate(Properties properties)In memory config source based on the provided properties.static org.eclipse.microprofile.config.spi.ConfigSourceenvironmentVariables()Environment variables config source.static org.eclipse.microprofile.config.spi.ConfigSourcesystemProperties()In memory config source based on system properties.
-
-
-
Method Detail
-
create
public static org.eclipse.microprofile.config.spi.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 org.eclipse.microprofile.config.spi.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 org.eclipse.microprofile.config.spi.ConfigSource create(Path path)
Propertiesconfig 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 org.eclipse.microprofile.config.spi.ConfigSource create(URL url)
Propertiesconfig 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 org.eclipse.microprofile.config.spi.ConfigSource create(String name, Path path)
Propertiesconfig 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 org.eclipse.microprofile.config.spi.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 org.eclipse.microprofile.config.spi.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 org.eclipse.microprofile.config.spi.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 org.eclipse.microprofile.config.spi.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<org.eclipse.microprofile.config.spi.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<org.eclipse.microprofile.config.spi.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
-
create
public static org.eclipse.microprofile.config.spi.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 org.eclipse.microprofile.config.spi.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
-
-