Annotation Type Order
@Retention(RUNTIME) @Target({TYPE,METHOD,FIELD}) @Documented public @interface Order
@Order
defines the sort order for an annotated component.The
value()
is optional and represents an order value as defined in theOrdered
interface. Lower values have higher priority. The default value isOrdered.LOWEST_PRECEDENCE
, indicating lowest priority (losing to any other specified order value).NOTE: Since Spring 4.0, annotation-based ordering is supported for many kinds of components in Spring, even for collection injection where the order values of the target components are taken into account (either from their target class or from their
@Bean
method). While such order values may influence priorities at injection points, please be aware that they do not influence singleton startup order which is an orthogonal concern determined by dependency relationships and@DependsOn
declarations (influencing a runtime-determined dependency graph).Since Spring 4.1, the standard
Priority
annotation can be used as a drop-in replacement for this annotation in ordering scenarios. Note thatPriority
may have additional semantics when a single element has to be picked (seeAnnotationAwareOrderComparator.getPriority(java.lang.Object)
).Alternatively, order values may also be determined on a per-instance basis through the
Ordered
interface, allowing for configuration-determined instance values instead of hard-coded values attached to a particular class.Consult the javadoc for
OrderComparator
for details on the sort semantics for non-ordered objects.- Since:
- 2.0
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
Ordered
,AnnotationAwareOrderComparator
,OrderUtils
,Priority
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description int
value
The order value.
Element Detail
value
int value
The order value.Default is
Ordered.LOWEST_PRECEDENCE
.- See Also:
Ordered.getOrder()
- Default:
- 2147483647