AOP Terminologies and Keywords

Posted by Dhiraj Ray on February 16th, 2017

 

What is AOP?
AOP is software paradigm aims to achieve modularity using Cross Cutting Concerns.Cross Cutting Concerns can be explianed as any functionality that affects multiple points of an application.It helps us to fill the gaps in modular programming left in inhertiance or delegation.
One of the key components in spring is spring AOP.The module helps us provide declarative enterprise services.

Aspect
The modularization of concern is known as Aspect.In spring,Aspect is a class with special priviliges and are annotaed with @Aspect to represent Aspects.

JoinPoint
A joinpoint is a point in the execution of the application where an aspect can be plugged in.Joinpoint has information about actual method call that triggered the advice so that whichever method triggered the corresponding aspect can be traced. This point could be a method being called, an exception being thrown, or even a field being modified.
These are the points where your aspect code can be inserted into the normal flow of your application to add new behavior.

Advice
In AOP terminology the job of an aspect is called Advice.It defines both when and what of the aspect. Spring aspects can work with five kinds of advice
 
Before: The advice functionality takes place before the advised method is invoked.

After: The advice functionality takes place after the advised method completes, regardless of the outcome.

After-returning: The advice functionality takes place after the advised method successfully completes.
 
After-throwing: The advice functionality takes place after the advised method throws an exception.

Around: The advice wraps the advised method, providing some functionality before and after the advised method is invoked.

Pointcut
Pointcut is an AOP terminology for all the points in the execution of your code where you want this advice method to cut in.It defines the Where of the aspect.A pointcut definition matches one or more join points at which advice should be woven.Predicate Expressions are used with advice to set the target of execution.

AOP Proxy
AOP Proxy is an Object created by the AOP framework to execute our service.At run time the Spring weaves our service and target object to create the desired proxy object.

According to OOPS, a method of different class can never execute unless and untill we invoke it.It is almost impossible.To achieve this in AOP, we use AOP proxy.
For example, suppose class A is directly calling class B and class B is internally calling to C and adding some features and then returning to A.This is the concept of proxy.

Weaving
Weaving is the process of applying aspects to a target object to create a new proxied object. The aspects are woven into the target object at the specified join points.It can take place at several points in the target object’s life time
For Spring Complete tutorials and FAQs visit here Spring Tutorials

Like it? Share it!


Dhiraj Ray

About the Author

Dhiraj Ray
Joined: February 14th, 2017
Articles Posted: 2

More by this author