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)

Chapter 4. AspectJ Support

In this chapter, we will see how AspectJ facilitates Spring AOP. We will particularly focus on syntax for pointcuts and the possibility of using IoC on domain objects: either the definition is applied to the hierarchies of objects (context bindings), or pointcuts are applied on the names of Spring beans. We will see how aspects are set up in complex contexts to avoid conflicts, and which advanced functionalities are allowed (annotations on annotations). The possibility of using AspectJ syntax means that we can define the rules on which aspects can be applied through pointcuts in a better way. There are two modalities to use AspectJ's features with Spring: by means of annotations and XML configuration.

AspectJ annotations

The annotations introduced in Java 5 allow us to add features in a very simple way.

In our context, they allow us to define aspects and other AOP components already seen in this book, by means of annotations.

The power of this functionality lies in...