Rmi - Study: Ex. No: 1 5.12.2016
Rmi - Study: Ex. No: 1 5.12.2016
Rmi - Study: Ex. No: 1 5.12.2016
no : 1
The RMI (Remote Method Invocation) is an API that provides a mechanism to create distributed
application in java. The RMI allows an object to invoke methods on an object running in another
JVM.
1. Application Layer
This layer is nothing but the actual systems (client and server) involved in communication. A
client Java program communicates with the other Java program on the server side. RMI is
nothing but a communication between two JVMs placed on different systems.
2. Proxy Layer
The proxy layer consists of proxies (named as stub and skeleton by designers) for client and
server. Stub is client side proxy and Skeleton is server side proxy.
The stub and skeleton are not hard coded by the Programmer but they are generated by RMI
compiler
Proxies are implicitly connected to RMI mechanism through Remote reference layer, the layer
responsible for object communication and transfer of objects between client and server.
4.Transport layer does not exist separately but is a part of Remote reference layer. Transport
layer is responsible for actually setting up connections and handling the transport of data from
one machine to another.
2.What are different terms and classes that are used in RMI?
A remote object is an object whose method can be invoked from another JVM
The stub is an object, acts as a gateway for the client side. All the outgoing requests are routed
through it. It resides at the client side and represents the remote object.
The skeleton is an object, acts as a gateway for the server side object. All the incoming requests
are routed through it.
The Naming class provides methods for storing and obtaining references to remote objects.
3.What is the method used by RMI client to connect to remote RMI servers?
Stub: A stub is proxy that stands for RMI Server on client side and handles remote method
invocation on behalf of RMI Client.
Skeleton: It is a proxy that stands for RMI client on server side and handles remote method
invocation on RMI Server on behalf of client.
Registry Service: A Registry Service is an application that provides the facility of registration &
lookup of Remote stub.
4.What are the steps that are involved in RMI distributed applications?
3. Compile the implementation class and create the stub and skeleton objects using the rmic
tool
In RMI, a remote interface is an interface that declares a set of methods that may be invoked
from a remote Java virtual machine. A remote interface must satisfy the following requirements:
A remote interface must at least extend, either directly or indirectly, the interface
java.rmi.Remote
The client then uses the stub as an implementation of the remote interface concerned, to perform
the networking part of RMI, interacting with the server JVM to eventually invoke the same
method in the remote object that the client is invoking in the stub.
The Stub is the class that implements the remote interface. It serves as a client-side placeholder
for the remote object
The Skeleton actually knows the real remote objects delegates the stub's request to it and returns
the response to the stub. You require both as they are the essential building blocks for RMI.
RMI has at least three protocol implementations: Java Remote Method Protocol(JRMP), Internet
Inter ORB Protocol(IIOP), and Jini Extensible Remote Invocation(JERI). These are alternatives,
not part of the same thing, All three are indeed layer 6 protocols for those who are still speaking
OSI reference model.
9.Explain various methods of registering and gaining access to the Remote Object?
The methods of remote objects are to be invoked by implementing the java.rmi.Remote interface.
Methods of Remote Object:
bind():
- Binds the specified name to the remote object.
- The name parameter of this method should be in an URL format.
unbind():
- Destroys the binding for a specific name of a remote method in the registry.
rebind():
- Binds again the specified name to the remote object.
- The current binding will be replaced by rebinding.
list():
- Returns the names of the names that were bound to the registry in an array form.
- These names are in the form of URL-formatted string.
lookup():
- A stub, a reference will be returned for the remote object which is related with a specified
name.
"marshalling" refers to the process of converting the data or the objects inbto a byte-stream, and
"unmarshalling" is the reverse process of converting the byte-stream beack to their original data
or object. The conversion is achieved through "serialization".