Class ConfigSources
- java.lang.Object
-
- io.helidon.config.ConfigSources
-
public final class ConfigSources extends Object
Provides access to built-inConfigSourceimplementations.- See Also:
ConfigSource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConfigSources.CompositeBuilderBuilder of aConfigSourcethat encapsulates multiple separateConfigSources.static classConfigSources.MapBuilderBuilder of aConfigSourcebased on aMapcontaining config entries.static interfaceConfigSources.MergingStrategyAn algorithm for combining multipleConfigNode.ObjectNoderoot nodes into a singleConfigNode.ObjectNoderoot 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 aBuilderfor creating aConfigSourcefrom the specified resource located on the classpath of the current thread's context classloader.static ConfigSourcecreate(Config config)Returns aConfigSourcethat contains the same configuration model as the providedconfig.static ConfigSourcecreate(ConfigNode.ObjectNode objectNode)Returns aConfigSourcethat wraps the specifiedobjectNodeand returns it whenSource.load()is invoked.static ConfigSourcecreate(Readable readable, String mediaType)static ConfigSourcecreate(String content, String mediaType)static ConfigSources.CompositeBuildercreate(Supplier<ConfigSource>... configSources)Provides aConfigSources.CompositeBuilderfor creating a compositeConfigSourcebased on the specifiedConfigSources, used in the order in which they are passed as arguments.static ConfigSources.CompositeBuildercreate(List<Supplier<ConfigSource>> configSources)Provides aConfigSources.CompositeBuilderfor creating a compositeConfigSourcebased on theConfigSources and their order in the specified list.static ConfigSources.MapBuildercreate(Map<String,String> map)static ConfigSources.MapBuildercreate(Map<String,String> map, String name)static ConfigSources.MapBuildercreate(Properties properties)static ConfigSources.MapBuildercreate(Properties properties, String name)static AbstractConfigSource.Builder<? extends AbstractConfigSource.Builder<?,Path>,Path>directory(String path)Provides aBuilderfor creating aConfigSourcefrom the specified directory path.static ConfigSourceempty()Provides an empty config source.static ConfigSourceenvironmentVariables()Provides a @{code ConfigSource} for creating aConfigfrom environment variables.static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path>file(String path)Provides aBuilderfor creating aConfigSourcefrom the specified file path.static ConfigSources.CompositeBuilderload(Config metaConfig)Provides aConfigSources.CompositeBuilderfor creating a compositeConfigSourcebased on theConfigSources returned by the provided meta-configuration.static ConfigSources.CompositeBuilderload(Supplier<ConfigSource>... metaSources)Provides aConfigSources.CompositeBuilderfor creating a compositeConfigSourcebased on theConfigSources returned by the provided meta-sources.static ConfigSourceprefixed(String key, Supplier<ConfigSource> sourceSupplier)Provides aConfigSourcefrom asourceSupplier, adding the specifiedprefixto the keys in the source.static ConfigSourcesystemProperties()Provides aConfigSourcefor creating aConfigderived from system properties.static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,URL>,URL>url(URL url)Provides aBuilderfor creating aConfigSourcefrom 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 aConfigSourcethat contains the same configuration model as the providedconfig.- Parameters:
config- the originalConfig- Returns:
ConfigSourcefor the sameConfigas the original
-
create
public static ConfigSource create(ConfigNode.ObjectNode objectNode)
Returns aConfigSourcethat wraps the specifiedobjectNodeand 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 aConfigSourcefrom the providedreadable contentand with the specifiedmediaType.Instant.now()is thecontent timestamp.- Parameters:
readable- aReadableproviding the configuration contentmediaType- a configuration media type- Returns:
- a config source
-
create
public static ConfigSource create(String content, String mediaType)
Provides aConfigSourcefrom the providedStringcontent 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 aConfigSourcefrom asourceSupplier, adding the specifiedprefixto 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 aConfigSourcefor creating aConfigderived from system properties.- Returns:
ConfigSourcefor config derived from system properties
-
environmentVariables
public static ConfigSource environmentVariables()
Provides a @{code ConfigSource} for creating aConfigfrom environment variables.- Returns:
ConfigSourcefor config derived from environment variables
-
classpath
public static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path> classpath(String resource)
Provides aBuilderfor creating aConfigSourcefrom 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
ConfigSourcefor the classpath-based resource
-
file
public static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,Path>,Path> file(String path)
Provides aBuilderfor creating aConfigSourcefrom 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 aBuilderfor creating aConfigSourcefrom 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 aBuilderfor creating aConfigSourcefrom 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.CompositeBuilderfor creating a compositeConfigSourcebased on the specifiedConfigSources, used in the order in which they are passed as arguments.By default the resulting
ConfigSourcecombines the variousConfigSources using the system-providedfallback merging strategy. The application can invokeConfigSources.CompositeBuilder.mergingStrategyto 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.CompositeBuilderfor creating a compositeConfigSourcebased on theConfigSources and their order in the specified list.By default the resulting
ConfigSourcecombines the variousConfigSources using the system-providedfallback merging strategy. The application can invokeConfigSources.CompositeBuilder.mergingStrategyto 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.CompositeBuilderfor creating a compositeConfigSourcebased on theConfigSources returned by the provided meta-sources.Each meta-source must contain the
sourcesproperty which is an array of config sources. SeeConfigSource.create(Config)for more information about the format of meta-configuration.The returned builder is a
CompositeBuilderthat 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.CompositeBuilderfor creating a compositeConfigSourcebased on theConfigSources returned by the provided meta-configuration.The meta-configuration must contain the
sourcesproperty which is an array of config sources. SeeConfigSource.create(Config)for more information about the format of meta-configuration.The returned builder is a
CompositeBuilderthat 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[])
-
-