Proxy
Usage
- Also known as: Surrogate
- An object representing another object
- Provide a surrogate or placeholder for another object to control access to it
Participants
Proxy
- 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 for the real subject.
- Controls access to the real subject and may be responsible for creating and deleting it.
- Other responsibilites depend on the kind of proxy:
Subject
- 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 that they can postpone accessing it. For example, the ImageProxy from the Motivation caches the real images's extent.
- Protection proxies check that the caller has the access permissions required to perform a request.
RealSubject
- Defines the common interface for RealSubject and Proxy so that a Proxy can be used anywhere a RealSubject is expected.
- Defines the real object that the proxy represents.
