Book Image

Spring 2.5 Aspect Oriented Programming

Book Image

Spring 2.5 Aspect Oriented Programming

Overview of this book

Developing powerful web applications with clean, manageable code makes the maintenance process much easier. Aspect-Oriented Programming (AOP) is the easiest and quickest way to achieve such results. Spring is the only Java framework to offer AOP features. The combined power of Spring and AOP gives a powerful and flexible platform to develop and maintain feature-rich web applications quickly. This book will help you to write clean, manageable code for your Java applications quickly, utilizing the combined power of Spring and AOP. You will master the concepts of AOP by developing several real-life AOP-based applications with the Spring Framework, implementing the basic components of Spring AOP: Advice, Joinpoint, Pointcut, and Advisor. This book will teach you everything you need to know to use AOP with Spring. It starts by explaining the AOP features of Spring and then moves ahead with configuring Spring AOP and using its core classes, with lot of examples. It moves on to explain the AspectJ support in Spring. Then you will develop a three-layered example web application designed with Domain-Driven Design (DDD) and built with Test-Driven Development methodology using the full potential of AOP for security, concurrency, caching, and transactions.
Table of Contents (13 chapters)

Introductions


Introductions are a very strong component of the Spring AOP. They permit us to dynamically introduce new one-object functionalities as the implementation of interfaces on existing objects:

  • To create a mixin, adding to the state held in the object. This is probably the most important use.

  • To expose additional states associated with a special TargetSource. This is used within Spring, for example, with scripting support.

  • To expose an object or object graph in a different way—for example, making an object graph implement the XML DOM interfaces.

Introductions are often mixins that allow one to obtain the effects of multiple inheritance in Java.

To allow the implementation of interfaces at runtime rather than more simply at compile time makes sense in cases where the crosscutting functionalities don't allow us to easily choose the way at compile time.

In the documentation of Spring 1.x, we had introductions, object locking, and modification detection as examples of use.

In the case...