Tuesday, March 29, 2022

Basics Of Aspect Oriented Programming

Concern

A concern is a part of a system divided on the basis of functionality. It can be as general as the details of the database interaction or as specific as performing a primitive calculation. Usually, code can be separated into logical sections, each addressing separate concerns.  A concern can be categorized into two types as below:-
  1. Core-concerns, &
  2. Cross-cutting concerns This type of concern is shared across multiple application modules and represent functionalities for secondary requirements for example logging, security, and data transfer are concerns that are needed in almost every module of an application, hence also called system-wide concerns.



AOP

Most of the enterprise applications have some common crosscutting concerns that are applicable to different types of Objects and modules. Some of the common crosscutting concerns are logging, transaction management, data validation, etc.





How to Enable AOP

<!-- Enable AspectJ style of Spring AOP -->
<aop:aspectj-autoproxy />

How to Configure Aspects

There are 2 ways to configure the aspects as below:

Annotation Based










XML Based




References:
1. https://medium.com/anatta-design/cross-cutting-concern-aadf4f51a5c1
2. https://www.journaldev.com/2583/spring-aop-example-tutorial-aspect-advice-pointcut-joinpoint-annotations

No comments:

Post a Comment