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)

ProxyFactoryBean


As we've previously seen, we have at our disposal two kinds of proxies: the ones provided by JDK, which we can also write as seen in the previous section, and those provided by the CGLIB, which work in a transparent manner.

In everyday use, we don't directly use either of the two implementations. We rather rely on a factory that provides the proxy class ready for use. This allows us to focus our attention and development on crosscutting concerns to apply through the proxy, rather than focus on the proxy.

To make our job easier Spring provides the class org.springframework.aop.config.ProxyFactoryBean, and we mostly use it in a declarative way by doing the "dirty work" that we have seen. It is necessary to create and use proxies in a programmatic way. ProxyFactoryBean is a central component in SpringAOP because if proxies act as links among advices, targets, joinpoints, and advisors, the ProxyFactoryBean performs its tasks in a declarative manner rather than by code in a programmatic...