Remote method invocation
Remote Method Invocation (RMI) is an API which allows an object to invoke a method on an object that exists in another address space, which could be on the same machine or on a remote machine. Through RMI, object running in a JVM present on a computer (Client side) can invoke methods on an object present in another JVM (Server side). RMI creates a public remote server object that enables client and server side communications through simple method calls on the server object.
The communication between client and server is handled by using two intermediate objects: Stub object (on client side) and Skeleton object (on server side).
Stub Object- The stub object on the client machine builds an information block and sends this information to the server. The block consists of identifier of the remote object to be used,method name which is to be invoked,parameters to the remote JVM
Skeleton Object -The skeleton object passes the request from the stub object to the remote object. It calls the desired method on the real object present on the server.It forwards the parameters received from the stub object to the method.