|
| |
How Does RMI Perform a Remote Method Call?
There are a number of components and actions involved in performing a remote
method call:
- In order for a remote method call to appear as if it is local, there has
to be a local object which 'stands in for' the remote object -- that is, it
presents the same interface to the client as the remote object
does.
- The local object is called the client stub.
- The interface that both the stub and the remote object present is
known as the remote interface
- When a call is made to one of the methods in the client stub, the stub is responsible
for somehow:
- Invoking the corresponding method on the remote object
- Passing any parameters provided on the local call to the remote
object's method
- Eventually, obtaining any return values from the remote method (output
parameters, or the return value from the method) and passing them back
to the local caller.
- The mechanism used to pass values back and forth between the client stub
and the remote object is called marshalling:
- Data to be passed over the connection from the client to the server is
first marshalled into a form that may be conveniently
transported over the 'wire'.
- On the server side, the data is received, and must be unmarshalled
into a form that can be used by, and supplied to, the remote object.
- Data to be returned from the remote object to the client stub must
similarly be marshalled on the server side, and subsequently unmarshalled
on the client side.
- Remember that code can cause exceptions to occur; exceptions can
be [un]marshalled, too.
|