Using interceptors to handle application statistics

The gathering of application statistics is a common requirement. It may be desirable to determine how many times a method is executed or how much time is spent in a method. This recipe illustrates collecting both of these types of statistics using a chain of interceptors.

Getting ready

The process for developing and using interceptors for an application's statistics is similar to previous techniques and include:

  1. Creating a class to maintain the application's statistics
  2. Creating interceptors to support the gathering of the statistics
  3. Using the @Interceptors annotation to designate a target method

    In this recipe we will create two interceptors. The first will keep track of the number of times a method ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.