0%

JDK代理模式

代理模式

代理模式是一种通过代理对象来代替真实对象,而可以在不修改原有对象的前提下,提供额外的功能操作,扩展目标对象的功能

静态代理

静态代理中,对目标对象的每个方法的增强都是手动完成的,在接口新增一些方法,目标对象和代理对象都需要进行修改(使用场景非常少)

动态代理

相比较于静态代理来说,动态代理更加灵活。我们不需要针对每个目标类都单独创建一个代理类,我们可以直接使用代理对象实现类(CGLB动态动态代理机制)

动态代理实现

JDK动态代理

在 Java 动态代理机制中 InvocationHandler 接口和 Proxy 类是核心。

Read more »

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate
Read more »