Reputation: 9232
I am reading some tutorials regarding Interceptors
in java ee, but there are some themes which are not covered extensively. Therefore I would be greatful to anyone having answers to the following questions:
1) In which order are Interceptors execueted in case the target class contains an @AroundInvoke
method as:
@Interceptors({PrimaryInterceptor.class, SecondaryInterceptor.class})
@Stateful
public class OrderBean {
...
@AroundInvoke
private void last(InvocationContext ctx) { ... }
...
}
I have the impression that first it is excecuted the taget class Interceptor, namely the last
method in the above case and then the two class-level Interceptors in the order specified inside the annotation. Am I right?
2) What are Timeout Interceptors
(containing methods with the annotation @AroundTimeout
) and when are the excecuted?
Upvotes: 2
Views: 3730
Reputation: 27496
Quoting the documentation.
By default the ordering of interceptors when invoking a method are
External interceptors
Default interceptors, if present
Class interceptors, if present
Method interceptors, if present
Interceptor method on the bean class (using @AroundInvoke
)
Within each group (default, class, method) the order of the interceptors are from left to right as defined in the @Interceptors
annotation, and then the XML
interceptors.
And for the second question - @AroundTimeout
is used together with EJB timers, interceptor is fired whenever method annotated with @Schedule
timeouts - see this example.
Upvotes: 4