- java.lang.Object
-
- io.helidon.config.hocon.mp.HoconMpConfigSource
-
- All Implemented Interfaces:
ConfigSource
public class HoconMpConfigSource extends Object implements ConfigSource
MicroProfileConfigSource
that can be used to add HOCON/JSON files from classpath or file system using theConfigProviderResolver.getBuilder()
.The HOCON/JSON file is transformed to a flat map as follows:
Object nodesEach node in the tree is dot separated.
server = { host = "localhost" port= 8080 }
Will be transformed to the following properties:server.host=localhost server.port=8080
List nodes (arrays)Each node will be indexed (0 based)
providers = [{abac = {enabled = true}}] names = [ first second third ]
Will be transformed to the following properties:providers.0.abac.enabled=true names.0=first names.1=second names.2=third
-
-
Field Summary
-
Fields inherited from interface org.eclipse.microprofile.config.spi.ConfigSource
CONFIG_ORDINAL, DEFAULT_ORDINAL
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<ConfigSource>
classPath(String resource)
Create from HOCON/JSON file(s) on classpath.static List<ConfigSource>
classPath(String resource, String profile)
Create from HOCON/JSON file(s) on classpath with profile support.static ConfigSource
create(URL url)
Load a HOCON/JSON config source from URL.static ConfigSource
create(Path path)
Load a HOCON/JSON config source from file system.String
getName()
Map<String,String>
getProperties()
Set<String>
getPropertyNames()
String
getValue(String propertyName)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.microprofile.config.spi.ConfigSource
getOrdinal
-
-
-
-
Method Detail
-
create
public static ConfigSource create(Path path)
Load a HOCON/JSON config source from file system.- Parameters:
path
- path to the HOCON/JSON file- Returns:
- config source loaded from the file
- See Also:
create(java.net.URL)
-
create
public static ConfigSource create(URL url)
Load a HOCON/JSON config source from URL. The URL may be any URL which is supported by the used JVM.- Parameters:
url
- url of the resource- Returns:
- config source loaded from the URL
-
classPath
public static List<ConfigSource> classPath(String resource)
Create from HOCON/JSON file(s) on classpath.- Parameters:
resource
- resource name to locate on classpath (looks for all instances)- Returns:
- list of config sources discovered (may be zero length)
-
classPath
public static List<ConfigSource> classPath(String resource, String profile)
Create from HOCON/JSON file(s) on classpath with profile support.- Parameters:
resource
- resource name to locate on classpath (looks for all instances)profile
- name of the profile to use- Returns:
- list of config sources discovered (may be zero length)
-
getPropertyNames
public Set<String> getPropertyNames()
- Specified by:
getPropertyNames
in interfaceConfigSource
-
getProperties
public Map<String,String> getProperties()
- Specified by:
getProperties
in interfaceConfigSource
-
getValue
public String getValue(String propertyName)
- Specified by:
getValue
in interfaceConfigSource
-
getName
public String getName()
- Specified by:
getName
in interfaceConfigSource
-
-