一、AOP 的底层实现
实际上,AOP 的底层是通过 Spring 提供的的动态代理技术实现的。在运行期间,Spring通过动态代理技术动态 的生成代理对象,代理对象方法执行时进行增强功能的介入,在去调用目标对象的方法,从而完成功能的增强
二、AOP的动态代理技术(2种)
3.jdk动态代理
可参考:https://blog.csdn.net/QLBFA/article/details/110499922
TargetInterface:
package cn.itcast.proxy.jdk;
/**
* @author QLBF
* @version 1.0
* @date 2021/1/12 19:56
*/
public interface TargetInterface {
public void save();
}
Target:
package cn.itcast.proxy.jdk;
/**
* @author QLBF
* @version 1.0
* @date 2021/1/12 19:57
*/
public class Target implements TargetInterface {
public void save() {
System.out.println("Target run...");
}
}
Advice:
package cn.itcast.proxy.jdk;
/**
* @author QLBF
* @version 1.0
* @date 2021/1/12 19:58
*/
//这是个增强内容封装成对象而已
public class Advice {
public void before(){
System.out.println("前置增强...");
}
public void afterReturning(){
System.out.p