Intent -
Provide a surrogate or placeholder for another object to
control access to it.
Problem -
Remote Proxy - You want to provide access to a
remote object
Virtual Proxy - You want to create expensive
objects on demand (lazy loading)
Protection Proxy - You want to control access
to an object.
Smart Reference - You want to provide a
replacement for a bare pointer (not needed in Java,
but is applicable for providing a way to unload
resources that aren't freed by the garbage collector)
Solution -
Participants and Collaborators
Proxy
Subject
RealSubject
Consequences
A remote proxy may hide the fact that an object is
in a different address space (performance issues,
etc)
A virtual proxy allows optimizations for object
creation
Protection proxies and smart references allow
additional housekeeping to take place when an object
is accessed.
Implementation
Proxies don't have to know the real subject if they
can deal with an interface.