Annotation Type EachProperty
-
@Documented @Retention(RUNTIME) @Target({METHOD,TYPE}) @Singleton @ConfigurationReader public @interface EachPropertyThis annotation allows driving the production of
Beandefinitions from either configuration or the presence of another bean definitionFor example:
@EachProperty("foo.bar") public class ExampleConfiguration { }In the above example a new
ExampleConfigurationbean will be created for each item under thefoo.barkey in application configurationA reference to the configuration entry name can be obtained with the
Parameterannotation applied to a constructor argument:@EachProperty("foo.bar") public class ExampleConfiguration { ExampleConfiguration(@Parameter String name) { ... } }In the above example for a configuration property of
foo.bar.test, the value of thenameargument will be"test"The bean is created as a singleton with a Named qualifier matching the configuration entry name, thus allowing retrieval with:
ExampleConfiguration exampleConfiguration = applicationContext.getBean(ExampleConfiguration.class, Qualifiers.byName("test"));Or alternatively dependency injection via the Named qualifier.
This annotation is typically used in conjunction with
EachBean. For example, one can drive the configuration of other beans with theEachBeanannotation:@EachBean(ExampleConfiguration) @Singleton public class ExampleBean { ExampleBean(ExampleConfiguration config) { ... } }- Since:
- 1.0
- See Also:
EachBean,ConfigurationProperties
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.StringvalueDefines the property thisEachPropertyis driven by.
-
-
-
Element Detail
-
value
@AliasFor(annotation=ConfigurationReader.class, member="value") java.lang.String value
Defines the property thisEachPropertyis driven by. Should be in kebab case form. Example: "my-app.bar".- Returns:
- The property that this bean is driven by
-
-
-
includes
@AliasFor(annotation=ConfigurationReader.class, member="includes") java.lang.String[] includes
- Returns:
- The names of the properties to include
- Default:
- {}
-
-
-
excludes
@AliasFor(annotation=ConfigurationReader.class, member="excludes") java.lang.String[] excludes
- Returns:
- The names of the properties to exclude
- Default:
- {}
-
-
-
list
boolean list
- Returns:
- True if the beans should be bound from a list. By default
EachPropertybinds to a map where the key is a string and the value is an instance of the annotated class.
- Default:
- false
-
-