INTRODUCTION• Remote Method Invocation : is the action ofinvoking a method of a remote interface on a remoteobject• The Java RMI allows an object running in one JavaVirtual Machine to invoke methods in an objectrunning in another Java VM• Provides for remote communication betweenprograms written in the Java programming language
OVERVIEW OF RMI• RMI is an object-oriented implementation of theRemote Procedure Call• it is an API for Java programs only UsingRMI, an object server exports a remote object andregisters it with a directory service.• The object provides remote methods, which canbe invoked in client programs.
OVERVIEW OF RMI• A remote object is declared with a remoteinterface The remote interface is implemented bythe remote object.• An object client accesses the object by invokingthe remote methods associated with the objects.• provides support for distributed objects in Java
RMI ARCHITECTURE LAYERS The RMI is built from three abstraction layers.1. The stub/skeleton layer client-side stubs and server-side skeletons2. The remote reference layer remote reference behavior3. The transport layer set up a connection, management, andremote object tracking
STUB/SKELETON LAYER• intercept method calls made by the client to theinterface reference variable and to redirect these callsto a remote RMI service.• A stub is the clients local representative of a remoteobject.• Stub hides all the network-level communication andserialization of parameters in order to present asimple invocation mechanism to the caller.
•When the caller invokes a method on the localstub, this stub is responsible for carrying out themethod call on the remote object.•The stub implements the same set of remoteinterfaces a remote object implements.
•Skeleton works on the server side.•This skeleton is responsible for directing the call tothe actual implementation object.•Stubs and skeletons are generated by the rmiccompiler.• Initiate a call to the remote object Marshalarguments to a marshal stream.• Inform the remote reference layer that the callshould be invoked.• Unmarshal the return value or exception from amarshal stream Inform the remote reference layerthat the call is Complete.
REMOTE REFERENCE LAYER• This layer is the middleware between the stub &skeleton layer and the underlying transport layer.• This layer handles the creation and management ofremote object references.• It also connects clients to exported objects that arerunning on the server via Remote Object Activation.• Responsible for carrying out specific remotereference protocol independent of stubs and skeletons
TRANSPORT LAYER• The transport layer is based on TCP/IP connections.•The transport layer responsibilities:1.Setting up connections to remote address spaces&Managing connections3. Monitoring connection liveness4. Listening for incoming calls5. Maintaing a table of remote objects that reside inthe address space6.Setting up a connection for an incoming call7.Locate the dispatcher for the target of the remotecall and pass the connection to the dispatcher
TRANSPORT LAYER ABSTRACTIONS1.Endpoint: Endpoint is the abstraction used to denote anaddress space or a JVM2.Channel: It is responsible for managing connectionsbetween the local address space and the remote addressspace for which it is a channel3.Connection: It is an abstraction for transferring data
4.Transport:•This abstraction manages channels.• The transport abstraction is responsible for acceptingcalls on incoming connections to the addressspace, setting up a connection object for the call, anddispatching to higher layers in the stream
Advantages1.simple and easy to use2. Seamless Remote Invocation on objects in different virtual machines.3. Very reliable distributed applications.4. Preserves the safety and security provided by the Java runtime.5. Callbacks from servers to applets