当前位置:网站首页>Cglib dynamic proxy
Cglib dynamic proxy
2022-06-25 07:36:00 【Borny Ding Ding】
1、 explain
Dynamically generate a subclass of the proxy class , Subclass overrides all of the classes to be proxied final Methods . Provide proxies for classes that do not implement interfaces , yes jdk Dynamic agent is a good supplement . Application scenarios , for example aop、hibernate.
2、 Simple example
public class DogService {
public void sound() {
System.out.println("wang");
}
}DogService dogService = new DogService();
// cglib A dynamic proxy
Enhancer enhancer = new Enhancer();
enhancer.setClassLoader(dogService.getClass().getClassLoader());
enhancer.setSuperclass(dogService.getClass());
MethodInterceptor methodInterceptor = new MethodInterceptor() {
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
throws Throwable {
System.out.println("before");
Object invoke = method.invoke(dogService, args);
System.out.println("after");
return invoke;
}
};
enhancer.setCallback(methodInterceptor);
DogService dogServiceProxy = (DogService) enhancer.create();
dogServiceProxy.sound();test result
before
wang
after边栏推荐
- Conditional grouping with $exists inside $cond
- smartBugs安装小问题总结
- Common functions of OrCAD schematic
- Zhugeliang vs pangtong, taking distributed Paxos
- TEMPEST HDMI泄漏接收 2
- Sichuan Tuwei ca-is3105w fully integrated DC-DC converter
- 【UVM入门 ===> Episode_9 】~ 寄存器模型、寄存器模型的集成、寄存器模型的常规方法、寄存器模型的应用场景
- VectorDraw Web Library 10.10
- Introduction to Sichuan Tuwei ca-is3082wx isolated rs-485/rs-422 transceiver
- Orcad Schematic常用功能
猜你喜欢

CPDA | how to start the growth path of data analysts?

稳压二极管的原理,它有什么作用?

Reading sensor data with GPIO analog SPI interface

This year, I graduated
![[batch dos-cmd command - summary and summary] - external command -cmd download command and packet capture command (WGet)](/img/00/5a5b081b78ad6a6c1c3a3c847dd315.png)
[batch dos-cmd command - summary and summary] - external command -cmd download command and packet capture command (WGet)

为什么要“除夕”,原来是内存爆了!
![[batch dos-cmd command - summary and summary] - application startup and call, service and process operation commands (start, call, and)](/img/19/b8c0fb72f1c851a6b97f2c17a18665.png)
[batch dos-cmd command - summary and summary] - application startup and call, service and process operation commands (start, call, and)

What is the difference between norflash and nandflash

13 `bs_ duixiang. Tag tag ` get a tag object

Design a MySQL table for message queue to store message data
随机推荐
Harmony food menu interface
Several good weather plug-ins
Research on 3D model retrieval method based on two channel attention residual network - Zhou Jie - paper notes
GUI pull-down menu of unity3d evil door implementation dropdown design has no duplicate items
Enter an integer with any number of bits, and output the sum of each bit of the number. For example: 1234 – > 10
Keepalived monitors the process and automatically restarts the service process
14 BS object Node name Name attrs string get node name attribute content
三年营收连续下滑,天地壹号困在醋饮料里
Icon already includes gloss effects
Cocos学习日记3——api获取节点、组件
Debug through yalc before releasing NPM package
Let's talk about MCU crash caused by hardware problems
Analysis on the trend of the number of national cinemas, film viewers and average ticket prices in 2021 [figure]
Chuantu microelectronics ca-if1051 can-fd transceiver
【批处理DOS-CMD命令-汇总和小结】-应用程序启动和调用、服务和进程操作命令(start、call、)
The e-book "action guide for large organizations to further promote zero code application platform" was officially released!
CPDA | how to start the growth path of data analysts?
用动图讲解分布式 Raft
Authentique Photoshop 2022 expérience d'achat partage
Vscode official configuration synchronization scheme