Performance JDK dynamic proxy versus CGLIB proxy

We learned what proxies are used for. According to the GoF book, Design Patterns: Elements of Reusable Object-Oriented Software, a proxy is a placeholder for another object to control access to it. As the proxy lies in between the caller of an object and the real object, it can decide whether to prevent the invocation of the real (or target) object or perform some action before the target object is invoked.

Many object-relational mappers use proxy patterns to implement a behavior that prevents data from being loaded until it is actually needed. Sometimes this is called lazy loading. Spring also uses proxies to develop some of its functionality, such as its transaction management, security, ...

Get Hands-On High Performance with Spring 5 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.