Annotation Interface Order
Order in a Micronaut application is important in multiple aspects including but note limited to:
- Controlling bean selection and prioritization
- Ordering injected
Listcollections. - Ordering AOP method interceptors
- Ordering HTTP filters
This annotation can be used to control the order by specifying a numerical value that sorts components in the desired order
The lowest value takes precedence: a component annotated @Order(1) comes before one
annotated @Order(100), and Ordered.HIGHEST_PRECEDENCE is
the most negative value rather than the largest one.
jakarta.annotation.Priority is mapped to this annotation at compile time with its
value unchanged, so a bean annotated @Priority(10) orders as @Order(10) and the
lowest priority value wins. That is the direction Jakarta Interceptors and Jakarta RESTful Web
Services give the priorities they define; a specification that prefers the highest value instead,
such as the selection of a CDI alternative, needs the value negated by whoever reads it. The
mapping adds to the metadata rather than replacing it, so jakarta.annotation.Priority is
still readable as written alongside the mapped order.
- Since:
- 2.0
- Author:
- Sean Carroll
- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
int valueThe order value. Defaults to zero (no order).- Returns:
- the order
- Default:
0
-