Pro Spring 3 pp 229-268 | Cite as

More Spring AOP and Annotations

  • Clarence Ho


In this chapter, we go into more detail about the AOP features available in Spring. In particular, we look at the topic in a much more real-world light: we explore the framework services in Spring that allow for transparent application of AOP, we cover real-world usage of AOP in the context of the sample application, and we also discuss overcoming the limitations of Spring AOP using Spring/AspectJ integration. More specifically, this chapter covers the following:
  • Advanced use of pointcuts: This chapter finishes discussing pointcutting by looking at both ComposablePointcut and ControlFlowPointcut. This section also summarizes the whole pointcut discussion and looks at the appropriate techniques you should employ when you are using pointcuts in your application.

  • Introductions: Mentioned briefly in the previous chapter, introductions allow you to add interface implementations dynamically to any object on the fly using the familiar interceptor concept.

  • AOP framework services: We skipped over this topic completely in the previous chapter and focused solely on assembling AOP proxies and advice chains manually. However, in true Spring fashion, the framework fully supports configuring AOP transparently and declaratively. In this section, we look at three ways (the ProxyFactoryBean class, the aop namespace, and @AspectJ-style annotations) to inject declaratively defined AOP proxies into your application objects as collaborators, thus making your application completely unaware that it is working with advised objects.

  • Integrating AspectJ: AspectJ is a fully featured AOP implementation. The main difference between AspectJ and Spring AOP is that AspectJ applies advice to target objects via weaving (either compile-time or load-time weaving), while as discussed in the previous chapter, Spring AOP is based on a proxy. The feature set of AspectJ is much greater than that of Spring AOP, but it is much more complicated to use than Spring. AspectJ is a good solution when you find that Spring AOP lacks a feature you need. Starting from version 2.0, you can take full advantage of Spring features when configuring your AspectJ aspects.


Previous Chapter Framework Service Class Package Public Class Advice Class 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Clarence Ho and Rob Harrop 2012

Authors and Affiliations

  • Clarence Ho

There are no affiliations available

Personalised recommendations