What is a use case for using a dynamic proxy?
How do they relate to bytecode generation and reflection?
Any recommended reading?
See Question&Answers more detail:osWhat is a use case for using a dynamic proxy?
How do they relate to bytecode generation and reflection?
Any recommended reading?
See Question&Answers more detail:osI highly recommend this resource.
First of all, you must understand what the proxy pattern use case. Remember that the main intent of a proxy is to control access to the target object, rather than to enhance the functionality of the target object. The access control includes synchronization, authentication, remote access (RPC), lazy instantiation (Hibernate, Mybatis), AOP (transaction).
In contrast with static proxy, the dynamic proxy generates bytecode which requires Java reflection at runtime. With the dynamic approach you don't need to create the proxy class, which can lead to more convenience.