Proxy Pattern
Overview
Provide a surrogate or placeholder for another object to control access to it.
Participants
- maintains a reference that lets the proxy access the real
subject. Proxy may refer to a Subject if the RealSubject and
Subject interfaces are the same.
- provides an interface identical to Subject's so that a proxy
can be substituted for the real subject.
- controls access to the real subject and may be responsible
for creating and deleting it.
- other responsibilities depend on the kind of proxy:
- remote proxies are responsible for encoding a request and
its arguments and for sending the encoded request to the
real subject in a different address space.
- virtual proxies may cache additional information about the
real subject so they can postpone accessing it.
- protection proxies check that the caller has the access
permission required to perform a request.
- this participant can not be read-only.
- this participant can not be an interface.
- defines the common interface for RealSubject and Proxy so that
a Proxy can be used anywhere a RealSubject is expected.
- this participant can not be read-only.
Parameters
-
here you can specify the name of an attribute where the Proxy will keep a reference
to the Real Subject object it represents.
-
the "Initialization variant" option defines the kind of initialization of that attribute.
-
when selected, will create special JavaDoc links in the code between pattern participants, describing
their relationships.
Applicability
Proxy is applicable whenever there is a need for a more versatile or sophisticated reference
to an object than a simple pointer.