O'Reilly logo

Java EE 7 Development with NetBeans 8 by David R. Heffelfinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing aspect-oriented programming with interceptors

Sometimes, we wish to execute some logic just before and/or just after a method's main logic executes. For example, we might want to measure the execution time of a method to track down performance problems, or we might want to send a message to a log every time we enter and leave a method, to make it easier to track down bugs or exceptions.

The most common solution to these kinds of problems is to add a little bit of code at the beginning and end of every method, implementing the logic to profile or log in each method. This approach, however, has problems: the logic needs to be implemented several times, and; if we later wish to modify or remove the functionality, we need to modify several ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required