[Go to site: main page, start]

0% found this document useful (0 votes)
10 views3 pages

Java RMI: Remote Method Invocation Explained

The document explains the process of performing remote computation using Java RMI, detailing the roles of key components such as Remote Interface, Remote Class, Stub, and Naming methods. It outlines the flow of control from client to server during remote method invocation and emphasizes the significance of binding and lookup in the RMI registry for client access to remote objects. Overall, it provides a comprehensive overview of how Java RMI facilitates remote method calls across different JVMs.

Uploaded by

bevina2110
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Java RMI: Remote Method Invocation Explained

The document explains the process of performing remote computation using Java RMI, detailing the roles of key components such as Remote Interface, Remote Class, Stub, and Naming methods. It outlines the flow of control from client to server during remote method invocation and emphasizes the significance of binding and lookup in the RMI registry for client access to remote objects. Overall, it provides a comprehensive overview of how Java RMI facilitates remote method calls across different JVMs.

Uploaded by

bevina2110
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

UIT2702 CLOUD AND DISTRIBUTED COMPUTING

RMI
REG NO: 3122 22 5002 019

NAME: BEVINA R

Explain the process of performing a remote computation using Java RMI. Describe each of
the following components and their role in enabling remote method invocation:

a) Remote Interface

b) Remote Class (Servant)

c) Stub

d) Skeleton

e) [Link]() and [Link]() methods

Explain the purpose of each component in the RMI architecture and the flow of control
from the client invoking a remote method to the server executing it. Briefly explain the
significance of binding and lookup in the RMI registry.

Java RMI allows a program running on one Java Virtual Machine (JVM) to invoke methods on
an object running on a different JVM, possibly on a different machine. It’s basically a way to
call methods remotely, just like calling local ones.

a) Remote Interface

This is the starting point. A Remote Interface defines the methods that a client can invoke
remotely.

 It must extend the [Link] interface.

 All the methods declared here must throw RemoteException.

b) Remote Class (Servant)

This is the actual class that implements the Remote Interface. It contains the real logic of the
methods. This class must:

 Implement the remote interface.

 Extend UnicastRemoteObject (or explicitly export the object).


 Handle any remote logic like database access, computations, etc.

This is the server-side logic, the actual work is done here when a remote method is called.

c) Stub

The Stub acts as a client-side proxy (a representative of the remote object). It appears to the
client as if it’s the actual object, but it just forwards method calls to the remote server. It
handles network communication, marshaling (converting method parameters into a byte
stream), and then sends the request to the server. It makes remote methods feel like local
method calls to the client.

d) Skeleton

In earlier versions of Java RMI, the Skeleton was a server-side counterpart to the stub. It
would receive the incoming call, unmarshal the parameters, and pass them to the actual
remote object. It used to handle incoming requests and forward them to the actual
implementation. Now this part is handled by the JVM itself, so it’s no longer required in
modern RMI.

e) [Link]() and [Link]()

These are utility methods from [Link] used to interact with the RMI Registry,
which is like a phonebook for remote objects.

[Link](String name, Remote obj)

 Used on the server to register a remote object with the RMI registry.

 Associates a name with the remote object so clients can discover it.

[Link](String name)

 Used by the client to look up a remote object from the registry using its name.

 Returns a stub to the remote object, which the client can then use to invoke
methods.

Flow of Control (Client to Server)

1. Server Side

o The server implements the remote interface.

o An instance of the implementation class is created and bound to the RMI


registry using [Link]().
2. Client Side

o The client uses [Link]() to get the stub (proxy) for the remote object.

o The client calls a method on the stub.

3. Stub

o The stub marshals the method call and parameters.

o It sends the request over the network to the server.

4. Server

o The RMI runtime unmarshals the data.

o The actual method is executed on the server-side object.

o The result is marshaled and sent back.

5. Client

o The stub receives the result, unmarshals it, and returns it to the client as if it
was a local method call.

Significance of Binding and Lookup

 Binding ([Link]) links a name to a remote object and makes it accessible to


clients via the registry.

 Lookup ([Link]) allows clients to search and access that remote object
using the name.

Without binding and lookup, clients would have no way of locating and connecting to the
remote object.

You might also like