Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
297 views13 pages

Java - RMI

it is a basic resource material for the topic RMI in java.

Uploaded by

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

Java - RMI

it is a basic resource material for the topic RMI in java.

Uploaded by

hemrajsoyal1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Remote Method Invocation (RMI)

Introduction

RMI is a Java API that allows an object residing in one JVM to


invoke methods on an object residing in another JVM.

Basically, it is used as a medium of communication between


two different JVMs

It also enables Java applications to communicate over a


network.
Stub

• Stub: Client proxy that forwards method calls to the


remote object.
• It initialize a connection with remote JVM.

• It writes and transmits the parameters

• Wait for result.

• Read the return value and exception.

• Finally, returns the value to the sever.


Skeleton

• Skeleton: Server Dispatcher handling calls from stub.


• Reads the parameters for remote method.

• Invokes the method on actual remote object.

• Writes and transmits the result to the caller.


Layers of RMI

RMI consists of four main layers:


I. Application Layer: Where the client and server object
reside.
II. Stub and Skeleton Layer: Handles communication between
client and server.
III. Remote Reference Layer (RRL): Manages invocations
between JVMs.
IV. Transport Layer: Manages the transmission of methods.
(Uses TCP/IP protocol)
RMI Architecture

Application
Layer

Stubs &
Skeleton Layer

Remote
Reference Layer

Transport Layer
How RMI is Implemented?

1. Design the interface for the service.

2. Implement the methods specified in the interface.

3. Generate the stub and the skeleton. (via rmic)

4. Register the service by name and location.

5. Use the service in an application.


RMI Communication Process
rmiregistry 4.

(finds object by name) rmic (stores object by name)

5. 2.
3. 3.
Client Stub Skeleton Implemen
tation

(uses) 1.
(implements)
Interface

Client Host Server Host


Implementing RMI in Java
1. Defining Remote Interface:
• It must have java.rmi.Remote and throw RemoteException.
• This exception handles the Network issues.

Hello.java
Implementing RMI in Java
2. Creating Server:
• In the server, we bind object to the RMI registry, making it available for the
clients.

HelloImpl.java
Implementing RMI in Java
3. Creating the Client:
• The client looks up the remote object in the RMI registry and invokes its
methods.

RMIClient.java

And, that is how RMI can be implemented in JAVA


Conclusion

• RMI provides Java-to-Java communication.

• RMI supports various security features.

• RMI enables distributed computing in JAVA.

• Can be used in Cloud-based Systems or Microservices.


Thanks

You might also like