SpringFramework中DefaultAopProxyFactory的作用是什么
发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,本篇文章为大家展示了SpringFramework中DefaultAopProxyFactory的作用是什么,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。Sp
千家信息网最后更新 2025年02月02日SpringFramework中DefaultAopProxyFactory的作用是什么
本篇文章为大家展示了SpringFramework中DefaultAopProxyFactory的作用是什么,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
Springaop中的DefaultAopProxyFactory,先上一张图,如下图1
图1
Springaop中使用DefaultAopProxyFactory来创建代理,它决定了何时使用JDK还是Cglib代理,实现如下List-1所示:
List-1
public class DefaultAopProxyFactory implements AopProxyFactory, Serializable { @Override public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException { if (config.isOptimize() || config.isProxyTargetClass() || hasNoUserSuppliedProxyInterfaces(config)) { Class> targetClass = config.getTargetClass(); if (targetClass == null) { throw new AopConfigException("TargetSource cannot determine target class: " + "Either an interface or a target is required for proxy creation."); } if (targetClass.isInterface() || Proxy.isProxyClass(targetClass)) { return new JdkDynamicAopProxy(config); } return new ObjenesisCglibAopProxy(config); } else { return new JdkDynamicAopProxy(config); } } /** * Determine whether the supplied {@link AdvisedSupport} has only the * {@link org.springframework.aop.SpringProxy} interface specified * (or no proxy interfaces specified at all). */ private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) { Class>[] ifcs = config.getProxiedInterfaces(); return (ifcs.length == 0 || (ifcs.length == 1 && SpringProxy.class.isAssignableFrom(ifcs[0]))); }}
List-1中,目标对象拥有接口实现且没设置proxyTargetClass=true,则使用JDK代理,此外如果目标对象是个接口或者是代理类,则使用JDK代理,
否则使用Cglib,有些人说设置了ProxyTargetClass=true会使用JDK代理,正常情况下是正确的,不过从源码来看不一定--即使设置了ProxyTargetClass=true,如果目标对象类是个接口或者是代理类,则使用使用的是JDK代理。
上述内容就是SpringFramework中DefaultAopProxyFactory的作用是什么,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。
代理
对象
接口
目标
作用
内容
技能
知识
简明
简明扼要
就是
情况
文章
更多
源码
篇文章
行业
资讯
资讯频道
还是
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
热血航线怎么登录以前的服务器
辽宁省网络安全应急指挥
若服务器提供查询
头像图片怎么存数据库
视觉中国网络安全吗
太仓plm软件开发
dat数据库
思科路由器与网络安全
上海服务器设备回收多少钱
津南区数据网络技术答疑解惑
计算机四级网络技术题型
数据库访问技术是
去重服务器
浙江服务器电源特点
重庆办公系统软件开发大概多少钱
等保后发生网络安全问题
服务器行业销售模式如何改变
想学软件开发有什么方法
加强网络安全的监管
虹软人脸识别数据库
网络安全需要理性去守护
数据库技术 国产数据库
网络安全先进申报
医院服务器一年要多少钱
内存数据库 jdbc
加快构建网络安全保障体系
数据库系统的二级映像含义
服务器ip代理软件
unity网络服务器
方舟官方服务器分亚服