Chapter 12. Spring AOP and AspectJ

Over the last seven years or so, aspect-oriented programming (AOP) has emerged as a superior programming methodology. AOP addresses the pieces of a system that cannot be modularized with object-oriented programming (OOP) alone. As described by Ramnivas Laddad in his excellent book, AspectJ In Action:

In the evolutionary view of programming methodology, procedural programming introduced functional abstraction, OOP introduced object abstraction, and now AOP introduces concern abstraction.

This chapter will help you understand AOP and begin to apply it though the use of the Spring framework. By the end of this chapter, you will:

  • Recognize the differences between AOP and OOP

  • Comprehend the core concepts and terminology of AOP

  • Understand how Spring AOP uses AspectJ

  • Know the features of Spring AOP

  • Be able to apply Spring AOP

So let's get started by comparing some concepts within AOP and OOP.

Comparing Aspect-Oriented Programming to Object-Oriented Programming

Object-oriented programming (OOP) has been around for many years and has been very successful. After all, the Java programming language is based on OOP concepts. One of the major goals of OOP was to provide improved maintainability and reusability. OOP dramatically improved the modularity and reusability of applications through such concepts as encapsulation, inheritance, and polymorphism. It made possible a new level of modularity using these concepts. However, situations still exist where OOP solutions ...

Get Beginning Spring Framework 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.