eWebProgrammer eweb  

EJB Architecture  «Prev  Next»
Lesson 3J2EE Transports, stubs, and skeletons
Objective Describe message communication between a client and remote object.

J2EE Transports, Stubs, and Skeletons

In the previous section, we saw that the client sends a message to the remote object, and the remote object processes it and sends it back. How does this actually happen?
We will assume the BankAccount object has a method double getBalance(), and we will use it to look at the functions of the stub and the skeleton.

Transport Stubs and Skeletons
The figure above describes client, stub, skeleton, and BankAccount components.

Stubs and skeletons

The stub connects the client to the remote object.
A stub is an instance of the Proxy Pattern.
To make life simple for the client programmer, the stub hides all the messy details of connecting to the remote object and invoking its parameters.
The skeleton hides the network details from the remote object.
This makes the client and the remote object very portable, as you only need to generate new stubs and skeletons for any new environment.
The stub provides a similar interface to the client as does the remote object.
In fact, the client has no idea whether the stub is the real thing or a proxy.
In the next lesson I will discuss how the proxy pattern applies to distributed objects.