当前位置:网站首页>【DesignMode】代理模式(proxy pattern)
【DesignMode】代理模式(proxy pattern)
2022-07-07 14:16:00 【weixin_43224306】
基本介绍
代理模式:为一个对象提供一个替身,以控制对这个对象的访问。即通过代理对象访问目标对象.这样做的好处是:可以在目标对象实现的基础上,增强额外的功能操作,即扩展目标对象的功能。
被代理的对象可以是远程对象、创建开销大的对象或需要安全控制的对象
代理模式有不同的形式, 主要有三种 静态代理、理 动态代理 (JDK 代理、接口代理)和 Cglib 理 代理 (可以在内存动态的创建对象,而不需要实现接口, 他是属于动态代理的范畴) 。
1 代理模式(Proxy)
1.1 代理模式的基本介绍
代理模式:为一个对象提供一个替身,以控制对这个对象的访问。即通过代理对象访问目标对象.这样做的好处是:可以在目标对象实现的基础上,增强额外的功能操作,即扩展目标对象的功能。
被代理的对象可以是远程对象、创建开销大的对象或需要安全控制的对象
代理模式有不同的形式, 主要有三种 静态代理、理 动态代理 (JDK 代理、接口代理)和 Cglib 理 代理 (可以在内存动态的创建对象,而不需要实现接口, 他是属于动态代理的范畴) 。
代理模式示意图
2. 静态代理
2.1 静态代码模式的基本介绍
静态代理在使用时,需要定义接口或者父类,被代理对象(即目标对象)与代理对象一起实现相同的接口或者是继承相同父类
边栏推荐
- Iptables only allows the specified IP address to access the specified port
- Bidding announcement: Fujian Rural Credit Union database audit system procurement project (re bidding)
- PHP realizes wechat applet face recognition and face brushing login function
- prometheus api删除某个指定job的所有数据
- Prediction - Grey Prediction
- MySQL数据库基本操作-DQL-基本查询
- torch. Numel action
- Laravel post shows an exception when submitting data
- Asyncio concept and usage
- three.js打造酷炫下雪效果
猜你喜欢
记一次项目的迁移过程
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
Mysql database basic operation DQL basic query
Step by step monitoring platform ZABBIX
Eye of depth (VII) -- Elementary Transformation of matrix (attachment: explanation of some mathematical models)
Logback logging framework third-party jar package is available for free
Notification uses full resolution
Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()
95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)
企业级日志分析系统ELK
随机推荐
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
分步式监控平台zabbix
How can laravel get the public path
thinkphp3.2.3中设置路由,优化url
What about the pointer in neural network C language
AutoLISP series (3): function function 3
Laravel constructor and middleware execution order
分步式監控平臺zabbix
MySQL数据库基本操作-DQL-基本查询
Three. JS series (2): API structure diagram-2
1亿单身男女“在线相亲”,撑起130亿IPO
[summary of knowledge] summary of notes on using SVN in PHP
Bidding announcement: Fujian Rural Credit Union database audit system procurement project (re bidding)
Power of leetcode-231-2
Unity3D_ Class fishing project, bullet rebound effect is achieved
You Yuxi, coming!
SPI master RX time out interrupt
Leetcode-136-只出现一次的数(用异或来解答)
Logback日志框架第三方jar包 免费获取
应用程序和matlab的通信方式