Basic Concepts
Method Stacks in Threads
When the Java program virtual machine starts, the program code is loaded, and the virtual machines generates into a method call stack for each running line, and the thread runs as the execution unit in the method.
AOP Concepts and goals
AOP is aspect-oriented programming, which actually embeds some other code in your module without modifying the code module.
The goal is to unify the modules to extract and eliminate some of the blocky code scattered in the system (non-logical business).
AOP Terminology diagram
Connection point: Is the method of all threads and can be used as a candidate for embedding code;
Entry point: The last object to be selected as an embedded code;
Facets: implementation of embedded objects;
Enhanced Notifications: Embedded content (some defined methods, including pre-notification, post-notification, exception notification, final notification, surround notification)
Weaving: The entire process of embedding code is called weaving
AOP Principles
The advent of AOP is the presence of some non-business code embedded in the business code, such as a log notification, such as a connection to a database.
1. Modify the source code, over-coupling unrelated business code;
2. Whether the use of inheritance or interface implementation to add unrelated business code, the object will be over-coupling between objects;
3. Using dynamic Proxy mode to implement AOP, let the container to help us embed code.
AOP Usage Parsing
1. Importing jar packages (including core packages and AOP packages)
2. Create a spring core configuration file and import AOP constraints
3. Configure the Bean object, inject into the container, and configure the tangent and tangent points
Note: Commonly used expressions
Execution (< access modifier >?< return type >< method name > (< parameter >) < exception >)
(1)Execution (* com.harry.aop.service.UserService.add (..))
(2)Execution (* com.harry.aop.service.userservic.* (..))
(3)Execution (* * * * (..))
(4) match all methods of Save start Execution (* save* (..))
Framework application: Spring FRAMEWORK-AOP Technology