当前位置:网站首页>[designmode] proxy pattern
[designmode] proxy pattern
2022-07-07 16:36:00 【weixin_ forty-three million two hundred and twenty-four thousan】
Basic introduction
The proxy pattern : Provide a surrogate for an object , To control access to this object . That is, access the target object through the proxy object . The advantage of this is : It can be realized on the basis of the target object , Enhance additional functional operations , That is, extending the functionality of the target object .
The proxied object can be a remote object 、 Create expensive objects or objects that need security control
There are different forms of agency , There are three main types Static proxy 、 The reason is A dynamic proxy (JDK agent 、 The interface agent ) and Cglib The reason is agent ( Objects can be created dynamically in memory , Instead of implementing interfaces , He belongs to the category of dynamic agency ) .
1 The proxy pattern (Proxy)
1.1 The basic introduction of agent mode
The proxy pattern : Provide a surrogate for an object , To control access to this object . That is, access the target object through the proxy object . The advantage of this is : It can be realized on the basis of the target object , Enhance additional functional operations , That is, extending the functionality of the target object .
The proxied object can be a remote object 、 Create expensive objects or objects that need security control
There are different forms of agency , There are three main types Static proxy 、 The reason is A dynamic proxy (JDK agent 、 The interface agent ) and Cglib The reason is agent ( Objects can be created dynamically in memory , Instead of implementing interfaces , He belongs to the category of dynamic agency ) .
Schematic diagram of agent mode

2. Static proxy
2.1 The basic introduction of static code pattern
Static agents are used , You need to define an interface or parent class , Proxied object ( That is, the target object ) Implement the same interface or inherit the same parent class with the proxy object
边栏推荐
- 如何快速检查钢网开口面积比是否符合 IPC7525
- "The" "PIP" "entry cannot be recognized as the name of a cmdlet, function, script file, or runnable program."
- Communication mode between application program and MATLAB
- Personal notes of graphics (2)
- Statistical learning method -- perceptron
- thinkphp3.2.3中设置路由,优化url
- pycharm 终端部启用虚拟环境
- What is the difference between IP address and physical address
- 记录Servlet学习时的一次乱码
- URL和URI的关系
猜你喜欢

二叉搜索树(特性篇)

Logback logging framework third-party jar package is available for free

AutoLISP series (2): function function 2

谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题

删除 console 语句引发的惨案

Talk about the cloud deployment of local projects created by SAP IRPA studio

统计学习方法——感知机

Personal notes of graphics (4)

无法将“pip”项识别为 cmdlet、函数、脚本文件或可运行程序的名称

Odoo integrated plausible embedded code monitoring platform
随机推荐
二叉搜索树(特性篇)
【HCSD大咖直播】亲授大厂面试秘诀-简要笔记
如何快速检查钢网开口面积比是否符合 IPC7525
全网“追杀”钟薛高
Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
Cesium (4): the reason why gltf model is very dark after loading
二叉搜索树(基操篇)
Laravel5.1 路由 -路由分组
Imitate the choice of enterprise wechat conference room
95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)
Three. JS series (1): API structure diagram-1
Bidding announcement: Fujian Rural Credit Union database audit system procurement project (re bidding)
torch.numel作用
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
121. The best time to buy and sell stocks
Geoserver2.18 series (5): connect to SQLSERVER database
【C 语言】 题集 of Ⅹ
Horizontal and vertical centering method and compatibility
无法将“pip”项识别为 cmdlet、函数、脚本文件或可运行程序的名称
偶然升职的内心独白