当前位置:网站首页>[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
边栏推荐
- 1亿单身男女“在线相亲”,撑起130亿IPO
- Spark Tuning (III): persistence reduces secondary queries
- Laravel5.1 Routing - routing packets
- JS 模块化
- MySQL数据库基本操作-DQL-基本查询
- logback.xml配置不同级别日志,设置彩色输出
- TiDB For PostgreSQL和YugabyteDB在Sysbench上的性能对比
- HAVE FUN | “飞船计划”活动最新进展
- 【DesignMode】代理模式(proxy pattern)
- Sysom case analysis: where is the missing memory| Dragon lizard Technology
猜你喜欢
随机推荐
Power of leetcode-231-2
Vs tool word highlight with margin
Xcode Revoke certificate
spark调优(三):持久化减少二次查询
Laravel5.1 路由 -路由分组
Leetcode-231-2的幂
平衡二叉树(AVL)
PHP has its own filtering and escape functions
URL和URI的关系
Communication mode between application program and MATLAB
Opencv personal notes
php 自带过滤和转义函数
PHP实现微信小程序人脸识别刷脸登录功能
[Android -- data storage] use SQLite to store data
二叉搜索树(特性篇)
Record the migration process of a project
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
统计学习方法——感知机
MySQL中, 如何查询某一天, 某一月, 某一年的数据
1亿单身男女“在线相亲”,撑起130亿IPO