Tuesday, June 5, 2007

Implement logging as an Aspect using Spring's AOP Framework

clipped from www.devx.com
Implement Logging as an Aspect Using Spring's AOP Framework
Aspect-oriented programming (AOP) enables you to write code for a crosscutting functionality and then apply it declaratively to existing code. Logging is a prime candidate for implementation as an aspect, and Spring offers the AOP framework to get it done. 


The AOP technique helps you add design and run-time behavior to an object model in a non-obtrusive manner by using static and dynamic crosscutting. By using AOP, you can write code for a crosscutting functionality such as logging and then apply it declaratively (via annotations or XML declaration) to already existing code. Also, you can inject the code into plain old Java objects (POJOs) for third-party software for which you don’t have either the source code or the license to modify it. In this way, AOP provides for a flexible and loosely coupled architecture.

Click to enlarge
Figure 2. Logging Module Provides a Blanket to Other Services

0 comments: