- java.lang.Object
-
- io.helidon.config.ConfigSources
-
public final class ConfigSources extends Object
Provides access to built-inConfigSource
implementations.- See Also:
ConfigSource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConfigSources.SystemPropertiesConfigSource
System properties config source.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClasspathConfigSource.Builder
classpath(String resource)
Provides aBuilder
for creating aConfigSource
from the specified resource located on the classpath of the current thread's context classloader.static List<UrlConfigSource.Builder>
classpathAll(String resource)
Create builders for each instance of the resource on the current classpath.static ConfigSource
create(Config config)
Returns aConfigSource
that contains the same configuration model as the providedconfig
.static NodeConfigSource
create(ConfigNode.ObjectNode objectNode)
Returns aConfigSource
that wraps the specifiedobjectNode
.static ConfigSource
create(InputStream data, String mediaType)
static ConfigSource
create(String content, String mediaType)
static MapConfigSource.Builder
create(Map<String,String> map)
static MapConfigSource.Builder
create(Map<String,String> map, String name)
static MapConfigSource.Builder
create(Properties properties)
static MapConfigSource.Builder
create(Properties properties, String name)
static DirectoryConfigSource.Builder
directory(String path)
Provides aBuilder
for creating aConfigSource
from the specified directory path.static ConfigSource
empty()
Provides an empty config source.static MapConfigSource
environmentVariables()
Provides a @{code ConfigSource} for creating aConfig
from environment variables.static FileConfigSource.Builder
file(String path)
Provides aBuilder
for creating aConfigSource
from the specified file path.static FileConfigSource.Builder
file(Path path)
Provides aBuilder
for creating aConfigSource
from the specified file path.static ConfigSource
prefixed(String key, Supplier<? extends ConfigSource> sourceSupplier)
Provides aConfigSource
from asourceSupplier
, adding the specifiedprefix
to the keys in the source.static ConfigSources.SystemPropertiesConfigSource.Builder
systemProperties()
Provides aConfigSource
for creating aConfig
derived from system properties.static UrlConfigSource.Builder
url(URL url)
Provides aBuilder
for creating aConfigSource
from the specified URL.
-
-
-
Method Detail
-
empty
public static ConfigSource empty()
Provides an empty config source.- Returns:
- empty config source
-
create
public static ConfigSource create(Config config)
Returns aConfigSource
that contains the same configuration model as the providedconfig
.- Parameters:
config
- the originalConfig
- Returns:
ConfigSource
for the sameConfig
as the original
-
create
public static NodeConfigSource create(ConfigNode.ObjectNode objectNode)
Returns aConfigSource
that wraps the specifiedobjectNode
.- Parameters:
objectNode
- hierarchical configuration representation that will be returned by the created config source- Returns:
- new instance of
ConfigSource
- See Also:
ConfigNode.ObjectNode
,ConfigNode.ListNode
,ConfigNode.ValueNode
,ConfigNode.ObjectNode.Builder
,ConfigNode.ListNode.Builder
-
create
public static ConfigSource create(InputStream data, String mediaType)
Provides aConfigSource
from the providedreadable content
and with the specifiedmediaType
.Instant.now()
is thecontent timestamp
.- Parameters:
data
- aInputStream
providing the configuration contentmediaType
- a configuration media type- Returns:
- a config source
-
create
public static ConfigSource create(String content, String mediaType)
Provides aConfigSource
from the providedString
content and with the specifiedmediaType
.Instant.now()
is thecontent timestamp
.- Parameters:
content
- a configuration contentmediaType
- a configuration media type- Returns:
- a config source
-
create
public static MapConfigSource.Builder create(Map<String,String> map)
- Parameters:
map
- a map- Returns:
- new Builder instance
- See Also:
create(Properties)
-
create
public static MapConfigSource.Builder create(Map<String,String> map, String name)
- Parameters:
map
- a mapname
- the name.- Returns:
- new Builder instance
- See Also:
create(Properties)
-
create
public static MapConfigSource.Builder create(Properties properties)
- Parameters:
properties
- properties- Returns:
- new Builder instance
- See Also:
create(Map)
-
create
public static MapConfigSource.Builder create(Properties properties, String name)
- Parameters:
properties
- propertiesname
- the name.- Returns:
- new Builder instance
- See Also:
create(Map)
-
prefixed
public static ConfigSource prefixed(String key, Supplier<? extends ConfigSource> sourceSupplier)
Provides aConfigSource
from asourceSupplier
, adding the specifiedprefix
to the keys in the source.- Parameters:
key
- key prefix to be added to all keyssourceSupplier
- a config source supplier- Returns:
- new @{code ConfigSource} for the newly-prefixed content
-
systemProperties
public static ConfigSources.SystemPropertiesConfigSource.Builder systemProperties()
Provides aConfigSource
for creating aConfig
derived from system properties.- Returns:
ConfigSource
for config derived from system properties
-
environmentVariables
public static MapConfigSource environmentVariables()
Provides a @{code ConfigSource} for creating aConfig
from environment variables.- Returns:
ConfigSource
for config derived from environment variables
-
classpath
public static ClasspathConfigSource.Builder classpath(String resource)
Provides aBuilder
for creating aConfigSource
from the specified resource located on the classpath of the current thread's context classloader.The name of a resource is a '
/
'-separated full path name that identifies the resource. If the resource name has a leading slash then it is dropped before lookup.- Parameters:
resource
- a name of the resource- Returns:
- builder for a
ConfigSource
for the classpath-based resource
-
classpathAll
public static List<UrlConfigSource.Builder> classpathAll(String resource)
Create builders for each instance of the resource on the current classpath.- Parameters:
resource
- resource to look for- Returns:
- a list of classpath config source builders
-
file
public static FileConfigSource.Builder file(String path)
Provides aBuilder
for creating aConfigSource
from the specified file path.- Parameters:
path
- a file path- Returns:
- builder for the file-based
ConfigSource
-
file
public static FileConfigSource.Builder file(Path path)
Provides aBuilder
for creating aConfigSource
from the specified file path.- Parameters:
path
- a file path- Returns:
- builder for the file-based
ConfigSource
-
directory
public static DirectoryConfigSource.Builder directory(String path)
Provides aBuilder
for creating aConfigSource
from the specified directory path.- Parameters:
path
- a directory path- Returns:
- new Builder instance
-
url
public static UrlConfigSource.Builder url(URL url)
Provides aBuilder
for creating aConfigSource
from the specified URL.- Parameters:
url
- a URL with configuration- Returns:
- new Builder instance
- See Also:
url(URL)
-
-