Proxy design pattern can be used in a wide variety of scenario in
Java. Some of these are as follows:
1. Virtual Proxy: This is a virtual object that acts as a proxy
for objects that are very expensive to create. It is used in
Lazy Loading. When client makes the first request, the real
object is created.
2. Remote Proxy: This is a local object that provides access
to a remote object. It is generally used in Remote Method
Invocation (RMI) and Remote Procedure Call (RPC). It is
also known as a Stub.
3. Protective Proxy: This is an object that control the access
to a Master object. It can authenticate and authorize the
client for accessing the Master object. If client has right
permissions, it allows client to access the main object.
4. Smart Proxy: It is an object that can add additional
information to the main object. It can track the number of
other objects accessing the main object. It can track the
different clients from where request is coming. It can even
deny access to an object if the number of requests is
greater than a threshold.