当前位置:网站首页>[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
边栏推荐
- 47_Opencv中的轮廓查找 cv::findContours()
- 121. The best time to buy and sell stocks
- Personal notes of graphics (3)
- Statistical learning method -- perceptron
- Tragedy caused by deleting the console statement
- Laravel5.1 Routing - routing packets
- logback. XML configure logs of different levels and set color output
- Laravel changed the session from file saving to database saving
- MySQL中, 如何查询某一天, 某一月, 某一年的数据
- AutoLISP series (2): function function 2
猜你喜欢

Spark Tuning (III): persistence reduces secondary queries

spark调优(三):持久化减少二次查询

Mysql database basic operation DQL basic query

Personal notes of graphics (3)
![[C language] question set of X](/img/17/bfa57de183c44cf0a3c6637bb65a9d.jpg)
[C language] question set of X

Logback日志框架第三方jar包 免费获取

Horizontal and vertical centering method and compatibility

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

数据中台落地实施之法

两类更新丢失及解决办法
随机推荐
Laravel5.1 Routing - routing packets
How to implement backspace in shell
Balanced binary tree (AVL)
How can laravel get the public path
torch.numel作用
Imitate the choice of enterprise wechat conference room
PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
Shandong old age Expo, 2022 China smart elderly care exhibition, smart elderly care and aging technology exhibition
Three. JS series (1): API structure diagram-1
MySQL数据库基本操作-DQL-基本查询
PHP has its own filtering and escape functions
记一次项目的迁移过程
二叉搜索树(基操篇)
预测——灰色预测
The difference and working principle between compiler and interpreter
Laravel 中config的用法
修改配置文件后tidb无法启动
pycharm 终端部启用虚拟环境
Xcode Revoke certificate
PHP实现微信小程序人脸识别刷脸登录功能