当前位置:网站首页>[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
边栏推荐
- 两类更新丢失及解决办法
- Xcode Revoke certificate
- 01tire+ chain forward star +dfs+ greedy exercise one
- 预测——灰色预测
- Performance measure of classification model
- Inner monologue of accidental promotion
- Cesium(3):ThirdParty/zip. js
- Build an all in one application development platform, light flow, and establish a code free industry benchmark
- The differences between exit, exit (0), exit (1), exit ('0 '), exit ('1'), die and return in PHP
- Logback日志框架第三方jar包 免费获取
猜你喜欢
随机推荐
[Android -- data storage] use SQLite to store data
laravel 是怎么做到运行 composer dump-autoload 不清空 classmap 映射关系的呢?
作为Android开发程序员,android高级面试
Personal notes of graphics (4)
You Yuxi, coming!
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
JS 模块化
torch. Numel action
torch.numel作用
3000 words speak through HTTP cache
Good news! Kelan sundb database and Hongshu technology privacy data protection management software complete compatibility adaptation
爬虫(17) - 面试(2) | 爬虫面试题库
Detailed explanation of several ideas for implementing timed tasks in PHP
Personal notes of graphics (3)
logback. XML configure logs of different levels and set color output
Statistical learning method -- perceptron
What else can an ordinary person do besides working in a factory to make money?
Power of leetcode-231-2
Opportunity interview experience summary
【医学分割】attention-unet