当前位置:网站首页>[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
边栏推荐
- C语言进阶——函数指针
- php 自带过滤和转义函数
- How to determine whether the checkbox in JS is selected
- Opencv configuration 2019vs
- [Android -- data storage] use SQLite to store data
- 华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
- How to implement backspace in shell
- 1亿单身男女“在线相亲”,撑起130亿IPO
- Laravel post shows an exception when submitting data
- torch. Numel action
猜你喜欢
Odoo集成Plausible埋码监控平台
【医学分割】attention-unet
Unity3d click events added to 3D objects in the scene
Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench
Xcode Revoke certificate
Have fun | latest progress of "spacecraft program" activities
网关Gateway的介绍与使用
AutoLISP series (3): function function 3
AutoLISP series (2): function function 2
AutoLISP series (1): function function 1
随机推荐
Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
Laravel 中config的用法
记录Servlet学习时的一次乱码
TiDB For PostgreSQL和YugabyteDB在Sysbench上的性能对比
laravel post提交数据时显示异常
Three. JS series (2): API structure diagram-2
Bidding announcement: Fujian Rural Credit Union database audit system procurement project (re bidding)
Prediction - Grey Prediction
【Vulnhub靶场】THALES:1
Leetcode-231-2的幂
谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题
Find tags in prefab in unity editing mode
Horizontal and vertical centering method and compatibility
PHP实现微信小程序人脸识别刷脸登录功能
What is the difference between IP address and physical address
Cesium (4): the reason why gltf model is very dark after loading
Laravel5.1 路由 -路由分组
Performance measure of classification model
[vulnhub range] thales:1
Communication mode between application program and MATLAB