Java Reference
In-Depth Information
will be executed around every method execution ( @AroundInvoke [2] ) on annotated
classes. Inside of it, we will call the context.proceed() method that will basically
forward the call to the original receiver. Note that the interceptor can decide (based on
some security logic, for instance) whether the call should be dropped. It could even ana-
lyze or change the returned value.
Finally, we have to enable it in the beans.xml file by adding the following code:
Now, let's move on to just the annotated classes or methods that you want to log using the
@Logged annotation. For instance, refer to the following:
public class TheatreBooker implements Serializable {
// Some code
All calls to the TheatreBooker public methods will now be logged in to the console:
21:02:11 INFO [com.packtpub.wflydevelopment.chapter4
.controller.TheatreBooker$Proxy$_$$_WeldSubclass] (default
task-8) Executing method public int
In the case of multiple interceptors, the order in which they are executed is determined by
the @Interceptor.Priority annotation. Interceptors with lowest priorities will be
called first. Be sure to check the constants defined in the Priority annotation. Your
own interceptor's priorities should be between the APPLICATION and
There are also other interesting CDI mechanisms that we will not cover in this topic, but
are definitely worth exploring: decorators and alternatives. Decorators are basically
Search WWH ::

Custom Search