Class ConfigSources
- 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.CompositeBuilder
Builder of aConfigSource
that encapsulates multiple separateConfigSource
s.static class
ConfigSources.MapBuilder
Builder of aConfigSource
based on aMap
containing config entries.static interface
ConfigSources.MergingStrategy
An algorithm for combining multipleConfigNode.ObjectNode
root nodes into a singleConfigNode.ObjectNode
root node.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path>
classpath(String resource)
Provides aBuilder
for creating aConfigSource
from the specified resource located on the classpath of the current thread's context classloader.static ConfigSource
create(Config config)
Returns aConfigSource
that contains the same configuration model as the providedconfig
.static ConfigSource
create(ConfigNode.ObjectNode objectNode)
Returns aConfigSource
that wraps the specifiedobjectNode
and returns it whenSource.load()
is invoked.static ConfigSource
create(Readable readable, String mediaType)
static ConfigSource
create(String content, String mediaType)
static ConfigSources.CompositeBuilder
create(Supplier<ConfigSource>... configSources)
Provides aConfigSources.CompositeBuilder
for creating a compositeConfigSource
based on the specifiedConfigSource
s, used in the order in which they are passed as arguments.static ConfigSources.CompositeBuilder
create(List<Supplier<ConfigSource>> configSources)
Provides aConfigSources.CompositeBuilder
for creating a compositeConfigSource
based on theConfigSource
s and their order in the specified list.static ConfigSources.MapBuilder
create(Map<String,String> map)
static ConfigSources.MapBuilder
create(Map<String,String> map, String name)
static ConfigSources.MapBuilder
create(Properties properties)
static ConfigSources.MapBuilder
create(Properties properties, String name)
static AbstractConfigSource.Builder<? extends AbstractConfigSource.Builder<?,Path>,Path>
directory(String path)
Provides aBuilder
for creating aConfigSource
from the specified directory path.static ConfigSource
empty()
Provides an empty config source.static ConfigSource
environmentVariables()
Provides a @{code ConfigSource} for creating aConfig
from environment variables.static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path>
file(String path)
Provides aBuilder
for creating aConfigSource
from the specified file path.static ConfigSources.CompositeBuilder
load(Config metaConfig)
Provides aConfigSources.CompositeBuilder
for creating a compositeConfigSource
based on theConfigSource
s returned by the provided meta-configuration.static ConfigSources.CompositeBuilder
load(Supplier<ConfigSource>... metaSources)
Provides aConfigSources.CompositeBuilder
for creating a compositeConfigSource
based on theConfigSource
s returned by the provided meta-sources.static ConfigSource
prefixed(String key, Supplier<ConfigSource> sourceSupplier)
Provides aConfigSource
from asourceSupplier
, adding the specifiedprefix
to the keys in the source.static ConfigSource
systemProperties()
Provides aConfigSource
for creating aConfig
derived from system properties.static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,URL>,URL>
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 ConfigSource create(ConfigNode.ObjectNode objectNode)
Returns aConfigSource
that wraps the specifiedobjectNode
and returns it whenSource.load()
is invoked.- Parameters:
objectNode
- hierarchical configuration representation that will be returned bySource.load()
- Returns:
- new instance of
ConfigSource
- See Also:
ConfigNode.ObjectNode
,ConfigNode.ListNode
,ConfigNode.ValueNode
,ConfigNode.ObjectNode.Builder
,ConfigNode.ListNode.Builder
-
create
public static ConfigSource create(Readable readable, String mediaType)
Provides aConfigSource
from the providedreadable content
and with the specifiedmediaType
.Instant.now()
is thecontent timestamp
.- Parameters:
readable
- aReadable
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 ConfigSources.MapBuilder create(Map<String,String> map)
- Parameters:
map
- a map- Returns:
- new Builder instance
- See Also:
create(Properties)
-
create
public static ConfigSources.MapBuilder create(Map<String,String> map, String name)
- Parameters:
map
- a mapname
- the name.- Returns:
- new Builder instance
- See Also:
create(Properties)
-
create
public static ConfigSources.MapBuilder create(Properties properties)
- Parameters:
properties
- properties- Returns:
- new Builder instance
- See Also:
create(Map)
-
create
public static ConfigSources.MapBuilder 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<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 ConfigSource systemProperties()
Provides aConfigSource
for creating aConfig
derived from system properties.- Returns:
ConfigSource
for config derived from system properties
-
environmentVariables
public static ConfigSource environmentVariables()
Provides a @{code ConfigSource} for creating aConfig
from environment variables.- Returns:
ConfigSource
for config derived from environment variables
-
classpath
public static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path> 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
-
file
public static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path> 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
-
directory
public static AbstractConfigSource.Builder<? extends AbstractConfigSource.Builder<?,Path>,Path> 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 AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,URL>,URL> 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)
-
create
@SafeVarargs public static ConfigSources.CompositeBuilder create(Supplier<ConfigSource>... configSources)
Provides aConfigSources.CompositeBuilder
for creating a compositeConfigSource
based on the specifiedConfigSource
s, used in the order in which they are passed as arguments.By default the resulting
ConfigSource
combines the variousConfigSource
s using the system-providedfallback merging strategy
. The application can invokeConfigSources.CompositeBuilder.mergingStrategy
to change how the sources are combined.- Parameters:
configSources
- original config sources to be treated as one- Returns:
- new composite config source builder instance initialized from config sources.
- See Also:
ConfigSources.CompositeBuilder
,ConfigSources.MergingStrategy
,create(Supplier[])
,create(List)
,load(Supplier[])
,load(Config)
,Config.create(Supplier[])
,Config.builder(Supplier[])
-
create
public static ConfigSources.CompositeBuilder create(List<Supplier<ConfigSource>> configSources)
Provides aConfigSources.CompositeBuilder
for creating a compositeConfigSource
based on theConfigSource
s and their order in the specified list.By default the resulting
ConfigSource
combines the variousConfigSource
s using the system-providedfallback merging strategy
. The application can invokeConfigSources.CompositeBuilder.mergingStrategy
to change how the sources are combined.- Parameters:
configSources
- original config sources to be treated as one- Returns:
- new composite config source builder instance initialized from config sources.
- See Also:
ConfigSources.CompositeBuilder
,ConfigSources.MergingStrategy
,create(Supplier[])
,create(List)
,load(Supplier[])
,load(Config)
,Config.create(Supplier[])
,Config.builder(Supplier[])
-
load
@SafeVarargs public static ConfigSources.CompositeBuilder load(Supplier<ConfigSource>... metaSources)
Provides aConfigSources.CompositeBuilder
for creating a compositeConfigSource
based on theConfigSource
s returned by the provided meta-sources.Each meta-source must contain the
sources
property which is an array of config sources. SeeConfigSource.create(Config)
for more information about the format of meta-configuration.The returned builder is a
CompositeBuilder
that combines the config from all config sources derived from the meta-configuration in the meta-sources. By default the composite builder uses thefallback merging strategy
.- Parameters:
metaSources
- ordered list of meta-sources from which the builder will read meta-configuration indicating the config sources- Returns:
- new composite config source builder initialized from the specified meta-sources.
- See Also:
ConfigSources.CompositeBuilder
,ConfigSources.MergingStrategy
,create(Supplier[])
,create(List)
,load(Supplier[])
,load(Config)
,Config.builderLoadSourcesFrom(Supplier[])
,Config.loadSourcesFrom(Supplier[])
-
load
public static ConfigSources.CompositeBuilder load(Config metaConfig)
Provides aConfigSources.CompositeBuilder
for creating a compositeConfigSource
based on theConfigSource
s returned by the provided meta-configuration.The meta-configuration must contain the
sources
property which is an array of config sources. SeeConfigSource.create(Config)
for more information about the format of meta-configuration.The returned builder is a
CompositeBuilder
that combines the config from all config sources derived from the meta-configuration. By default the composite builder uses thefallback merging strategy
.- Parameters:
metaConfig
- meta-configuration from which the builder will derive config sources- Returns:
- new composite config source builder initialized from the specified meta-config
- See Also:
ConfigSources.CompositeBuilder
,ConfigSources.MergingStrategy
,create(Supplier[])
,create(List)
,load(Supplier[])
,load(Config)
,Config.builderLoadSourcesFrom(Supplier[])
,Config.loadSourcesFrom(Supplier[])
-
-