Sie sind auf Seite 1von 5


no : 1

5.12.2016 RMI - STUDY

1.What is RMI? Explain RMI Architecture.

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

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

3. Remote Reference Layer

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?

RMI Client: It is an object that invokes remote methods on an RMI Server.

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.

A Registry Service provides location transparency of Remote Object to RMI Client.

4.What are the steps that are involved in RMI distributed applications?

1. Create the remote interface

2. Provide the implementation of the remote interface

3. Compile the implementation class and create the stub and skeleton objects using the rmic

4. Start the registry service by rmiregistry tool

5. Create and start the remote application

6. Create and start the client application

5.What is the use of java.rmi.remote Interface in RMI?

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

6.Why are stubs used in RMI?

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

7.What is the role of skeleton in RMI?

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.

8.How many types of protocol implementations do RMI have?

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:
- Binds the specified name to the remote object.
- The name parameter of this method should be in an URL format.

- Destroys the binding for a specific name of a remote method in the registry.
- Binds again the specified name to the remote object.
- The current binding will be replaced by rebinding.

- 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.

- A stub, a reference will be returned for the remote object which is related with a specified

11.Explain Marshalling and demarshalling.

"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".

12.What is the role of java.rmi.Naming class?

The Naming class provides methods for storing and obtaining references to remote objects in a
remote object registry. Each method of the Naming class takes as one of its arguments a name
that is a java.lang.String in URL format (without the scheme component) of the form:

13.What is the default port used by RMI Registry?

Default port used by RMI Registry is 1099 .

14.What is meant by binding in RMI?

Binding a name for a remote object is associating or registering a name for a remote object that
can be used at a later time to look up that remote object. A remote object can be associated with a
name using the Naming class's bind or rebindmethods.

15.What is the use of UnicastRemoteObject in RMI?

java.rmi.server.UnicastRemoteObject is used for exporting a remote object with Java Remote

Method Protocol (JRMP) and obtaining a stub that communicates to the remote object.