Principles of aop in Spring and Springaop
FeaturesFor Aspect-Oriented aop, you do not need to modify the source code for the extended functions.
AOP is short for Aspect Oriented Programming.
Aop adopts a horizontal extraction mechanism to replace the repetitive code of the traditional vertical Inheritance System
We have implemented the add () method to add new users to the database ()
Later, we found that the function needed to be extended, that is, after adding a new user, we need to record the added time and the user
The most primitive method is to directly modify the source code, the red letter in the image, but this is the original structured programming idea, not conducive to program Expansion
By inheriting the parent class and using the super (point) parent class method, add the log function to the subclass Method
(Personal opinion) or parent-child exchange,
(Personal opinion) or inherit the subclass to obtain the add () method. Create an addWithLog () method in the subclass.