Spring AOP tutorial

AOP refers to Aspect Oriented Programming which behaves like OOPs as both provides the concept of modularity. But the difference is it uses aspect rather than class for the unit of modularity.
Aspect Oriented Programming breaks down program logic into distinct parts called concerns. A cross-cutting concerns are aspects of a program that affect other concerns like transaction management, authentication, logging etc.

Spring AOP module provides the facility to add extra functionality before or after the method execution.
Note: Aspect Oriented Programming AOP is like triggers in programming languages like java, Perl, .NET etc.

AOP Terminologies:

An aspect represents a class that contains advices, join points etc like transaction management. An aspect can be configured through Spring XML configuration or spring AspectJ integration.
Join point:
Joint point represents a point in our application where we can plug-in AOP aspect. It can be method execution, exception handling, field access etc. Spring AOP only supports method execution joint type.
It represents the actual action to be taken by an aspect at a particular join point. In programming point view it represents the methods to be executed at a particular join point.
It represents the expression which is matched with join points to determine whether advice to be executed or not.
It provides the facility to add new methods or attributes to existing classes.
Target object:
It is an object on which advices are applied. It always be proxied object in spring because Spring AOP is implemented using runtime proxies.
Weaving is the process of linking aspects with other application types or objects to create the advised proxy objects. This can be done at compile time, load time or at runtime. Spring AOP performs weaving at the runtime.

AOP Advice Types:

It executes before the method execution.
It executes after the method execution. It not depends upon the method outcome.
It executes after the method execution when method completes successfully.
It executes after the method execution when method exits by throwing an exception.
It executes before and after the advised method is called.