Spring AOP Terminology, Terms We Should Know Before Entering The AOP
In this tutorial we are going to learn about Spring AOP Terminology, Terms We Should Know Before Entering The AOP.
Aspect Oriented Programming (AOP) compliments OOPs in the sense that it also provides modularity. But the key unit of modularity is aspect than class.
AOP breaks the program logic into distinct parts (called concerns). It is used to increase modularity by cross-cutting concerns.
A cross-cutting concern is a concern that can affect the whole application and should be centralized in one location in code as possible, such as transaction management, authentication, logging, security etc.
AOP concepts and terminologies are as follows:
- Join point
- Target Object
- AOP Proxy
Join point is any point in your program such as method execution, exception handling, field access etc. Spring supports only method execution join point.
Advice represents an action taken by an aspect at a particular join point. There are different types of advices:
- Before Advice: it executes before a join point.
- After Returning Advice: it executes after a joint point completes normally.
- After Throwing Advice: it executes if method exits by throwing an exception.
- After (finally) Advice: it executes after a join point regardless of join point exit whether normally or exceptional return.
- Around Advice: It executes before and after a join point.
It is an expression language of AOP that matches join points.
It means introduction of additional method and fields for a type. It allows you to introduce new interface to any advised object.
It is the object i.e. being advised by one or more aspects. It is also known as proxied object in spring because Spring AOP is implemented using runtime proxies.
It is a class that contains advices, joinpoints etc.
It is an aspect that contains only one advice.
It is used to implement aspect contracts, created by AOP framework. It will be a JDK dynamic proxy or CGLIB proxy in spring framework.
It is the process of linking aspect with other application types or objects to create an advised object. Weaving can be done at compile time, load time or runtime. Spring AOP performs weaving at runtime.