Remote Method Invocation in Java

Remote Method Invocation in Object Oriented (Java):

RMI is a technique, using Java language and development environment can write Object Oriented Programming in which objects on different computers can interact with each other over a network. RMI allows any Java object type to be used - even if the client or server has never encountered it before. RMI allows both client and server to dynamically load new object types as required.
The RMI provides remote communication between the applications using two objects stub and skeleton as shown in figure.

Remote Method Invocation in Java

Implementation

·            stub program in the client side of the client-server relationship (this type relationship is mostly used in computing environments using different Operating Systems), and a corresponding skeleton at the server end. The stub appears to the calling program to be the program being called for a service. (Sun uses the term proxy as a synonym for stub.)
·          A Remote Reference Layer that can behave differently depending on the parameters passed by the calling program. For example, this layer can determine whether the request is to call a single remote service or multiple remote programs as in a multicast.
·           A Transport Connection Layer, which sets up and manages the request.

Stub Mechanism

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

Skeleton Mechanism

·             It reads the parameter for the remote method
·             It invokes the method on the actual remote object, and
·             It writes and transmits (marshals) the result to the caller.


Previous
Next Post »