Reputation: 2715
I have a controller method which is annotated with 2 custom annotations.
One of them is processed with HandlerInterceptorAdapter
which is a part of Spring MVC.
The other is processed by AOP @Aspect
.
It appears that the first one always takes precedence over the last.
Putting @Order(value = Ordered.HIGHEST_PRECEDENCE)
does not work for this case.
Is there any way to arrange the execution order between these two?
Upvotes: 2
Views: 1342
Reputation: 825
There is an interceptor in Spring ExposeInvocationInterceptor
with @Order(value = Ordered.HIGHEST_PRECEDENCE + 1)
, & javadoc says
If used, this interceptor will normally be the first in the interceptor chain.
So, there can't be any interceptor with higher order than this. So, if you add +1
, i.e. the same precedence as ExposeInvocationInterceptor
(or higher), it will work.
So, I have tried following & it works:
@Order(value = Ordered.HIGHEST_PRECEDENCE + 1)
@Order(value = Integer.MIN_VALUE + 1)
as apparently Ordered.HIGHEST_PRECEDENCE = Integer.MIN_VALUE
.
Upvotes: 2