table of Contents
@ (Depth analysis proxy mode)
Depth analysis of proxy mode
- Master proxy mode of application scenarios
- Understand the difference between static and dynamic proxy agent
- CGLib and understand the fundamental difference between the JDK Proxy
- Handwritten implementation-defined dynamic proxy
Content targeting
- We know how to be a proxy mode to achieve SpringAOP when, in the end is how to achieve it?
- Simulation own handwriting to restore some of the details
Define a proxy mode
Agent mode (Proxy Pattern) refers to provide a proxy for other objects, to control access to the object.
Proxy object mediates between the client and the target audience.
Structural design patterns belonging to
Life in proxy mode
- Real Estate Agents
- Express little brother
- Scalpers
Proxy mode usage scenarios
- Protection of the target object
- Enhanced Audience
Static agents
- Display declaration is a proxy object
Data source routing eg: dynamically switching the data source
defect
It does not comply with the principle of opening and closing, as long as the agent of the class needs a new agency, we need to add a new method in the proxy class
Dynamic proxy ($ Proxy0)
- Get the proxy class references, and get all of his interfaces (reflecting acquisition) need to implement the interface
- JDK Proxy class to re-generate a new class that implements the method of the proxy class for all interfaces
- Jav dynamically generated code to enhance logic is added to the newly generated code.
- Java code compiler to generate new class files
- Loading and re-run the new class, derived class is the new class
Proxy is a utility class used to generate a new proxy class
Why the length of the interface of this class can not be greater than 65535?