Interface ConfigurationSource
- All Known Subinterfaces:
ConfigurableConfigurationSource
,DefaultableConfigurationSource
- All Known Implementing Classes:
io.inverno.mod.configuration.internal.AbstractConfigurableConfigurationSource
,io.inverno.mod.configuration.internal.AbstractConfigurationSource
,io.inverno.mod.configuration.internal.AbstractHashConfigurationSource
,io.inverno.mod.configuration.internal.AbstractPropertiesConfigurationSource
,BootstrapConfigurationSource
,CommandLineConfigurationSource
,CompositeConfigurationSource
,CPropsFileConfigurationSource
,MapConfigurationSource
,PropertiesConfigurationSource
,PropertyFileConfigurationSource
,RedisConfigurationSource
,SystemEnvironmentConfigurationSource
,SystemPropertiesConfigurationSource
,VersionedRedisConfigurationSource
A configuration source gives access to configuration properties.
Configuration properties can be queries as follows:
ConfigurationSource source = ...
Map<String, String> propertiesAsString = source
.get("prop1", "prop2")
.execute()
.collect(Collectors.toMap(
result -> result.getQueryKey().getName(),
result -> result.getResult()
.flatMap(property -> property.asString()).orElse(null)
)
)
.block();
Parameters can be specified on a query to specify the context for which values must be retrieved:
Map<String, String> propertiesAsString = source
.get("prop1", "prop2")
.withParameters("environment", "test")
.execute()
.collect(Collectors.toMap(
result -> result.getQueryKey().getName(),
result -> result.getResult()
.flatMap(property -> property.asString()).orElse(null)
)
)
.block();
Queries can be executed in a batch:
Map<String, String> propertiesAsString = source
.get("prop1", "prop2").and()
.get("prop3", "prop4")
.withParameters("customer", "abc")
.execute()
.collect(Collectors.toMap(
result -> result.getQueryKey().getName(),
result -> result.getResult()
.flatMap(property -> property.asString()).orElse(null)
)
)
.block();
- Since:
- 1.0
- Author:
- Jeremy Kuhn
-
Method Summary
Modifier and TypeMethodDescriptionCreates a configuration query to retrieve the specified properties.Creates a list configuration query to list configuration properties defined with the specified property name.unwrap()
Returns the original configuration source.default ConfigurationSource
withParameters
(ConfigurationKey.Parameter... parameters) Defines parameters that specify the context in which configuration properties are to be retrieved.default ConfigurationSource
withParameters
(String k1, Object v1) Defines one parameter that specifies the context in which configuration properties are to be retrieved.default ConfigurationSource
withParameters
(String k1, Object v1, String k2, Object v2) Defines two parameters that specify the context in which configuration properties are to be retrieved.default ConfigurationSource
Defines three parameters that specify the context in which configuration properties are to be retrieved.default ConfigurationSource
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.default ConfigurationSource
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.default ConfigurationSource
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.default ConfigurationSource
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.default ConfigurationSource
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.default ConfigurationSource
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.default ConfigurationSource
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.
-
Method Details
-
get
Creates a configuration query to retrieve the specified properties.
- Parameters:
names
- an array of property names- Returns:
- an executable configuration query
- Throws:
IllegalArgumentException
- if the array of names is null or empty
-
list
Creates a list configuration query to list configuration properties defined with the specified property name.
- Parameters:
name
- a property name- Returns:
- a list configuration query
- Throws:
IllegalArgumentException
- if the name is null or empty
-
withParameters
Defines one parameter that specifies the context in which configuration properties are to be retrieved.
- Parameters:
k1
- the parameter namev1
- the parameter value- Returns:
- the executable configuration query
-
withParameters
default ConfigurationSource withParameters(String k1, Object v1, String k2, Object v2) throws IllegalArgumentException Defines two parameters that specify the context in which configuration properties are to be retrieved.
- 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
default ConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3) throws IllegalArgumentException Defines three parameters that specify the context in which configuration properties are to be retrieved.
- 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
default ConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4) throws IllegalArgumentException Defines four parameters that specify the context in which configuration properties are to be retrieved.
- 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
default ConfigurationSource withParameters(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5) throws IllegalArgumentException Defines five parameters that specify the context in which configuration properties are to be retrieved.
- 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
default ConfigurationSource 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 Defines six parameters that specify the context in which configuration properties are to be retrieved.
- 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
default ConfigurationSource 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 Defines seven parameters that specify the context in which configuration properties are to be retrieved.
- 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
default ConfigurationSource 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 Defines eighth parameters that specify the context in which configuration properties are to be retrieved.
- 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
default ConfigurationSource 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 Defines nine parameters that specify the context in which configuration properties are to be retrieved.
- 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
default ConfigurationSource 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 Defines ten parameters that specify the context in which configuration properties are to be retrieved.
- 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
default ConfigurationSource withParameters(ConfigurationKey.Parameter... parameters) throws IllegalArgumentException Defines parameters that specify the context in which configuration properties are to be retrieved.
- Parameters:
parameters
- an array of parameters- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
ConfigurationSource withParameters(List<ConfigurationKey.Parameter> parameters) throws IllegalArgumentException Defines parameters that specify the context in which configuration properties are to be retrieved.
- Parameters:
parameters
- a list of parameters- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
unwrap
ConfigurationSource unwrap()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).- Returns:
- the original configuration or this configuration
-