Chapter 10. Filters and Interceptors
In case you register more filters and interceptors you might want to define an exact order in which they should be invoked. The order can be controlled by the @Priority
annotation defined by the javax.annotation.Priority
class. The annotation accepts an integer parameter of priority. Providers used in request processing (ContainerRequestFilter
, ClientRequestFilter
) as well as entity interceptors (ReaderInterceptor
, WriterInterceptor
) are sorted based on the priority in an ascending manner. So, a request filter with priority defined with @Priority(1000)
will be executed before another request filter with priority defined as @Priority(2000)
. Providers used during response processing (ContainerResponseFilter
, ClientResponseFilter
) are executed in the reverse order (using descending manner), so a provider with the priority defined with @Priority(2000)
will be executed before another provider with priority defined with @Priority(1000)
.
Read full article from Chapter 10. Filters and Interceptors
No comments:
Post a Comment