RMI stub and skeleton
What is a skeleton in RMI?Server side stub is refered to as a skeleton.
Explain the role of stub in RMIThe role of the stubs is to marshal and unmarshal the messages that are sent and received on the client or the server side.
Describe how the RMI mechanism works.RMI is a mechanism that is to communicate between two Java Virtual Machines. This just does like invoking a method from local machine. The whole communication is called RMI mechanism.
- To communicate between two remote methods by two different JVMs, there is always two intermediatory objects called stub and skeleton.
- The tasks that are performed by these two objects are as follows:
1. The tasks of stub object (on machine A)
A. Building a block of information which consists of:
- A remote object identifier that is to be used.
- The method describing operation number is to be called.
- The method parameters called marshaled parameters which are encoded into a specific format that is apt for transporting on the network.
B. Sending the above information to the server.
2. The tasks of skeleton object ( on the machine B):
- Unmarshalling the parameters.
- Invoking the real object’s required method which is on the server.
- Capturing the value returned or exception returned by the invoked call on the server.
- Marshaling this value.
- Sending the package along with the value in the form of marshaled back to the stub on the client on the machine A.
- The return value or exception from the server is unmarshalled by the stub and becomes the return value of the RMI. If the exception is thrown by the remote method then the stub object rethrows to the caller.
What are the layers on which RMI implementation is built? Explain them.The Stub/Skeleton Layer:
- The stub/skeleton layer sits in between application layer and the rest of the RMI system and acts as an interface.
- This layer transmits the information to remote layer. This transmission is done through the marshalling of streams.
- These streams performs the object serialization.
- A stub is a remote object at the client-side. This stub implements all the interfaces which remote object implementation supports.
- A skeleton is a remote object at the server-side. This stub consists of methods that invokes dispatch calls to the remote implementation of objects.
The Remote Reference Layer:
- The lower level transport interfaces is dealt by this layer.
- This layer carries a specific remote reference protocol independent of stub and skeletons.
- Every remote object is implemented by choosing their individual remote reference subclasses.
The Transport Layer:
- The transport layer sets up the connections to remote address spaces, manages them, monitors the connection liveliness, and listens the incoming calls.
- The transport layer maintains the remote object’s table available in the address space, in a table. For incoming calls, the transport layer establishes a connection.
- It locates the target dispatcher of the remote calls and passes the connection to the dispatcher.