Proxying

Опубликовано: 25 Март 2026
на канале: JavaAnatomy
126
11

Proxy, Spring Boot Bean
In short, a proxy is a wrapper or agent object that is being called by the client to access the real serving object behind the scenes.

The Proxy pattern uses a proxy (surrogate) object “in place of” another object. The objective of a proxy object is to control the creation of and access to the real object it represents. A common use of a proxy is to defer the cost of instantiating of an object (that is expensive to create) until it is actually needed by clients.

Defer the cost of instantiating an object.
ScopeBeans
Provide additional logic. In the proxy, extra functionality can be provided, for example
caching when operations on the real object are resource intensive
checking preconditions before operations on the real object are invoked.

JDK dynamic proxies
CGLIB to create the proxy for a given target object.
JDK Dynamic
JDK dynamic proxies are built into the JDK. If the target object to be proxied implements at least one interface, a JDK dynamic proxy is used. All of the interfaces implemented by the target type are proxied.

Github repo
https://github.com/java-space/springb...

The Application Context
   • The Application Context  

Observability
   • Part 1 Observability  

Spring AOP
   • Part 1   AOP vs OOP