您的位置:首页 > 编程语言 > Java开发

Spring Aop源码学习--Aop代理AopProxy

2017-07-07 18:22 381 查看
AopProxy是Spring Aop提供的代理类,简单来说通过其实现类可以获取到代理类。

AopProxy接口提供的方法如下:
public interface AopProxy {

/**
* Create a new proxy object.
* <p>Uses the AopProxy's default class loader (if necessary for proxy creation):
* usually, the thread context class loader.
* @return the new proxy object (never {@code null})
* @see Thread#getContextClassLoader()
*/
//获取一个代理对象
Object getProxy();

/**
* Create a new proxy object.
* <p>Uses the given class loader (if necessary for proxy creation).
* {@code null} will simply be passed down and thus lead to the low-level
* proxy facility's default, which is usually different from the default chosen
* by the AopProxy implementation's {@link #getProxy()} method.
* @param classLoader the class loader to create the proxy with
* (or {@code null} for the low-level proxy facility's default)
* @return the new proxy object (never {@code null})
*/
//根据类加载器获取代理对象
Object getProxy(ClassLoader classLoader);

}AopProxy有两个实现类JdkDynamicAopProxy和CglibAopProxy,简单来说这两个代理类的功能就是生成目标代理类,其实现机制可以参考 Java--Proxy代理介绍及实现机制
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: