Interface ConfigurationLoader<A,B extends ConfigurationLoader<A,B>>
- Type Parameters:
A
- the configuration typeB
- the configuration loader type
- All Known Implementing Classes:
AbstractConfigurationLoader
,BootConfigurationLoader
,BootNetClientConfigurationLoader
,BootNetServerConfigurationLoader
,ConfigurationLoaderSupport
,GrpcBaseConfigurationLoader
,GrpcClientConfigurationLoader
,GrpcServerConfigurationLoader
,HttpClientConfigurationLoader
,HttpServerConfigurationLoader
,JOSEConfigurationLoader
,LDAPClientConfigurationLoader
,LettuceRedisClientConfigurationLoader
,VertxSqlClientConfigurationLoader
,WebServerConfigurationLoader
A configuration loader is used to load a configuration object from a ConfigurationSource
.
A typical usage is:
ConfigurationSource<?,?> source = ...
SomeConfiguration configuration = ConfigurationLoader
.withConfiguration(SomeConfiguration.class)
.withParameters("environment", "test", "profile", "perf")
.withSource(source)
.load()
.block();
Please refer to @Configuration
documentation to learn how to define a proper configuration type.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionload()
Loads the configuration from the configuration source with the specified parameters.static <E> ConfigurationLoader
<E, ?> withConfiguration
(Class<E> configurationType) Creates a configuration loader to load configuration of the specified type.static <E,
F> ConfigurationLoader <E, ?> withConfigurator
(Class<F> configuratorType, Function<Consumer<F>, E> configurationCreator) Creates a configuration loader with a specified configurator type and configuration creation function.default B
withParameters
(ConfigurationKey.Parameter... parameters) Defines parameters that specify the context in which configuration properties are to be retrieved.default B
withParameters
(String k1, Object v1) Defines one parameter that specifies the context in which configuration properties are to be retrieved.default B
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 B
Defines three parameters that specify the context in which configuration properties are to be retrieved.default B
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 B
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 B
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 B
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 B
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 eigth parameters that specify the context in which configuration properties are to be retrieved.default B
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 B
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.withSource
(ConfigurationSource<?, ?, ?> source) Specifies the configuration source from where to load configuration properties.
-
Method Details
-
withConfiguration
static <E> ConfigurationLoader<E,?> withConfiguration(Class<E> configurationType) throws IllegalArgumentException Creates a configuration loader to load configuration of the specified type.
- Type Parameters:
E
- the configuration type to load- Parameters:
configurationType
- a class of type E- Returns:
- a configuration loader
- Throws:
IllegalArgumentException
- if the specified type is not an interface
-
withConfigurator
static <E,F> ConfigurationLoader<E,?> withConfigurator(Class<F> configuratorType, Function<Consumer<F>, E> configurationCreator) Creates a configuration loader with a specified configurator type and configuration creation function.
The configurator is acting as a builder: it exposes single argument methods to set the values of configuration properties whose names are the name of the methods.
Then the creator builds the configuration from the configurator.
Unlike
withConfiguration(Class)
, it is possible to load a configuration for any kind of object and not only interface since the creation of the configuration instance is delegated to the supplied configuration creator.- Type Parameters:
E
- the configuration type to loadF
- the configurator type- Parameters:
configuratorType
- a class of type FconfigurationCreator
- a function that builds the configuration from the configurator- Returns:
- a configuration loader
-
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 configuration loader
-
withParameters
default B 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 configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
default B 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 configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
default B 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 configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
default B 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 configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
default B 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 configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
default B 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 configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
default B 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 eigth 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 configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
default B 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 configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
default B 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 configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
Defines parameters that specify the context in which configuration properties are to be retrieved.
- Parameters:
parameters
- an array of parameters- Returns:
- the configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withParameters
Defines parameters that specify the context in which configuration properties are to be retrieved.
- Parameters:
parameters
- a list of parameters- Returns:
- the configuration loader
- Throws:
IllegalArgumentException
- if parameters were specified more than once
-
withSource
Specifies the configuration source from where to load configuration properties.
- Parameters:
source
- a configuration source- Returns:
- the configuration loader
-
load
Loads the configuration from the configuration source with the specified parameters.
- Returns:
- a mono emitting the resulting configuration object
- Throws:
ConfigurationLoaderException
- if there was an error loading the configuration
-