Class CompositeConfigurationSource
- All Implemented Interfaces:
ConfigurationSource<CompositeConfigurationSource.CompositeConfigurationQuery,
CompositeConfigurationSource.CompositeExecutableConfigurationQuery, CompositeConfigurationSource.CompositeListConfigurationQuery>
- Direct Known Subclasses:
BootstrapConfigurationSource
A composite configuration source that uses multiple configuration sources to resolve configuration properties.
A composite configuration source uses a CompositeConfigurationStrategy
to determine the best matching value among the different sources for a given query.
A composite configuration source queries its sources in sequence. It first applies a new CompositeConfigurationStrategy.CompositeDefaultingStrategy
provided by
CompositeConfigurationStrategy.createDefaultingStrategy()
to the sources that implement DefaultableConfigurationSource
. This allows to specify a defaulting strategy when
executing queries on each sources. The composite defaulting strategy allows to reduce the queries to execute on each source by keeping track of intermediate results in each round.
Configuration sources are ordered from the highest to lowest priority, the strategy allows to specify whether a result returned by a source for a given query supersedes the result returned in a
previous round for the same query (see
CompositeConfigurationStrategy.isSuperseded(io.inverno.mod.configuration.ConfigurationKey, io.inverno.mod.configuration.ConfigurationKey, io.inverno.mod.configuration.ConfigurationKey)
).
At the end of each round, the strategy is used to determine whether a result resolves a query (see
CompositeConfigurationStrategy.isResolved(io.inverno.mod.configuration.ConfigurationKey, io.inverno.mod.configuration.ConfigurationKey)
), in which case the query is removed from the list
of queries to execute on subsequent sources.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The configuration query used by the composite configuration source.static class
The configuration query result returned by a composite configuration source.static class
The executable configuration query used by the composite configuration source.static class
The list configuration query used by the composite configuration source. -
Constructor Summary
ConstructorDescriptionCompositeConfigurationSource
(List<ConfigurationSource<?, ?, ?>> sources) Creates a new composite configuration source with the specified sources ordered from the highest to lowest priority using the defaultCompositeConfigurationStrategy.lookup()
strategy.CompositeConfigurationSource
(List<ConfigurationSource<?, ?, ?>> sources, CompositeConfigurationStrategy strategy) Creates a new composite configuration source with the specified sources ordered from the highest to lowest priority and using the specified strategy. -
Method Summary
Modifier and TypeMethodDescriptionCreates a configuration query to retrieve the specified properties.List
<ConfigurationSource<?, ?, ?>> Returns the list of configuration sources from the highest priority to the lowest.Returns the composite configuration strategy.Creates a list configuration query to list configuration properties defined with the specified property name.void
setStrategy
(CompositeConfigurationStrategy strategy) Sets the composite configuration strategy.
-
Constructor Details
-
CompositeConfigurationSource
Creates a new composite configuration source with the specified sources ordered from the highest to lowest priority using the default
CompositeConfigurationStrategy.lookup()
strategy.- Parameters:
sources
- a list of configuration sources
-
CompositeConfigurationSource
public CompositeConfigurationSource(List<ConfigurationSource<?, ?, ?>> sources, CompositeConfigurationStrategy strategy) Creates a new composite configuration source with the specified sources ordered from the highest to lowest priority and using the specified strategy.
- Parameters:
sources
- a list of configuration sourcesstrategy
- a composite configuration strategy
-
-
Method Details
-
getSources
Returns the list of configuration sources from the highest priority to the lowest.
- Returns:
- a list of configuration sources
-
getStrategy
Returns the composite configuration strategy.
- Returns:
- the composite configuration strategy
-
setStrategy
Sets the composite configuration strategy.
- Parameters:
strategy
- a strategy- Throws:
NullPointerException
- if the strategy is null
-
get
public CompositeConfigurationSource.CompositeExecutableConfigurationQuery get(String... names) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Creates a configuration query to retrieve the specified properties.
- Specified by:
get
in interfaceConfigurationSource<CompositeConfigurationSource.CompositeConfigurationQuery,
CompositeConfigurationSource.CompositeExecutableConfigurationQuery, CompositeConfigurationSource.CompositeListConfigurationQuery> - Parameters:
names
- an array of property names- Returns:
- an executable configuration query
- Throws:
IllegalArgumentException
- if the array of names is null or empty
-
list
public CompositeConfigurationSource.CompositeListConfigurationQuery list(String name) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Creates a list configuration query to list configuration properties defined with the specified property name.
- Specified by:
list
in interfaceConfigurationSource<CompositeConfigurationSource.CompositeConfigurationQuery,
CompositeConfigurationSource.CompositeExecutableConfigurationQuery, CompositeConfigurationSource.CompositeListConfigurationQuery> - Parameters:
name
- a property name- Returns:
- a list configuration query
- Throws:
IllegalArgumentException
- if the name is null or empty
-