RPC in the Java Platform

In distributed computing, there is an essential need for the applications in the distributed environment to be able to use the functionalities offered by each application without knowing how these functionalities are implemented. One common possibility for this is the Remote procedure call (RPC), which is an Inter-Proccess communication that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network). Java Remote Method Invocation is the Java implementation of Remote Procedure Call. In the solution for this "Problem", we will take a look at the mechanism of Java RMI.
1 answer

How Java RMI Works

RMI applications often comprise two separate programs, a server and a client. A typical server program creates some remote objects, makes references to these objects accessible, and waits for clients to invoke methods on these objects. A typical client program obtains a remote reference to one or more remote objects on a server and then invokes methods on them. RMI provides the mechanism by which the server and the client communicate and pass information back and forth. Such an application is sometimes referred to as a distributed object application

Distributed object applications need to do the following:
* Locate remote objects. Applications can use various mechanisms to obtain references to remote objects. For example, an application can register its remote objects with RMI's simple naming facility, the RMI registry. Alternatively, an application can pass and return remote object references as part of other remote invocations.
* Communicate with remote objects. Details of communication between remote objects are handled by RMI. To the programmer, remote communication looks similar to regular Java method invocations.
* Load class definitions for objects that are passed around. Because RMI enables objects to be passed back and forth, it provides mechanisms for loading an object's class definitions as well as for transmitting an object's data

The server calls the registry to associate (or bind) a name with a remote object. The client looks up the remote object by its name in the server's registry and then invokes a method on it. The receiver can download the definition of an object's class if the class is not defined in the receiver's Java virtual machine.
All of the types and behavior of an object, previously available only in a single Java virtual machine, can be transmitted to another, possibly remote, Java virtual machine. RMI passes objects by their actual classes, so the behavior of the objects is not changed when they are sent to another Java virtual machine. This capability enables new types and behaviors to be introduced into a remote Java virtual machine, thus dynamically extending the behavior of an application

Taggings: