6 Using aspects with Spring AOP

 

This chapter covers

  • Aspect-oriented programming (AOP)
  • Using aspects
  • Using the aspect execution chain

Thus far, we have discussed the Spring context, and the only Spring capability we have used is DI, which is supported by the IoC principle. With DI, the framework manages objects you define, and you can request to use these objects where you need them. As we discussed in chapters 2 through 5, to request a bean’s reference, in most cases, you use the @Autowired annotation. When you request such an object from the Spring context, we say that Spring “injects” the object where you requested it. In this chapter, you’ll learn how to use another powerful technique supported by the IoC principle: aspects.

6.1 How aspects work in Spring

6.2 Implementing aspects with Spring AOP

6.2.1 Implementing a simple aspect

6.2.2 Altering the intercepted method’s parameters and the returned value

6.2.3 Intercepting annotated methods

6.2.4 Other advice annotations you can use

6.3 The aspect execution chain

Summary