Document common use cases for @Order vs @Priority vs @DependsOn
Issue: SPR-16213
(cherry picked from commit 84699c8)
This commit is contained in:
@@ -23,31 +23,33 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Marks a constructor, field, setter method or config method as to be
|
||||
* autowired by Spring's dependency injection facilities.
|
||||
* Marks a constructor, field, setter method or config method as to be autowired
|
||||
* by Spring's dependency injection facilities.
|
||||
*
|
||||
* <p>Only one constructor (at max) of any given bean class may carry this
|
||||
* annotation, indicating the constructor to autowire when used as a Spring
|
||||
* bean. Such a constructor does not have to be public.
|
||||
* <p>Only one constructor (at max) of any given bean class may carry this annotation,
|
||||
* indicating the constructor to autowire when used as a Spring bean. Such a
|
||||
* constructor does not have to be public.
|
||||
*
|
||||
* <p>Fields are injected right after construction of a bean, before any
|
||||
* config methods are invoked. Such a config field does not have to be public.
|
||||
* <p>Fields are injected right after construction of a bean, before any config
|
||||
* methods are invoked. Such a config field does not have to be public.
|
||||
*
|
||||
* <p>Config methods may have an arbitrary name and any number of arguments;
|
||||
* each of those arguments will be autowired with a matching bean in the
|
||||
* Spring container. Bean property setter methods are effectively just
|
||||
* a special case of such a general config method. Such config methods
|
||||
* do not have to be public.
|
||||
* <p>Config methods may have an arbitrary name and any number of arguments; each of
|
||||
* those arguments will be autowired with a matching bean in the Spring container.
|
||||
* Bean property setter methods are effectively just a special case of such a general
|
||||
* config method. Such config methods do not have to be public.
|
||||
*
|
||||
* <p>In the case of multiple argument methods, the 'required' parameter is
|
||||
* applicable for all arguments.
|
||||
* <p>In the case of a multi-arg constructor or method, the 'required' parameter is
|
||||
* applicable to all arguments. Individual parameters may be declared as Java-8-style
|
||||
* {@link java.util.Optional}, overriding the base required semantics.
|
||||
*
|
||||
* <p>In case of a {@link java.util.Collection} or {@link java.util.Map}
|
||||
* dependency type, the container can autowire all beans matching the
|
||||
* declared value type. For such purposes, the map keys must be declared
|
||||
* as type String and will be resolved to the corresponding bean names.
|
||||
* Alternatively, a target bean may also be of type {@code Collection} or
|
||||
* {@code Map} itself, getting injected as such.
|
||||
* <p>In case of a {@link java.util.Collection} or {@link java.util.Map} dependency type,
|
||||
* the container autowires all beans matching the declared value type. For such purposes,
|
||||
* the map keys must be declared as type String which will be resolved to the corresponding
|
||||
* bean names. Such a container-provided collection will be ordered, taking into account
|
||||
* {@link org.springframework.core.Ordered}/{@link org.springframework.core.annotation.Order}
|
||||
* values of the target components, otherwise following their registration order in the
|
||||
* container. Alternatively, a single matching target bean may also be a generally typed
|
||||
* {@code Collection} or {@code Map} itself, getting injected as such.
|
||||
*
|
||||
* <p>Note that actual injection is performed through a
|
||||
* {@link org.springframework.beans.factory.config.BeanPostProcessor
|
||||
|
||||
Reference in New Issue
Block a user