Class CompositeConfigurationSource
- All Implemented Interfaces:
ConfigurationSource
- 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
ConstructorDescriptionCreates a new composite configuration source with the specified sources ordered from the highest to lowest priority which uses 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 which uses the specified strategy.CompositeConfigurationSource
(List<ConfigurationSource> sources, List<ConfigurationKey.Parameter> defaultParameters) Creates a new composite configuration source with the specified sources ordered from the highest to lowest priority which applies the specified default parameters and uses the defaultCompositeConfigurationStrategy.lookup()
strategy.CompositeConfigurationSource
(List<ConfigurationSource> sources, List<ConfigurationKey.Parameter> defaultParameters, CompositeConfigurationStrategy strategy) Creates a new composite configuration source with the specified sources ordered from the highest to lowest priority which applies the specified default parameters and uses the specified strategy. -
Method Summary
Modifier and TypeMethodDescriptionCreates a configuration query to retrieve the specified properties.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.unwrap()
Returns the original configuration source.withParameters
(ConfigurationKey.Parameter... parameters) Defines parameters that specify the context in which configuration properties are to be retrieved.withParameters
(String k1, Object v1) Defines one parameter that specifies the context in which configuration properties are to be retrieved.withParameters
(String k1, Object v1, String k2, Object v2) Defines two parameters that specify the context in which configuration properties are to be retrieved.Defines three parameters that specify the context in which configuration properties are to be retrieved.withParameters
(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4) Defines four parameters that specify the context in which configuration properties are to be retrieved.withParameters
(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5) Defines five parameters that specify the context in which configuration properties are to be retrieved.withParameters
(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6) Defines six parameters that specify the context in which configuration properties are to be retrieved.withParameters
(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7) Defines seven parameters that specify the context in which configuration properties are to be retrieved.withParameters
(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7, String k8, Object v8) Defines eighth parameters that specify the context in which configuration properties are to be retrieved.withParameters
(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7, String k8, Object v8, String k9, Object v9) Defines nine parameters that specify the context in which configuration properties are to be retrieved.withParameters
(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7, String k8, Object v8, String k9, Object v9, String k10, Object v10) Defines ten parameters that specify the context in which configuration properties are to be retrieved.withParameters
(List<ConfigurationKey.Parameter> parameters) Defines parameters that specify the context in which configuration properties are to be retrieved.
-
Constructor Details
-
CompositeConfigurationSource
Creates a new composite configuration source with the specified sources ordered from the highest to lowest priority which uses the default
CompositeConfigurationStrategy.lookup()
strategy.- Parameters:
sources
- a list of configuration sources
-
CompositeConfigurationSource
public CompositeConfigurationSource(List<ConfigurationSource> sources, List<ConfigurationKey.Parameter> defaultParameters) Creates a new composite configuration source with the specified sources ordered from the highest to lowest priority which applies the specified default parameters and uses the default
CompositeConfigurationStrategy.lookup()
strategy.- Parameters:
sources
- a list of configuration sourcesdefaultParameters
- the default parameters to apply
-
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 which uses the specified strategy.
- Parameters:
sources
- a list of configuration sourcesstrategy
- a composite configuration strategy
-
CompositeConfigurationSource
public CompositeConfigurationSource(List<ConfigurationSource> sources, List<ConfigurationKey.Parameter> defaultParameters, CompositeConfigurationStrategy strategy) Creates a new composite configuration source with the specified sources ordered from the highest to lowest priority which applies the specified default parameters and uses the specified strategy.
- Parameters:
sources
- a list of configuration sourcesdefaultParameters
- the default parameters to applystrategy
- a composite configuration strategy
-
-
Method Details
-
withParameters
Description copied from interface:ConfigurationSource
Defines one parameter that specifies the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the parameter namev1
- the parameter value- Returns:
- the executable configuration query
-
withParameters
public final CompositeConfigurationSource withParameters(String k1, Object v1, String k2, Object v2) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines two parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the first parameter namev1
- the first parameter valuek2
- the second parameter namev2
- the second parameter value- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public final CompositeConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines three parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the first parameter namev1
- the first parameter valuek2
- the second parameter namev2
- the second parameter valuek3
- the third parameter namev3
- the third parameter value- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public final CompositeConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines four parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the first parameter namev1
- the first parameter valuek2
- the second parameter namev2
- the second parameter valuek3
- the third parameter namev3
- the third parameter valuek4
- the fourth parameter namev4
- the fourth parameter value- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public final CompositeConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines five parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the first parameter namev1
- the first parameter valuek2
- the second parameter namev2
- the second parameter valuek3
- the third parameter namev3
- the third parameter valuek4
- the fourth parameter namev4
- the fourth parameter valuek5
- the fifth parameter namev5
- the fifth parameter value- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public final CompositeConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines six parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the first parameter namev1
- the first parameter valuek2
- the second parameter namev2
- the second parameter valuek3
- the third parameter namev3
- the third parameter valuek4
- the fourth parameter namev4
- the fourth parameter valuek5
- the fifth parameter namev5
- the fifth parameter valuek6
- the sixth parameter namev6
- the sixth parameter value- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public final CompositeConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines seven parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the first parameter namev1
- the first parameter valuek2
- the second parameter namev2
- the second parameter valuek3
- the third parameter namev3
- the third parameter valuek4
- the fourth parameter namev4
- the fourth parameter valuek5
- the fifth parameter namev5
- the fifth parameter valuek6
- the sixth parameter namev6
- the sixth parameter valuek7
- the seventh parameter namev7
- the seventh parameter value- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public final CompositeConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7, String k8, Object v8) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines eighth parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the first parameter namev1
- the first parameter valuek2
- the second parameter namev2
- the second parameter valuek3
- the third parameter namev3
- the third parameter valuek4
- the fourth parameter namev4
- the fourth parameter valuek5
- the fifth parameter namev5
- the fifth parameter valuek6
- the sixth parameter namev6
- the sixth parameter valuek7
- the seventh parameter namev7
- the seventh parameter valuek8
- the eighth parameter namev8
- the eighth parameter value- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public final CompositeConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7, String k8, Object v8, String k9, Object v9) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines nine parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the first parameter namev1
- the first parameter valuek2
- the second parameter namev2
- the second parameter valuek3
- the third parameter namev3
- the third parameter valuek4
- the fourth parameter namev4
- the fourth parameter valuek5
- the fifth parameter namev5
- the fifth parameter valuek6
- the sixth parameter namev6
- the sixth parameter valuek7
- the seventh parameter namev7
- the seventh parameter valuek8
- the eighth parameter namev8
- the eighth parameter valuek9
- the ninth parameter namev9
- the ninth parameter value- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public final CompositeConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6, String k7, Object v7, String k8, Object v8, String k9, Object v9, String k10, Object v10) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines ten parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
k1
- the first parameter namev1
- the first parameter valuek2
- the second parameter namev2
- the second parameter valuek3
- the third parameter namev3
- the third parameter valuek4
- the fourth parameter namev4
- the fourth parameter valuek5
- the fifth parameter namev5
- the fifth parameter valuek6
- the sixth parameter namev6
- the sixth parameter valuek7
- the seventh parameter namev7
- the seventh parameter valuek8
- the eighth parameter namev8
- the eighth parameter valuek9
- the ninth parameter namev9
- the ninth parameter valuek10
- the tenth parameter namev10
- the tenth parameter value- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public final CompositeConfigurationSource withParameters(ConfigurationKey.Parameter... parameters) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
parameters
- an array of parameters- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
public CompositeConfigurationSource withParameters(List<ConfigurationKey.Parameter> parameters) throws IllegalArgumentException Description copied from interface:ConfigurationSource
Defines parameters that specify the context in which configuration properties are to be retrieved.
- Specified by:
withParameters
in interfaceConfigurationSource
- Parameters:
parameters
- a list of parameters- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
unwrap
Description copied from interface:ConfigurationSource
Returns the original configuration source.
A configuration source can be decorated in order to provide a fixed set of parameters for all queries or to use a particular
DefaultingStrategy
when considering aDefaultableConfigurationSource
. This method helps retrieving the original source (i.e. before any transformations).- Specified by:
unwrap
in interfaceConfigurationSource
- Returns:
- the original configuration or this configuration
-
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
- 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
- Parameters:
name
- a property name- Returns:
- a list configuration query
- Throws:
IllegalArgumentException
- if the name is null or empty
-