O'Reilly logo

Professional Java™ Development with the Spring Framework by Colin Sampaleanu, Thomas Risberg, Alef Arendsen, Juergen Hoeller, Rod Johnson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Spring and AOP

Aspect-Oriented Programming (AOP) is an important technology, well-suited to solving many common problems. Spring offers AOP features to complement its IoC features and ensure that enterprise service code does not pollute your application objects.

In keeping with Spring's layered architecture, Spring's AOP features are separate from the core IoC container. You are not forced to use AOP with Spring. However, most users choose to do so, if only to leverage valuable out-of-the-box services provided by Spring, which are delivered using AOP.

Spring takes a pragmatic approach to AOP. You can use as little AOP as you want, or integrate with AspectJ to harness the power of AOP extensions to the Java language. While learning how to exploit the full power of AOP is likely to take the industry years, Spring enables incremental adoption of AOP without the risk of dragging projects to the bleeding edge. We recommend that you take the time to understand the basic concepts of this important technology, which can help you solve practical problems today.

Goals

Enterprise applications often face crosscutting concerns—concerns that might potentially affect code in many objects. Consider the following requirements:

  • Every operation on the AccountManager interface should be performed within a transaction.

  • The return values of certain expensive methods should be cached for a specified period of time.

  • Whenever an instance field is modified in a domain object, the object should be marked ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required