Annotation Interface Configuration
Used on an interface to indicate a configuration.
A configuration should be created when there's a need to provide configuration data in a module. Configuration properties are declared as non-void no-argument methods in an interface. Default values can be specified in default methods.
@Configuration
public interface SomeConfig {
String property1();
default int property2() {
return 0;
}
}
For a given configuration, a module bean named after the configuration interface [ConfigurationInterface]Bean will be generated to provide a concrete configuration inside the enclosing module. This
bean will load configuration data from a ConfigurationSource
and a list of parameters when provided within the module, when no configuration source is specified, the default implementation
is loaded. A configurer can also be provided to override all or part of the loaded data.
The generated bean also provides a configurator to programmatically create a concrete configuration in an efficient way. A Consumer
of such configurator is called a configurer:
Config config = SomeConfigBean.ConfigConfigurator
.create(configConfigurator -> configConfigurator.property1("someValue").property2(42));
- Since:
- 1.0
- Author:
- Jeremy Kuhn
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Indicates whether a bean should be generated in addition to the configuration loader.Indicates a name identifying the configuration bean in the module, defaults to the name of the class.boolean
Indicates whether the generated bean should be overridable.
-
Element Details
-
name
String nameIndicates a name identifying the configuration bean in the module, defaults to the name of the class.
- Returns:
- A name
- Default:
""
-
generateBean
boolean generateBeanIndicates whether a bean should be generated in addition to the configuration loader.
- Returns:
- true to generate a bean, false otherwise
- Default:
true
-
overridable
boolean overridableIndicates whether the generated bean should be overridable.
- Returns:
- true to generate a bean, false otherwise
- Default:
true
-