The Remote Method Invocation(RMI) works similar to remote procedure calls(RPC). All RMI functionality found in the the java.rmi package. The protocol need to run java-only implementation is known as Java Remote Method Protocol(JRMP) and in order to run in non-JVM, then CORBA is used.
Generally RMI comprise of two separate programs, a server and a client. A server program creates some remote objects, and makes references to these object which further waits for client to invoke methods through these objects. When server and client communicate and pass their information such type of application is sometimes referred to as distributed object application.
The Java RMI allow programmer to execute remote function which behave similar to local functions calls but the difference is that it exits somewhere else.
The servers first need to bind its name to the registry because RMI servers on the same host bind remote object to names. Clients on local and remote hosts can then look up remote objects and can pass message to each other. The client lookup for the server name in the registry to establish the remote references.
The rmic is a command which generates stubs, skeletons, ties for remote objects using either the JRMP or IIOP protocols. These classes files are generated from the compiled Java files classes that contain remote object implementations. The stub is responsible for sending the remote call which passes over to the server-side skeleton The stub opening a socket to the remote server, marshaling the object parameters and forwarding the data stream to the skeleton. A skeleton contains a method that receives the remote calls, unmarshals all the parameters, and invokes the actual remote object implementation. And once you started the Registry, the server will be started and able to store itself in the Registry.
In the next page you will see few examples of RMI
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial