public final class ConfigSources extends Object
ConfigSource implementations.ConfigSource| Modifier and Type | Class and Description |
|---|---|
static class |
ConfigSources.CompositeBuilder
Builder of a
ConfigSource that encapsulates multiple separate
ConfigSources. |
static class |
ConfigSources.MapBuilder
Builder of a
ConfigSource based on a Map containing
config entries. |
static interface |
ConfigSources.MergingStrategy
An algorithm for combining multiple
ConfigNode.ObjectNode root nodes
into a single ConfigNode.ObjectNode root node. |
| Modifier and Type | Method and Description |
|---|---|
static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path> |
classpath(String resource)
Provides a
Builder for creating a ConfigSource
from the specified resource located on the classpath of the current
thread's context classloader. |
static ConfigSource |
create(Config config)
Returns a
ConfigSource that contains the same configuration model
as the provided config. |
static ConfigSource |
create(ConfigNode.ObjectNode objectNode)
Returns a
ConfigSource that wraps the specified objectNode
and returns it when Source.load() is invoked. |
static ConfigSources.CompositeBuilder |
create(List<Supplier<ConfigSource>> configSources)
Provides a
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the ConfigSources and their order
in the specified list. |
static ConfigSources.MapBuilder |
create(Map<String,String> map)
|
static ConfigSources.MapBuilder |
create(Properties properties)
|
static ConfigSource |
create(Readable readable,
String mediaType)
|
static ConfigSource |
create(String content,
String mediaType)
|
static ConfigSources.CompositeBuilder |
create(Supplier<ConfigSource>... configSources)
Provides a
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the specified ConfigSources, used
in the order in which they are passed as arguments. |
static AbstractConfigSource.Builder<? extends AbstractConfigSource.Builder<?,Path>,Path> |
directory(String path)
Provides a
Builder for creating a ConfigSource from the specified
directory path. |
static ConfigSource |
empty()
Provides an empty config source.
|
static ConfigSource |
environmentVariables()
Provides a @{code ConfigSource} for creating a
Config from
environment variables. |
static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path> |
file(String path)
Provides a
Builder for creating a ConfigSource from the specified
file path. |
static ConfigSources.CompositeBuilder |
load(Config metaConfig)
Provides a
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the ConfigSources returned by the
provided meta-configuration. |
static ConfigSources.CompositeBuilder |
load(Supplier<ConfigSource>... metaSources)
Provides a
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the ConfigSources returned by the
provided meta-sources. |
static ConfigSource |
prefixed(String key,
Supplier<ConfigSource> sourceSupplier)
Provides a
ConfigSource from a sourceSupplier, adding the
specified prefix to the keys in the source. |
static ConfigSource |
systemProperties()
Provides a
ConfigSource for creating a Config derived
from system properties. |
static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,URL>,URL> |
url(URL url)
Provides a
Builder for creating a ConfigSource from the specified
URL. |
public static ConfigSource empty()
public static ConfigSource create(Config config)
ConfigSource that contains the same configuration model
as the provided config.config - the original ConfigConfigSource for the same Config as the originalpublic static ConfigSource create(ConfigNode.ObjectNode objectNode)
ConfigSource that wraps the specified objectNode
and returns it when Source.load() is invoked.objectNode - hierarchical configuration representation that will be
returned by Source.load()ConfigSourceConfigNode.ObjectNode,
ConfigNode.ListNode,
ConfigNode.ValueNode,
ConfigNode.ObjectNode.Builder,
ConfigNode.ListNode.Builderpublic static ConfigSource create(Readable readable, String mediaType)
ConfigSource from the provided readable content and
with the specified mediaType.
Instant.now() is the content timestamp.
readable - a Readable providing the configuration contentmediaType - a configuration media typepublic static ConfigSource create(String content, String mediaType)
ConfigSource from the provided String content and
with the specified mediaType.
Instant.now() is the content timestamp.
content - a configuration contentmediaType - a configuration media typepublic static ConfigSources.MapBuilder create(Map<String,String> map)
map - a mapcreate(Properties)public static ConfigSources.MapBuilder create(Properties properties)
properties - propertiescreate(Map)public static ConfigSource prefixed(String key, Supplier<ConfigSource> sourceSupplier)
ConfigSource from a sourceSupplier, adding the
specified prefix to the keys in the source.key - key prefix to be added to all keyssourceSupplier - a config source supplierpublic static ConfigSource systemProperties()
ConfigSource for creating a Config derived
from system properties.ConfigSource for config derived from system propertiespublic static ConfigSource environmentVariables()
Config from
environment variables.ConfigSource for config derived from environment variablespublic static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path> classpath(String resource)
Builder for creating a ConfigSource
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.
resource - a name of the resourceConfigSource for the classpath-based resourcepublic static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path> file(String path)
Builder for creating a ConfigSource from the specified
file path.path - a file pathConfigSourcepublic static AbstractConfigSource.Builder<? extends AbstractConfigSource.Builder<?,Path>,Path> directory(String path)
Builder for creating a ConfigSource from the specified
directory path.path - a directory pathpublic static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,URL>,URL> url(URL url)
Builder for creating a ConfigSource from the specified
URL.url - a URL with configurationurl(URL)@SafeVarargs public static ConfigSources.CompositeBuilder create(Supplier<ConfigSource>... configSources)
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the specified ConfigSources, used
in the order in which they are passed as arguments.
By default the resulting ConfigSource combines the various
ConfigSources using the system-provided
fallback merging strategy. The
application can invoke ConfigSources.CompositeBuilder.mergingStrategy to change
how the sources are combined.
configSources - original config sources to be treated as oneConfigSources.CompositeBuilder,
ConfigSources.MergingStrategy,
create(Supplier[]),
create(List),
load(Supplier[]),
load(Config),
Config.create(Supplier[]),
Config.builder(Supplier[])public static ConfigSources.CompositeBuilder create(List<Supplier<ConfigSource>> configSources)
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the ConfigSources and their order
in the specified list.
By default the resulting ConfigSource combines the various
ConfigSources using the system-provided
fallback merging strategy. The
application can invoke ConfigSources.CompositeBuilder.mergingStrategy to change
how the sources are combined.
configSources - original config sources to be treated as oneConfigSources.CompositeBuilder,
ConfigSources.MergingStrategy,
create(Supplier[]),
create(List),
load(Supplier[]),
load(Config),
Config.create(Supplier[]),
Config.builder(Supplier[])@SafeVarargs public static ConfigSources.CompositeBuilder load(Supplier<ConfigSource>... metaSources)
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the ConfigSources returned by the
provided meta-sources.
Each meta-source must contain the sources property which is an
array of config sources. See ConfigSource.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 the
fallback merging strategy.
metaSources - ordered list of meta-sources from which the builder
will read meta-configuration indicating the config sourcesConfigSources.CompositeBuilder,
ConfigSources.MergingStrategy,
create(Supplier[]),
create(List),
load(Supplier[]),
load(Config),
Config.builderLoadSourcesFrom(Supplier[]),
Config.loadSourcesFrom(Supplier[])public static ConfigSources.CompositeBuilder load(Config metaConfig)
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the ConfigSources returned by the
provided meta-configuration.
The meta-configuration must contain the sources property which is
an array of config sources. See ConfigSource.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 the
fallback merging strategy.
metaConfig - meta-configuration from which the builder will derive
config sourcesConfigSources.CompositeBuilder,
ConfigSources.MergingStrategy,
create(Supplier[]),
create(List),
load(Supplier[]),
load(Config),
Config.builderLoadSourcesFrom(Supplier[]),
Config.loadSourcesFrom(Supplier[])Copyright © 2018–2019 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.