Spring AOP concepts of

1.1AOP Overview
The AOP: Aspect Oriented Programming i.e. full name: Oriented Programming.
Simple 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.
1.1.2 AOP role and advantages
effect:
During the program run, it does not modify the source code to the existing enhanced method.
Advantage:
Reduce duplication of code
Improve development efficiency
Easy maintenance
1.1.3 AOP implementations
The use of dynamic agent technology
 
Dynamic Proxy
Dynamic proxy 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.

 

 
Dynamic agent commonly used in two ways
Dynamic agent interface
Contributors: JDK official Proxy class.
Requirements: The minimum proxy class that implements an interface.
Dynamic proxy subclasses
Contributors: third party CGLib, if reported asmxxxx abnormal, you need to import asm.jar.
Requirements: The proxy class can not be final modified class (final class).
In Spring AOP
 
2.1Spring in AOP details
2.1.1 Description
We learn aop spring, that is, by way of configuration, realize the function of the previous section.
2.1.2 AOP related terms
JoinPoint (connection points):
The so-called connection points are those intercepted to the point. In the spring, these points refers to a method, because only the spring supporting method of the type
Junction.
Pointcut (entry point):
The so-called entry points means that we want to define the intercept of 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 notification is a special class code without modifying the premise, Introduction to some aspects may be added dynamically at runtime class
Law or Field.
Target (Audience):
Acting audience.
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.
Proxy (proxy):
After a category is woven into the reinforced AOP, to produce a result proxy class.
Aspect (section):
It is a combination of point and notification (introduce) a.
2.1.3 learning spring of AOP to clear things
a, development stage (we do)
Write core business code (main line of development): Most programmers do, require familiarity with business needs.
The common code extracted, made into notification. (The last stage of development do): AOP programmers do.
In the configuration file, the relationship between the starting point and notification declaration that section. : AOP programmers do.
b, operation phase (the Spring Framework completed)
Spring monitor the implementation of the framework entry point method. Once the entry point method is to monitor the operation, using a proxy mechanism to dynamically create target
Like the proxy object, according to the notification type, at a position corresponding to the proxy object, the notification function corresponding weaving, complete the full code logic operation.
2.1.4 choice about agency
In the spring, the framework will be based on whether the target class implements the interface to determine which dynamic proxy.
 
 

 

Guess you like

Origin www.cnblogs.com/yangzhixue/p/11803885.html