17 June 2011

interview questions java : RMI

RMI
Contributed by:  Saritha G Pillai

Q. What is RMI?

Answer. Remote Method Invocation (RMI) is the process of activating a method on a remotely running object. RMI offers location transparency in the sense that it gives the feel that a method is executed on a locally running object.

download.oracle.com/javase/tutorial/rmi/index.html

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136424.html

http://java.sun.com/developer/onlineTraining/rmi/RMI.html

Q. Discuss in brief about Remote Method Invocation (RMI) and its working.

Answer.  RMI is a java object equivalent process that invokes a method in a distributed environment.RMI performs the communication among objects using object-to-object communication. RMI uses the objects distribution techniques and invokes methods of objects which are located in a remote site.

Working of RMI:

The code from machine A is being accessed for the object that is residing on machine B in a remote relocation. There are two intermediate objects called a ‘stub’ and a ‘skeleton’, which actually handles the communication. The following are the tasks that performed by these two objects:

Task that are to be handled by the stub object (on machine A):

 Building a information block which consists of
- an identifier of the remote object
- an operation number that describes the method to be called and
- the method parameters called marshaled parameters that are to be encoded into a suitable format for transporting over the network
Sending the information to the server.

The tasks that are to be handled by the skeleton object (on machine B) are:

Unmarshalling the parameters
Invoking the required method of the object which is lying on the server
Capturing and returning the value if successful or an exception if unsuccessful , after the call on the server
Marshalling the returned value
Packaging the value that is in the marshaled form and sending to the stub on the client.

Subsequently the stub object unmarshals the return value or exception from the server as the case may be. This is the returned value of the remote method invocation. If an exception is thrown, the stub object will rethrow the exception to the caller.

download.oracle.com/javase/tutorial/rmi/index.html

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136424.html

http://java.sun.com/developer/onlineTraining/rmi/RMI.html

No comments:

Post a Comment