"It provides the control for accessing the original object".
Proxy pattern is to provide a Surrogate or Placeholder for an object to control its references. It is used when we want to provide controlled access of functionality.
One reason for controlling access to an object is to defer the full cost of its creation and initialization until we actually need to use it. Consider an image viewer program that must be able to list and display high-resolution photo objects that are in a folder, but how often does someone open a folder and view all the images inside. Sometimes you will be looking for a particular photo, sometimes you will only want to see an image name. The image viewer must be able to list all photo objects, but the photo objects must not be loaded into memory until they are required to be rendered.
Subject: Interface implemented by the RealSubject and representing its services.
It is also implemented by Proxy.
Proxy: Controls access to the RealSubject and may be responsible for its creation and deletion.
RealSubject: This is the real object that the proxy represents.
Common scenarios to use the Proxy pattern
If you want to delay the creation and initialization of expensive objects until needed, where the objects are created on demand (For example creating the RealSubject object only when the doSomething method is invoked).
In distributed object communication, a local object represents a remote object (one that belongs to a different address space). The local object is a proxy for the remote object, and method invocation on the local object results in remote method invocation on the remote object. An example would be an ATM implementation, where the ATM might hold proxy objects for bank information that exists on the remote server.
Java RMI stub objects are another good example. The stub object acts as a proxy where invoking methods on the stub would cause the stub to communicate and invoke methods on a remote object (called skeleton) found on a different machine.
A protection proxy might be used to control access to a resource based on access rights.
To provide a sophisticated access to certain objects such as tracking the number of references to an object and denying access if a certain number is reached, as well as loading an object from the database into memory on demand.
Proxy Design Patterns in Java's core libraries