Monday 22 June 2015

RMI


Remote method invocation,


  • An overview of RMI
  • Writing rmi server
  • Writing rmi client
  • Creating and deploying the application.
Overview :

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.
The RMI provides remote communication between the applications using two objects stub and skeleton.

Understanding stub and skeleton :

RMI uses stub and skeleton object for communication with the remote object.
remote object is an object whose method can be invoked from another JVM. Let's understand the stub and skeleton objects: 

Stub :

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. When the caller invokes method on the stub object, it does the following tasks:

  1. It initiates a connection with remote Virtual Machine (JVM),
  2. It writes and transmits (marshals) the parameters to the remote Virtual Machine (JVM),
  3. It waits for the result
  4. It reads (unmarshals) the return value or exception, and
  5. It finally, returns the value to the caller.

Skeleton : 

The skeleton is an object, acts as a gateway for the server side object. All the incoming requests are routed through it. When the skeleton receives the incoming request, it does the following tasks:

  1. It reads the parameter for the remote method
  2. It invokes the method on the actual remote object, and
  3. It writes and transmits (marshals) the result to the caller.
In the Java 2 SDK, an stub protocol was introduced that eliminates the need for skeletons.
stub and skeleton in RMI
What is distributed application,
  1. The application need to locate the remote method
  2. It need to provide the communication with the remote objects, and
  3. The application need to load the class definitions for the objects.
The RMI application have all these features, so it is called the distributed application.



No comments:

Post a Comment