spring framework _AOP and notes

1. What is AOP: stands for Aspect Oriented Programming that is: Oriented Programming.

In simple terms it is to repeat our program code extracted, when you need to perform, using dynamic proxy technology, without modifying the source code, based on our existing methods enhanced.

2. AOP role and advantages

Role: During the program run, does not modify the source code to the existing enhanced method. Advantages: reduce duplication of code to improve development efficiency and easy maintenance

3. AOP implementationsthe use of dynamic agent technology

4. The dynamic proxy mode and the characteristics

Features:

Bytecode used with the creation, as used with the load.
It differs from the static agent is also here. Because static agent is a bytecode up has been created, and finished loading.
The decorator pattern is a reflection of the static agent.

the way :

Dynamic agent interface
provider: JDK official Proxy class.
Requirements: The minimum proxy class that implements an interface.
Dynamic Proxy subclass
provider: third party CGLib, if reported asmxxxx abnormal, you need to import asm.jar.
Requirements: proxy class is not modified with a final class (class final)

5. The the Spring in detail AOP

AOP related terms:

JoinPoint (connection points):
a so-called connection points are those points being intercepted. In the spring, these points refers to a method, because only the spring type connection point supporting method.
Pointcut (entry point):
The so-called entry points means we have to define the intercept which Joinpoint.
Advice (notification / Enhanced):
The so-called notice refers to Joinpoint after intercepting the thing to do is to inform.
Type of notification: notification front, rear notification, abnormality notification, the final notification, around advice.
Introduction (introducing):
introducing a notification is a special class code without modifying the premise, Introduction class may be dynamically added or Field methods at runtime.
Target (Audience):
proxy target object.
Weaving (weaving):
it refers to the enhancement applied to the target object to the process of creating a new proxy object.
Agent dynamic spring weaving, while the weaving AspectJ using compile and class loading of weaving.
The Proxy (Agent):
after being woven into a class enhanced AOP, to produce a result proxy class.
Aspect (section):
is a combination of pointcuts and (introduce) a.

When you see these terms, I was ignorant of the force, how to understand these terms, this is a problem? So that the explanation with reference to FIG.

 

 1. entry point: You call the result can be understood as a method call to the current method, also equivalent to the starting point (enhancement)

2. The point of attachment: increased because in addition to the method, as well as unreinforced methods that are collectively referred to as the point of attachment

3. Notification / Enhancement: This is already evident in the figure expressed

4. introduce: It will be appreciated to enhance the method's code

5. weaving: the process can be understood as a method of enhancing

6. Agent: this can be understood as a proxy class is generated after the weaving

7. section: Combining entry points and notification

 

Declarative transaction control 6. basis of xml

6.1 build environment:

Step 1: Create project and import coordinates maven 

Step 2: Create spring configuration file and import constraints

The third step: to prepare the database tables and entity classes

Step Four: Writing the business layer interface and implementation class

Step five: Write Dao interface and implementation class

Step 6: Configuring the business layer in the configuration file and persistence layer 

6.2 Configuration Steps

Step 1: Configure Transaction Manager

Step Two: Configuring transaction notice reference transaction manager

Step Three: Configure transaction properties

Step Four: Configure AOP pointcut expression

Step Five: Configure the entry point notification expressions and affairs of the correspondence between

 

7. The base configuration annotations

The related XML configuration successively replaced by annotations

 

Can not stand Tucao own, a top editor functions did not see ...... too lazy to re-write

 





  



Guess you like

Origin www.cnblogs.com/d1320/p/10982182.html