Describe how the proxy pattern applies to distributed objects.
Client Stub Proxy Pattern
The stub is an example of the proxy pattern. It is used whenever you need to decouple the specifics of an object from its clients.
In this course we are decoupling the location and details of how to invoke the remote object from the client. All the client sees is the interface of the proxy, and all the details of the remote object are hidden under its surface. You will appreciate the simplicity of changing the implementation of the proxy.
In doing so, you can alter remote specific implementation details such as the network address of the remote object or the transport that is being used to communicate with the remote object. All this can be done without changing a single line of code in the client. Details that change are usually location, security, transactions, etc.
A design pattern describes a solution to a problem that occurs over and over again when designing object-oriented computer systems.
The following SlideShow illustrates these steps. (Please note that I have ignored the actual host systems and the details of the network and show only the object specifics.)
The client invokes getBalance() on the stub
The stub marshals the method call into the appropriate wire format message and sends it across the network to the remote object's skeleton.
The skeleton listens on the network for messages. When the message arrives, the skeleton un-marshals it.
The skeleton invokes the getBalance() method of the remote object.
Remote object processes the call to getBalance() and returns the balance
Return value is marshalled by the skeleton and returned to the stub
The stub un-marshals the return and passes it back to the client.