AOP : The full name is Aspect Oriented Programming, namely:Aspect-oriented programming。
Simply put, it is to extract the repetitive code of our program, when it needs to be executed, the technology of dynamic proxy is used to enhance our existing methods without modifying the source code.
35.2.2 The role and advantages of AOP
effect:
During the running of the program, the source code is not modified to enhance the existing methods.
Advantage:
Reduce repetitive code
Improve development efficiency
Easy to maintain
35.2.3 Implementation of AOP
Use dynamic proxy technology
35.3 AOP in Spring
35.3.1 AOP related terms
Joinpoint:
The so-called connection points are those points that are intercepted. In spring, these points refer to methods, because spring only supports connection points of method types.
Pointcut:
The so-called entry point refers to the definition of which Joinpoint we want to intercept.
Advice (notification/enhancement):
The so-called notification means that the thing to do after intercepting Joinpoint is notification.
Notification types: pre-notification, post-notification, exception notification, final notification, surround notification.
Introduction(引介):
Introduction is a special kind of notification. On the premise of not modifying the class code, Introduction can dynamically add some methods or fields to the class at runtime.
Target:
The target object of the agent.
Weaving:
Refers to the process of applying enhancements to the target object to create a new proxy object.
Spring uses dynamic proxy weaving, while AspectJ uses compile-time weaving and class-loading weaving.
Proxy:
After a class is woven and enhanced by AOP, a result proxy class is generated.
Aspect:
It is a combination of entry point and notification (introduction).
35.4 XML-based AOP configuration steps in spring
1. Give the notification bean to spring to manage it;