Using interceptors with timers

Interceptors provide a convenient way of incorporating required functionality of an application into the application without cluttering up the business logic. For example, security and logging operations may be required when certain methods of an application execute. Code could be added directly to the method to perform these actions. However, they are tangential to the method itself and can obscure the business logic of the method.

An interceptor is a technique permitting the addition of this functionality, but places the code implementing the functionality outside of the actual function. When the method executes, the interceptor is executed first. Within the interceptor, its code can be executed before and after ...

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.