Module io.inverno.mod.configuration
Package io.inverno.mod.configuration
Interface ConfigurationSource<A extends ConfigurationQuery<A,B>,B extends ExecutableConfigurationQuery<A,B>,C extends ListConfigurationQuery<C>>
- Type Parameters:
A
- source specific query typeB
- source specific executable query typeC
- source specific list query type
- All Known Subinterfaces:
ConfigurableConfigurationSource<A,
,B, C, D, E> DefaultableConfigurationSource<A,
B, C, D>
- All Known Implementing Classes:
AbstractConfigurableConfigurationSource
,AbstractConfigurationSource
,AbstractHashConfigurationSource
,AbstractPropertiesConfigurationSource
,BootstrapConfigurationSource
,CommandLineConfigurationSource
,CompositeConfigurationSource
,CPropsFileConfigurationSource
,MapConfigurationSource
,PropertiesConfigurationSource
,PropertyFileConfigurationSource
,RedisConfigurationSource
,SystemEnvironmentConfigurationSource
,SystemPropertiesConfigurationSource
,VersionedRedisConfigurationSource
public interface ConfigurationSource<A extends ConfigurationQuery<A,B>,B extends ExecutableConfigurationQuery<A,B>,C extends ListConfigurationQuery<C>>
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
-
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
-