1, the introduction

Proxy means that when we need to access the target object, we do not directly access the target object, but the proxy object does it for us. When do we need an agent? On the one hand, you want to do things like log before and after the actual target object method is executed. On the other hand, methods that need to be executed do not have a concrete implementation; dynamic proxies can be used.

2. What is static proxy?

Instead of drawing class diagrams, one paragraph makes it clear.

1. Create the target object.

Create a proxy object. The target object is an attribute of the proxy object.

3. Set the target object to the proxy object.

4. Call the target object’s method in the proxy object’s method

5. You can call some pre-and post-methods that execute the target object in the methods of the proxy object.

6,

3. What is dynamic proxy?