- java.lang.Object
-
- io.helidon.config.PrefixedConfigSource
-
- All Implemented Interfaces:
ConfigSource
,EventConfigSource
,NodeConfigSource
,Source
,Supplier<ConfigSource>
public final class PrefixedConfigSource extends Object implements ConfigSource, NodeConfigSource, EventConfigSource
ConfigSource
implementation wraps another config source and add key prefix to original one. Only supports "eager" config sources, such asParsableSource
andNodeConfigSource
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.helidon.config.spi.Source
Source.Builder<B extends Source.Builder<B>>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PrefixedConfigSource
create(Config metaConfig)
Create a prefixed config source from meta configuration.static PrefixedConfigSource
create(String key, ConfigSource source)
Create a new prefixed config source.String
description()
Short, human-readable summary referring to the underlying source.boolean
exists()
If the underlying data exist at this time.void
init(ConfigContext context)
Initialize the config source with aConfigContext
.Optional<ConfigContent.NodeContent>
load()
Loads the underlying source data.void
onChange(BiConsumer<String,ConfigNode> changedNode)
Register a change listener.boolean
optional()
Whether this source is optional.Optional<RetryPolicy>
retryPolicy()
Retry policy configured on this config source.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.config.spi.ConfigSource
get
-
-
-
-
Method Detail
-
create
public static PrefixedConfigSource create(Config metaConfig)
Create a prefixed config source from meta configuration. The meta configuration must contain the configuration key "key" and meta configuration of another config source to be prefixed with the key.- Parameters:
metaConfig
- meta configuration- Returns:
- a new prefixed config source
-
create
public static PrefixedConfigSource create(String key, ConfigSource source)
Create a new prefixed config source.- Parameters:
key
- prefix keysource
- wrapped source- Returns:
- a new prefixed config source
-
init
public void init(ConfigContext context)
Description copied from interface:ConfigSource
Initialize the config source with aConfigContext
.The method is executed during
Config
bootstrapping byConfig.Builder
.- Specified by:
init
in interfaceConfigSource
- Parameters:
context
- a config context
-
description
public String description()
Description copied from interface:Source
Short, human-readable summary referring to the underlying source.For example, a file path or a URL or any other information that helps the user recognize the underlying origin of the data this
Source
provides.Default is the implementation class simple name with any
"Source"
suffix removed.- Specified by:
description
in interfaceSource
- Returns:
- description of the source
-
load
public Optional<ConfigContent.NodeContent> load() throws ConfigException
Description copied from interface:NodeConfigSource
Loads the underlying source data. This method is only called when the sourceSource.exists()
.The method can be invoked repeatedly, for example during retries.
- Specified by:
load
in interfaceNodeConfigSource
- Returns:
- An instance of
T
as read from the underlying origin of the data (if it exists) - Throws:
ConfigException
- in case of errors loading from the underlying origin
-
onChange
public void onChange(BiConsumer<String,ConfigNode> changedNode)
Description copied from interface:EventConfigSource
Register a change listener.- Specified by:
onChange
in interfaceEventConfigSource
- Parameters:
changedNode
- the key and node of the configuration that changed. This may be the whole config tree, or a specific node depending on how fine grained the detection mechanism is. To notify of a whole node being changed, use empty string as a key
-
exists
public boolean exists()
Description copied from interface:Source
If the underlying data exist at this time. This is to prevent us loading such a source if we know it does not exist.
-
retryPolicy
public Optional<RetryPolicy> retryPolicy()
Description copied from interface:Source
Retry policy configured on this config source.- Specified by:
retryPolicy
in interfaceSource
- Returns:
- configured retry policy
-
-