11 Proxy

AN ORDINARY OBJECT does its own work in support of the public interface that it advertises. It can happen, though, that a legitimate object cannot live up to this ordinary responsibility. This may occur when an object takes a long time to load, when the object is running on another computer, or when you need to intercept messages to the object. In these cases, a proxy object can take the responsibility that a client expects and forward requests appropriately to an underlying target object.

The intent of the PROXY pattern is to control access to an object by providing a surrogate, or placeholder, for it.

A Classic Example: Image Proxies

A proxy object usually has an interface that is nearly identical to the interface of the ...

Get Design Patterns in Java™, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.