当前位置:网站首页>【DesignMode】代理模式(proxy pattern)
【DesignMode】代理模式(proxy pattern)
2022-07-07 14:16:00 【weixin_43224306】
基本介绍
代理模式:为一个对象提供一个替身,以控制对这个对象的访问。即通过代理对象访问目标对象.这样做的好处是:可以在目标对象实现的基础上,增强额外的功能操作,即扩展目标对象的功能。
被代理的对象可以是远程对象、创建开销大的对象或需要安全控制的对象
代理模式有不同的形式, 主要有三种 静态代理、理 动态代理 (JDK 代理、接口代理)和 Cglib 理 代理 (可以在内存动态的创建对象,而不需要实现接口, 他是属于动态代理的范畴) 。
1 代理模式(Proxy)
1.1 代理模式的基本介绍
代理模式:为一个对象提供一个替身,以控制对这个对象的访问。即通过代理对象访问目标对象.这样做的好处是:可以在目标对象实现的基础上,增强额外的功能操作,即扩展目标对象的功能。
被代理的对象可以是远程对象、创建开销大的对象或需要安全控制的对象
代理模式有不同的形式, 主要有三种 静态代理、理 动态代理 (JDK 代理、接口代理)和 Cglib 理 代理 (可以在内存动态的创建对象,而不需要实现接口, 他是属于动态代理的范畴) 。
代理模式示意图

2. 静态代理
2.1 静态代码模式的基本介绍
静态代理在使用时,需要定义接口或者父类,被代理对象(即目标对象)与代理对象一起实现相同的接口或者是继承相同父类
边栏推荐
- The unity vector rotates at a point
- How does laravel run composer dump autoload without emptying the classmap mapping relationship?
- Laravel 服务提供者实例教程 —— 创建 Service Provider 测试实例
- prometheus api删除某个指定job的所有数据
- Set the route and optimize the URL in thinkphp3.2.3
- HAVE FUN | “飞船计划”活动最新进展
- PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
- Leetcode-136-只出现一次的数(用异或来解答)
- JS中null NaN undefined这三个值有什么区别
- The team of East China Normal University proposed the systematic molecular implementation of convolutional neural network with DNA regulation circuit
猜你喜欢

Vs tool word highlight with margin

Odoo集成Plausible埋码监控平台

Xcode Revoke certificate

Three. JS series (1): API structure diagram-1
![[Android -- data storage] use SQLite to store data](/img/f6/a4930276b3da25aad3ab1ae6f1cf49.png)
[Android -- data storage] use SQLite to store data

Unity3d click events added to 3D objects in the scene

AutoLISP series (1): function function 1

Eye of depth (VII) -- Elementary Transformation of matrix (attachment: explanation of some mathematical models)
![[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3](/img/8f/ca9ab042916f68de7994d9f2124da9.jpg)
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3

95. (cesium chapter) cesium dynamic monomer-3d building (building)
随机推荐
What are compiled languages and interpreted languages?
预测——灰色预测
Tidb cannot start after modifying the configuration file
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
Vs tool word highlight with margin
How can laravel get the public path
Introduction to ThinkPHP URL routing
121. The best time to buy and sell stocks
Prediction - Grey Prediction
HAVE FUN | “飞船计划”活动最新进展
01tire+ chain forward star +dfs+ greedy exercise one
修改配置文件后tidb无法启动
asyncio 概念和用法
Continuous creation depends on it!
95. (cesium chapter) cesium dynamic monomer-3d building (building)
pycharm 终端部启用虚拟环境
spark调优(三):持久化减少二次查询
Prometheus API deletes all data of a specified job
23. 合并K个升序链表-c语言
How to determine whether the checkbox in JS is selected