0.10. Infrastructure Code
From the book:
Most of us have used dynamic proxies, often without realizing it. A lot of frameworks and tools are built on dynamic proxies. Even the humble annotation is implemented with dynamic proxies. These examples are a small sample of where we might find them in use.
Build tools like Gradle use proxies for models, tasks, actions, and listeners. Examples include
ProgressListener. Maven uses them for plugin management through the
Application containers like JBoss and Spring Framework use proxies for dependency injection. Some examples are
@Bean. Scoping and lifecycle management also use dynamic proxies.
Persistence management with JPA within these containers uses proxies — for example,
@JoinColumn. In Spring, we can derive a custom repository by extending the
Repository interface. In the background, a multi-interface dynamic decorating proxy takes care of the details.
If we choose Hibernate for ORM, then proxies surround
ConnectionProxy is a dynamic proxy of
Again in Spring, a dynamic proxy for
InitBinder binds HTTP form fields with a data model. Dynamic proxies are used under the hood by many of the frameworks we use every day: Spring Framework, WildFly, NetBeans Platform, Apache Tomcat, and OpenJDK, among many others.