
Aspect Oriented Programming (AOP) |
|
A lot of software systems have certain concerns which crosscut across (spread across) multiple modules, termed in AOP world as “Crosscutting Concerns”. A system could have core concerns and system-level concerns. For example in an application processing a business request is a core concern and logging, authentication and transaction management will be its system-level concerns. Logging of exceptions or debug information may crosscut across multiple modules within a system. In case of “Struts” application it would be Action classes where one would like to log the exceptions or debug information. In order to achieve this one would have to write code that would log the exceptions or debug information across all Action classes wherever needed. Hence a concern in a system can be defined as a particular goal, or an area of interest within a system. Using current programming methodologies crosscutting concerns span over multiple modules, resulting in a system which is difficult to evolve and manage. Aspect Oriented Programming (AOP) is an approach to separate out the crosscutting concerns there by provided modularization of concerns. Before we proceed towards the example of solving logging inside a struts action class using AOP we need to understand some of the core terminology used in AOP. To implement the logging concern as an aspect in a struts application I have used AspectJ AOP framework, which was developed by XEROX Corporation and is now a part of eclipse project. You can read more about AspectJ at www.aspectj.org. |

Download full article as PDF.