Book Image

SPRING COOKBOOK

Book Image

SPRING COOKBOOK

Overview of this book

Table of Contents (19 chapters)
Spring Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introduction


Aspect-oriented programming (AOP) is about inserting and executing, at runtime, extra pieces of code at various points of the normal execution flow of a program. In AOP terminology, these pieces of code are methods that are called advices and the classes containing them are called aspects. AOP is complementary to object-oriented programming.

This chapter is about the Spring AOP framework, which enables us to execute advices before and after methods of Spring beans (controller methods, service methods, and so on). For more extensive AOP functionality, AspectJ is the reference Java AOP framework and gets integrated seamlessly with Spring. However, it's more complex to use and requires a customized compilation process.

In the first recipe, we will create an aspect class and configure Spring to use it. We will use this aspect class in the following recipes, where we will go through the different types of advice offered by Spring AOP, using practical use cases.