Java Reference
In-Depth Information
Listing 5.9. Overriding default-, class-, and method-level interceptors
Here the example is almost the same as before, but now the <method> tag has been added.
This ejb-jar.xml file configuration will override any default-, class-, and method-level an-
notations when the placeOrder() method is called. Instead, MyInterceptor will be
executed.
Defining interceptors with the @Interceptors annotation and using the ejb-jar.xml file
to either configure interceptors as well or to override the annotations is all about enabling
interceptors, and that's only part of the story. Sometimes it's necessary to disable intercept-
ors. We'll look at this next.
Disabling interceptors
In some cases, it may be necessary to disable interceptors. There are two annotations you
can use to disable interceptors at either the default or class levels if you need to. Ap-
plying the @javax.interceptor.ExcludeDefaultInterceptors annotation
on either a class or a method disables all default interceptors on the class or method.
Similarly, the @javax.interceptor.ExcludeClassInterceptors annotation
disables class-level interceptors for a method. For the following example, both default-
and class-level interceptors are disabled for the findOrderById() method, but the
Search WWH ::




Custom Search