AOP static and dynamic

Agency: the idea is due to our project there will be some of the core business functions as well as some additional features. For additional functionality we want to introduce in time of need, when not removed. The introduction of the proxy class increases the flexibility to use additional features to improve the maintainability of the project.

# Dynamic Proxy

A: development steps
1. Write the original class

2. Write the extra features (notice)
### 1 pre-notification, additional features before the original core functionality to achieve MethodBeforeAdvice

public void before(Method methdo, Object[] arrs ,Object obj)throwable{
System.out.println("核心功能执行前的额外功能");
};

### Rear notice: Additional functions after the original core functionality added
before or after the original core functions are added extra features: ### surround notice
abnormal notify ###: extra when the original core function throws an exception, added Features

Defined cut-off point: cut-off point is the location of additional functionality in the project to be added.
<AOP: = the pointcut expression The "Execution (* ... . ()..) ID =" PCT ">
First
: Return value matches
the second *: matching packet structure
Third *: class name matches
the fourth * : matching method name
(.): match the parameter list, meaning two match points are arbitrary parameters

III: knitting: (also known as Weave weaving)
<AOP: Advisor advice- REF = "" the pointcut-REF = "">

Guess you like

Origin blog.csdn.net/weixin_42987508/article/details/83831202