Class CPropsFileConfigurationSource
- All Implemented Interfaces:
ConfigurationSource
,DefaultableConfigurationSource
A configuration source that looks up properties in a configuration properties file following the .cprops
file format.
This source supports parameterized configuration properties defined in a configuration file as follows:
web {
server_port=8080
[ profile = "ssl" ] {
server_port=8443
}
}
[ env="dev" ] {
db.url="jdbc:oracle:thin:@dev.db.server:1521:sid"
}
[ env="prod" ] {
db.url="jdbc:oracle:thin:@dev.db.server:1521:sid"
[ zone="eu" ] {
db.url="jdbc:oracle:thin:@prod_eu.db.server:1521:sid"
}
[ zone="us" ] {
db.url="jdbc:oracle:thin:@prod_us.db.server:1521:sid"
}
}
Please refer to the .cprops
format definition for more information on how to create parameterized configuration in the .cprops
format.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.inverno.mod.configuration.internal.AbstractHashConfigurationSource
io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashConfigurationQuery<A,
B extends io.inverno.mod.configuration.internal.AbstractHashConfigurationSource<A, B>>, io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashConfigurationQueryResult<A, B extends io.inverno.mod.configuration.internal.AbstractHashConfigurationSource<A, B>>, io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashExecutableConfigurationQuery<A, B extends io.inverno.mod.configuration.internal.AbstractHashConfigurationSource<A, B>>, io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashListConfigurationQuery<A, B extends io.inverno.mod.configuration.internal.AbstractHashConfigurationSource<A, B>> -
Field Summary
Fields inherited from class io.inverno.mod.configuration.internal.AbstractHashConfigurationSource
defaultingStrategy
Fields inherited from class io.inverno.mod.configuration.internal.AbstractConfigurationSource
decoder, defaultParameters, original
-
Constructor Summary
ConstructorDescriptionCPropsFileConfigurationSource
(Resource propertyResource) Creates a.cprops
file configuration source with the specified resourceCPropsFileConfigurationSource
(Resource propertyResource, SplittablePrimitiveDecoder<String> decoder) Creates a.cprops
file configuration source with the specified resource and string value decoder.CPropsFileConfigurationSource
(InputStream propertyInput) Creates a.cprops
file configuration source with the specified input stream.CPropsFileConfigurationSource
(InputStream propertyInput, SplittablePrimitiveDecoder<String> decoder) Creates a.cprops
file configuration source with the specified input stream and string value decoder.CPropsFileConfigurationSource
(Path propertyFile) Creates a.cprops
file configuration source with the file at the specified path.CPropsFileConfigurationSource
(Path propertyFile, SplittablePrimitiveDecoder<String> decoder) Creates a.cprops
file configuration source with the file at the specified path and the specified string value decoder. -
Method Summary
Modifier and TypeMethodDescriptionReturns the time-to-live duration of the properties loaded withload()
.protected Mono
<List<ConfigurationProperty>> load()
Loads the configuration properties.void
setPropertiesTTL
(Duration ttl) Sets the time-to-live duration of the properties loaded withload()
.withDefaultingStrategy
(DefaultingStrategy defaultingStrategy) Returns a proxy of the defaultable configuration source instance using the specified defaulting strategy.withParameters
(List<ConfigurationKey.Parameter> parameters) Defines parameters that specify the context in which configuration properties are to be retrieved.Methods inherited from class io.inverno.mod.configuration.internal.AbstractHashConfigurationSource
get, list
Methods inherited from class io.inverno.mod.configuration.internal.AbstractConfigurationSource
getDecoder, setDecoder, unwrap, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.configuration.ConfigurationSource
unwrap, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters, withParameters
-
Constructor Details
-
CPropsFileConfigurationSource
Creates a
.cprops
file configuration source with the file at the specified path.- Parameters:
propertyFile
- the path to the.cprops
file
-
CPropsFileConfigurationSource
Creates a
.cprops
file configuration source with the file at the specified path and the specified string value decoder.- Parameters:
propertyFile
- the path to the.cprops
filedecoder
- a string decoder
-
CPropsFileConfigurationSource
Creates a
.cprops
file configuration source with the specified input stream.- Parameters:
propertyInput
- the.cprops
input
-
CPropsFileConfigurationSource
public CPropsFileConfigurationSource(InputStream propertyInput, SplittablePrimitiveDecoder<String> decoder) Creates a
.cprops
file configuration source with the specified input stream and string value decoder.- Parameters:
propertyInput
- the.cprops
inputdecoder
- a string decoder
-
CPropsFileConfigurationSource
Creates a
.cprops
file configuration source with the specified resource- Parameters:
propertyResource
- the.properties
resource
-
CPropsFileConfigurationSource
public CPropsFileConfigurationSource(Resource propertyResource, SplittablePrimitiveDecoder<String> decoder) Creates a
.cprops
file configuration source with the specified resource and string value decoder.- Parameters:
propertyResource
- the.properties
resourcedecoder
- a string decoder
-
-
Method Details
-
withParameters
public CPropsFileConfigurationSource 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
- Specified by:
withParameters
in classio.inverno.mod.configuration.internal.AbstractConfigurationSource<io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashConfigurationQuery<String,
CPropsFileConfigurationSource>, io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashExecutableConfigurationQuery<String, CPropsFileConfigurationSource>, io.inverno.mod.configuration.internal.AbstractHashConfigurationSource.HashListConfigurationQuery<String, CPropsFileConfigurationSource>, String, CPropsFileConfigurationSource> - Parameters:
parameters
- a list of parameters- Returns:
- the executable configuration query
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withDefaultingStrategy
Description copied from interface:DefaultableConfigurationSource
Returns a proxy of the defaultable configuration source instance using the specified defaulting strategy.
- Parameters:
defaultingStrategy
- a defaulting strategy- Returns:
- a new defaultable configuration source
-
setPropertiesTTL
Sets the time-to-live duration of the properties loaded with
load()
.If set to null, which is the default, properties are cached indefinitely.
Note that this ttl doesn't apply to a source created with an
InputStream
which is cached indefinitely since the steam can't be read twice.- Parameters:
ttl
- the properties time-to-live or null to cache properties indefinitely
-
getPropertiesTTL
Returns the time-to-live duration of the properties loaded with
load()
.- Returns:
- the properties time-to-live or null if properties are cached indefinitely
-
load
Description copied from class:io.inverno.mod.configuration.internal.AbstractHashConfigurationSource
Loads the configuration properties.
- Specified by:
load
in classio.inverno.mod.configuration.internal.AbstractHashConfigurationSource<String,
CPropsFileConfigurationSource> - Returns:
- A mono emitting the list of configuration properties
-