SlideShare a Scribd company logo
Advanced Programming
Remote Method Invocation
Gera
2020
1
Remote Method Invocation (RMI)
•RMI stands for Remote Method Invocation.
•It is a mechanism that allows an object residing in
one system (JVM) to access/invoke an object
running on another JVM.
•RMI is used to build distributed applications; it
provides remote communication between Java
programs.
•It is provided in the package java.rmi.
2
Architecture of an RMI Application
•In an RMI application, we write two programs, a
server program (resides on the server) and a client
program (resides on the client).
• Inside the server program, a remote object is
created and reference of that object is made
available for the client (using the registry).
• The client program requests the remote objects
on the server and tries to invoke its methods
3
Architecture of an RMI Application…
• The following diagram shows the architecture of an RMI application.
4
Architecture of an RMI Application…
Let us now discuss the components of this architecture.
• Transport Layer ─ This layer connects the client and the server. It
manages the existing connection and also sets up new connections.
• Stub ─ A stub is a representation (proxy) of the remote object at
client. It resides in the client system; it acts as a gateway for the
client program.
• Skeleton ─ This is the object which resides on the server side. stub
communicates with this skeleton to pass request to the remote
object.
• RRL (Remote Reference Layer) ─ It is the layer which manages the
references made by the client to the remote object.
5
Working of an RMI Application
• When the client makes a call to the remote object, it is
received by the stub which eventually passes this request
to the RRL.
• When the client-side RRL receives the request, it invokes
a method called invoke() of the object remoteRef. It
passes the request to the RRL on the server side.
• The RRL on the server side passes the request to the
Skeleton (proxy on the server) which finally invokes the
required object on the server.
• The result is passed all the way back to the client.
6
RMI Registry
• RMIregistry is a namespace on which all server objects
are placed.
• Each time the server creates an object, it registers this
object with the RMIregistry (using bind() or reBind()
methods). These are registered using a unique name
known as bind name.
• To invoke a remote object, the client needs a reference
of that object.
• At that time, the client fetches the object from the
registry using its bind name (using lookup() method).
7
RMI Registry…
• The following illustration explains the entire process:
8
Goals of RMI
Following are the goals of RMI:
• To minimize the complexity of the application
• To preserve type safety
• Distributed garbage collection
• Minimize the difference between working with local and
remote objects
9
The Remote Interface
• A remote interface provides the description of all the
methods of a particular remote object.
• The client communicates with this remote interface.
To create a remote interface –
• Create an interface that extends the predefined interface
Remote which belongs to the package.
• Declare all the business methods that can be invoked by the
client in this interface.
• Since there is a chance of network issues during remote calls,
an exception named RemoteException may occur;
10
Developing the Implementation Class
(Remote Object)
•We need to implement the remote interface
created in the earlier step. (We can write an
implementation class separately or we can directly
make the server program implement this
interface.)
To develop an implementation class –
• Implement the interface created in the previous step.
• Provide implementation to all the abstract methods of
the remote interface.
11
Developing the Server Program
• An RMI server program should implement the remote interface
or extend the implementation class. Here, we should create a
remote object and bind it to the RMIregistry.
To develop a server program –
• Create a class that extends the implementation class implemented in the previous
step. (or implement the remote interface)
• Create a remote object by instantiating the implementation class as shown below.
• Export the remote object using the method exportObject() of the class named
UnicastRemoteObject which belongs to the package java.rmi.server.
• Get the RMI registry using the getRegistry() method of the LocateRegistry class
which belongs to the package java.rmi.registry.
• Bind the remote object created to the registry using the bind() method of the class
named Registry. To this method, pass a string representing the bind name and the
object exported, as parameters.
12
Developing the Client Program
• Write a client program in it, fetch the remote object and invoke
the required method using this object.
To develop a client program –
• Create a client class from where you want invoke the remote object.
• Get the RMI registry using the getRegistry() method of the
LocateRegistry class which belongs to the package java.rmi.registry.
• Fetch the object from the registry using the method lookup() of the class
Registry which belongs to the package java.rmi.registry. To this method
you need to pass a string value representing the bind name as a
parameter. This will return you the remote object down cast it.
• The lookup() returns an object of type remote, down cast it to the type
Hello.
• Finally invoke the required method using the obtained remote object. 13
Developing the Client Program
• Write a client program in it, fetch the remote object and invoke
the required method using this object.
To develop a client program –
• Create a client class from where you want invoke the remote object.
• Get the RMI registry using the getRegistry() method of the
LocateRegistry class which belongs to the package java.rmi.registry.
• Fetch the object from the registry using the method lookup() of the class
Registry which belongs to the package java.rmi.registry. To this method
you need to pass a string value representing the bind name as a
parameter. This will return you the remote object down cast it.
• The lookup() returns an object of type remote, down cast it to the type
Hello.
• Finally invoke the required method using the obtained remote object. 14
RMI Implementation
For implementing RMI system The steps are as follows:
• Step–1: Create an Remote interface
• A remote interface specifies the methods that can be invoked
remotely by a client.
• Such interfaces includes the types of objects that will be used as
the parameters and return values for these methods.
• This interface extends java.rmi.Remote interface, It is part of
java.rmi package.
• Its purpose is simply indicate that an interface uses remote
methods and must specify the exception RemoteException in
throws statement. 15
RMI Implementation…
Step–2: Create a Class that implements the interface
• This class must extends java.rmi.UnicastRemoteObject
and must implements an interface defined in step–1.
• This class provides the functionality needed to make
object available from remote machines.
• The Constructor must call super(), and it should call
Naming.rebind(name, this):- It makes RMI registry
which informs that an object having “name” is
available.
16
RMI Implementation…
Step–3: Creates Server that creates an instance of this class.
• Create an instance of the Class which implements Remote
Interface, and gives it a name.
• With the RMI registry, the RMI Object is available to Remote
clients.
• This can be done by rebind() method of Naming class.
• It required 2 arguments:
• First argument is String that names the Server as “AddServer”.
• Second argument is reference to an instanse of AddServerImpl
class.
17
RMI Implementation…
Step–4: Creates Client that connects to Server object
• Clients uses a method Naming.lookup() to get the reference of
Remote objects.
• The client using the interface to hold the reference and for method
call. So that, We should create interface before client request it.
• The Client required 3 command line arguments:
• first argument is IP address or name of Server machine,
• second and third arguments are two numbers required for addition.
• The client forms a string that follows the URL syntax.
• It includes IP address or name of the server and String
“AddServer”.
18
RMI Implementation…
Step–5: Compile all these source classes
• Includes Remote Interfaces, their implementations, any other Server
and Client classes.
Step–6: Run the RMI Interface compiler
• RMI Interface compiler (i.e. rmic) can be run on the class that
implements Remote Interface.
• rmic compiler runs on the .class file and not on .java files.
Step–7: Start RMI Registry
• The program rmiregistry comes with JDK in bin directory.
• For Windows the command is start rmiregistry on command prompt.
• Before starting you RMI Server, RMI Registry must be started. 19
RMI Implementation…
Step–8: Start Server Class
• For windows, the command for staring server is start java
MyRMIServer on command prompt.
• After executing this command, Server starts running and creates
an instance of RMI classes which implements Remote Interface.
Step–9: Run Client Program
• For widows, the command for starting client is java MyRMIClient
on command prompt.
• The client program will ask for RMI Registry for reference.
• After getting the reference, it can invoke any Remote method.
20
Marshalling
• Marshalling is the process of transforming the memory
representation of an object to a data format suitable for storage
or transmission. i.e. It is the process of converting a data
structure or object into a sequence of bits so that it can be stored
in a file, a memory buffer, or transmitted across a network.
• It is typically used when data must be moved between different
parts of a computer program or from one program to another.
Unmarshalling
• The reverse process of marshalling is called unmarshalling.
• The process of, extracting a data structure from a series of bytes,
is called unmarshalling.
21
References
➢S. Horstmann and Gary Cornell, Core Java 2 – Volume II-
Advanced Features, Sun Microsystems Press
➢Harvey M. Deitel and Paul J. Deitel, Java How to
Program, Deitel & Associates
➢Tutorials Point “Java RMI,” tutorialspoint.com
➢Prof. Shailesh T. Gahane, Dr. D Y Patil School of MCA,
Pune, “Java Programming Remote Method Invocation ”
22
Gerabirhan Paulos
ToCourseInfo@gmail.com

More Related Content

What's hot

Java RMI
Java RMIJava RMI
Java RMI
Prajakta Nimje
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
Nitish Nagar
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket ProgrammingMousmi Pawar
 
Java Networking
Java NetworkingJava Networking
Java Networking
68SachinYadavSYCS
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Java RMI Presentation
Java RMI PresentationJava RMI Presentation
Java RMI Presentation
Masud Rahman
 
Java Networking
Java NetworkingJava Networking
Java Networking
Sunil OS
 
Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)UC San Diego
 
Java rmi tutorial
Java rmi tutorialJava rmi tutorial
Java rmi tutorial
HarikaReddy115
 
An eclipse client server architecture with asynchronous messaging
An eclipse client server architecture with asynchronous messagingAn eclipse client server architecture with asynchronous messaging
An eclipse client server architecture with asynchronous messagingThomas Kratz
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
Sonali Parab
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVA
Prankit Mishra
 
Lambda expressions java8 - yousry
Lambda expressions java8 - yousryLambda expressions java8 - yousry
Lambda expressions java8 - yousry
yousry ibrahim
 
Rmi ppt-2003
Rmi ppt-2003Rmi ppt-2003
Rmi ppt-2003
kalaranjani1990
 
Windows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside worldWindows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside world
Prabhakaran Soundarapandian
 
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
Jitendra Bafna
 
Enterprise java unit-2_chapter-1
Enterprise  java unit-2_chapter-1Enterprise  java unit-2_chapter-1
Enterprise java unit-2_chapter-1
sandeep54552
 
04 android
04 android04 android
04 androidguru472
 
Spring integration
Spring integrationSpring integration
Spring integration
Oliver Gierke
 
Java
Java Java

What's hot (20)

Java RMI
Java RMIJava RMI
Java RMI
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Java RMI Presentation
Java RMI PresentationJava RMI Presentation
Java RMI Presentation
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
 
Java rmi tutorial
Java rmi tutorialJava rmi tutorial
Java rmi tutorial
 
An eclipse client server architecture with asynchronous messaging
An eclipse client server architecture with asynchronous messagingAn eclipse client server architecture with asynchronous messaging
An eclipse client server architecture with asynchronous messaging
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVA
 
Lambda expressions java8 - yousry
Lambda expressions java8 - yousryLambda expressions java8 - yousry
Lambda expressions java8 - yousry
 
Rmi ppt-2003
Rmi ppt-2003Rmi ppt-2003
Rmi ppt-2003
 
Windows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside worldWindows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside world
 
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
 
Enterprise java unit-2_chapter-1
Enterprise  java unit-2_chapter-1Enterprise  java unit-2_chapter-1
Enterprise java unit-2_chapter-1
 
04 android
04 android04 android
04 android
 
Spring integration
Spring integrationSpring integration
Spring integration
 
Java
Java Java
Java
 

Similar to Remote Method Invocation, Advanced programming

Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
sakthibalabalamuruga
 
Rmi
RmiRmi
ADB Lab Manual.docx
ADB Lab Manual.docxADB Lab Manual.docx
ADB Lab Manual.docx
SaiKumarPrajapathi
 
A Short Java RMI Tutorial
A Short Java RMI TutorialA Short Java RMI Tutorial
A Short Java RMI TutorialGuo Albert
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
Jalpesh Vasa
 
Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)
eLink Business Innovations
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
ashishspace
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
Thesis Scientist Private Limited
 
Rmi
RmiRmi
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMIbackdoor
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMIbackdoor
 
Module 3 remote method invocation-2
Module 3   remote method  invocation-2Module 3   remote method  invocation-2
Module 3 remote method invocation-2
Ankit Dubey
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
Dew Shishir
 

Similar to Remote Method Invocation, Advanced programming (20)

Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Rmi
RmiRmi
Rmi
 
ADB Lab Manual.docx
ADB Lab Manual.docxADB Lab Manual.docx
ADB Lab Manual.docx
 
DS
DSDS
DS
 
A Short Java RMI Tutorial
A Short Java RMI TutorialA Short Java RMI Tutorial
A Short Java RMI Tutorial
 
Rmi
RmiRmi
Rmi
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
 
Rmi
RmiRmi
Rmi
 
Rmi
RmiRmi
Rmi
 
Rmi
RmiRmi
Rmi
 
17rmi
17rmi17rmi
17rmi
 
Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)Introduction to Remote Method Invocation (RMI)
Introduction to Remote Method Invocation (RMI)
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
Rmi
RmiRmi
Rmi
 
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
 
Introduction To Rmi
Introduction To RmiIntroduction To Rmi
Introduction To Rmi
 
Module 3 remote method invocation-2
Module 3   remote method  invocation-2Module 3   remote method  invocation-2
Module 3 remote method invocation-2
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 

More from Gera Paulos

Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)
Gera Paulos
 
Java Database Connectivity (Advanced programming)
Java Database Connectivity (Advanced programming)Java Database Connectivity (Advanced programming)
Java Database Connectivity (Advanced programming)
Gera Paulos
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)
Gera Paulos
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2
Gera Paulos
 
Advanced programming ch1
Advanced programming ch1Advanced programming ch1
Advanced programming ch1
Gera Paulos
 
Image restoration and enhancement #2
Image restoration and enhancement #2 Image restoration and enhancement #2
Image restoration and enhancement #2
Gera Paulos
 
Introduction to digital image processing #1
Introduction to digital image processing #1Introduction to digital image processing #1
Introduction to digital image processing #1
Gera Paulos
 
Implement maintenance procedures
Implement maintenance proceduresImplement maintenance procedures
Implement maintenance procedures
Gera Paulos
 
Maintain equipment and consumables
Maintain equipment and consumablesMaintain equipment and consumables
Maintain equipment and consumables
Gera Paulos
 
Care for network and computer hardware
Care for network and computer hardwareCare for network and computer hardware
Care for network and computer hardware
Gera Paulos
 
Update and document operational procedures
Update and document operational proceduresUpdate and document operational procedures
Update and document operational procedures
Gera Paulos
 
Apply quality control
Apply quality controlApply quality control
Apply quality control
Gera Paulos
 
Monitoring implementation of work plan
Monitoring implementation of work planMonitoring implementation of work plan
Monitoring implementation of work plan
Gera Paulos
 
Provide first level remote help desk support
Provide first level remote help desk supportProvide first level remote help desk support
Provide first level remote help desk support
Gera Paulos
 
Configuring and administrate server
Configuring and administrate serverConfiguring and administrate server
Configuring and administrate server
Gera Paulos
 
Identifying and resolving network problems
Identifying and resolving network problemsIdentifying and resolving network problems
Identifying and resolving network problems
Gera Paulos
 
Conduct / facilitate user training
Conduct / facilitate user trainingConduct / facilitate user training
Conduct / facilitate user training
Gera Paulos
 
Monitor and administer system and network
Monitor and administer system and network Monitor and administer system and network
Monitor and administer system and network
Gera Paulos
 
Creating technical documents
Creating technical documentsCreating technical documents
Creating technical documents
Gera Paulos
 
Determine bestfit topology lecture #2 edit
Determine bestfit topology lecture #2 editDetermine bestfit topology lecture #2 edit
Determine bestfit topology lecture #2 edit
Gera Paulos
 

More from Gera Paulos (20)

Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)
 
Java Database Connectivity (Advanced programming)
Java Database Connectivity (Advanced programming)Java Database Connectivity (Advanced programming)
Java Database Connectivity (Advanced programming)
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2
 
Advanced programming ch1
Advanced programming ch1Advanced programming ch1
Advanced programming ch1
 
Image restoration and enhancement #2
Image restoration and enhancement #2 Image restoration and enhancement #2
Image restoration and enhancement #2
 
Introduction to digital image processing #1
Introduction to digital image processing #1Introduction to digital image processing #1
Introduction to digital image processing #1
 
Implement maintenance procedures
Implement maintenance proceduresImplement maintenance procedures
Implement maintenance procedures
 
Maintain equipment and consumables
Maintain equipment and consumablesMaintain equipment and consumables
Maintain equipment and consumables
 
Care for network and computer hardware
Care for network and computer hardwareCare for network and computer hardware
Care for network and computer hardware
 
Update and document operational procedures
Update and document operational proceduresUpdate and document operational procedures
Update and document operational procedures
 
Apply quality control
Apply quality controlApply quality control
Apply quality control
 
Monitoring implementation of work plan
Monitoring implementation of work planMonitoring implementation of work plan
Monitoring implementation of work plan
 
Provide first level remote help desk support
Provide first level remote help desk supportProvide first level remote help desk support
Provide first level remote help desk support
 
Configuring and administrate server
Configuring and administrate serverConfiguring and administrate server
Configuring and administrate server
 
Identifying and resolving network problems
Identifying and resolving network problemsIdentifying and resolving network problems
Identifying and resolving network problems
 
Conduct / facilitate user training
Conduct / facilitate user trainingConduct / facilitate user training
Conduct / facilitate user training
 
Monitor and administer system and network
Monitor and administer system and network Monitor and administer system and network
Monitor and administer system and network
 
Creating technical documents
Creating technical documentsCreating technical documents
Creating technical documents
 
Determine bestfit topology lecture #2 edit
Determine bestfit topology lecture #2 editDetermine bestfit topology lecture #2 edit
Determine bestfit topology lecture #2 edit
 

Recently uploaded

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 

Remote Method Invocation, Advanced programming

  • 1. Advanced Programming Remote Method Invocation Gera 2020 1
  • 2. Remote Method Invocation (RMI) •RMI stands for Remote Method Invocation. •It is a mechanism that allows an object residing in one system (JVM) to access/invoke an object running on another JVM. •RMI is used to build distributed applications; it provides remote communication between Java programs. •It is provided in the package java.rmi. 2
  • 3. Architecture of an RMI Application •In an RMI application, we write two programs, a server program (resides on the server) and a client program (resides on the client). • Inside the server program, a remote object is created and reference of that object is made available for the client (using the registry). • The client program requests the remote objects on the server and tries to invoke its methods 3
  • 4. Architecture of an RMI Application… • The following diagram shows the architecture of an RMI application. 4
  • 5. Architecture of an RMI Application… Let us now discuss the components of this architecture. • Transport Layer ─ This layer connects the client and the server. It manages the existing connection and also sets up new connections. • Stub ─ A stub is a representation (proxy) of the remote object at client. It resides in the client system; it acts as a gateway for the client program. • Skeleton ─ This is the object which resides on the server side. stub communicates with this skeleton to pass request to the remote object. • RRL (Remote Reference Layer) ─ It is the layer which manages the references made by the client to the remote object. 5
  • 6. Working of an RMI Application • When the client makes a call to the remote object, it is received by the stub which eventually passes this request to the RRL. • When the client-side RRL receives the request, it invokes a method called invoke() of the object remoteRef. It passes the request to the RRL on the server side. • The RRL on the server side passes the request to the Skeleton (proxy on the server) which finally invokes the required object on the server. • The result is passed all the way back to the client. 6
  • 7. RMI Registry • RMIregistry is a namespace on which all server objects are placed. • Each time the server creates an object, it registers this object with the RMIregistry (using bind() or reBind() methods). These are registered using a unique name known as bind name. • To invoke a remote object, the client needs a reference of that object. • At that time, the client fetches the object from the registry using its bind name (using lookup() method). 7
  • 8. RMI Registry… • The following illustration explains the entire process: 8
  • 9. Goals of RMI Following are the goals of RMI: • To minimize the complexity of the application • To preserve type safety • Distributed garbage collection • Minimize the difference between working with local and remote objects 9
  • 10. The Remote Interface • A remote interface provides the description of all the methods of a particular remote object. • The client communicates with this remote interface. To create a remote interface – • Create an interface that extends the predefined interface Remote which belongs to the package. • Declare all the business methods that can be invoked by the client in this interface. • Since there is a chance of network issues during remote calls, an exception named RemoteException may occur; 10
  • 11. Developing the Implementation Class (Remote Object) •We need to implement the remote interface created in the earlier step. (We can write an implementation class separately or we can directly make the server program implement this interface.) To develop an implementation class – • Implement the interface created in the previous step. • Provide implementation to all the abstract methods of the remote interface. 11
  • 12. Developing the Server Program • An RMI server program should implement the remote interface or extend the implementation class. Here, we should create a remote object and bind it to the RMIregistry. To develop a server program – • Create a class that extends the implementation class implemented in the previous step. (or implement the remote interface) • Create a remote object by instantiating the implementation class as shown below. • Export the remote object using the method exportObject() of the class named UnicastRemoteObject which belongs to the package java.rmi.server. • Get the RMI registry using the getRegistry() method of the LocateRegistry class which belongs to the package java.rmi.registry. • Bind the remote object created to the registry using the bind() method of the class named Registry. To this method, pass a string representing the bind name and the object exported, as parameters. 12
  • 13. Developing the Client Program • Write a client program in it, fetch the remote object and invoke the required method using this object. To develop a client program – • Create a client class from where you want invoke the remote object. • Get the RMI registry using the getRegistry() method of the LocateRegistry class which belongs to the package java.rmi.registry. • Fetch the object from the registry using the method lookup() of the class Registry which belongs to the package java.rmi.registry. To this method you need to pass a string value representing the bind name as a parameter. This will return you the remote object down cast it. • The lookup() returns an object of type remote, down cast it to the type Hello. • Finally invoke the required method using the obtained remote object. 13
  • 14. Developing the Client Program • Write a client program in it, fetch the remote object and invoke the required method using this object. To develop a client program – • Create a client class from where you want invoke the remote object. • Get the RMI registry using the getRegistry() method of the LocateRegistry class which belongs to the package java.rmi.registry. • Fetch the object from the registry using the method lookup() of the class Registry which belongs to the package java.rmi.registry. To this method you need to pass a string value representing the bind name as a parameter. This will return you the remote object down cast it. • The lookup() returns an object of type remote, down cast it to the type Hello. • Finally invoke the required method using the obtained remote object. 14
  • 15. RMI Implementation For implementing RMI system The steps are as follows: • Step–1: Create an Remote interface • A remote interface specifies the methods that can be invoked remotely by a client. • Such interfaces includes the types of objects that will be used as the parameters and return values for these methods. • This interface extends java.rmi.Remote interface, It is part of java.rmi package. • Its purpose is simply indicate that an interface uses remote methods and must specify the exception RemoteException in throws statement. 15
  • 16. RMI Implementation… Step–2: Create a Class that implements the interface • This class must extends java.rmi.UnicastRemoteObject and must implements an interface defined in step–1. • This class provides the functionality needed to make object available from remote machines. • The Constructor must call super(), and it should call Naming.rebind(name, this):- It makes RMI registry which informs that an object having “name” is available. 16
  • 17. RMI Implementation… Step–3: Creates Server that creates an instance of this class. • Create an instance of the Class which implements Remote Interface, and gives it a name. • With the RMI registry, the RMI Object is available to Remote clients. • This can be done by rebind() method of Naming class. • It required 2 arguments: • First argument is String that names the Server as “AddServer”. • Second argument is reference to an instanse of AddServerImpl class. 17
  • 18. RMI Implementation… Step–4: Creates Client that connects to Server object • Clients uses a method Naming.lookup() to get the reference of Remote objects. • The client using the interface to hold the reference and for method call. So that, We should create interface before client request it. • The Client required 3 command line arguments: • first argument is IP address or name of Server machine, • second and third arguments are two numbers required for addition. • The client forms a string that follows the URL syntax. • It includes IP address or name of the server and String “AddServer”. 18
  • 19. RMI Implementation… Step–5: Compile all these source classes • Includes Remote Interfaces, their implementations, any other Server and Client classes. Step–6: Run the RMI Interface compiler • RMI Interface compiler (i.e. rmic) can be run on the class that implements Remote Interface. • rmic compiler runs on the .class file and not on .java files. Step–7: Start RMI Registry • The program rmiregistry comes with JDK in bin directory. • For Windows the command is start rmiregistry on command prompt. • Before starting you RMI Server, RMI Registry must be started. 19
  • 20. RMI Implementation… Step–8: Start Server Class • For windows, the command for staring server is start java MyRMIServer on command prompt. • After executing this command, Server starts running and creates an instance of RMI classes which implements Remote Interface. Step–9: Run Client Program • For widows, the command for starting client is java MyRMIClient on command prompt. • The client program will ask for RMI Registry for reference. • After getting the reference, it can invoke any Remote method. 20
  • 21. Marshalling • Marshalling is the process of transforming the memory representation of an object to a data format suitable for storage or transmission. i.e. It is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file, a memory buffer, or transmitted across a network. • It is typically used when data must be moved between different parts of a computer program or from one program to another. Unmarshalling • The reverse process of marshalling is called unmarshalling. • The process of, extracting a data structure from a series of bytes, is called unmarshalling. 21
  • 22. References ➢S. Horstmann and Gary Cornell, Core Java 2 – Volume II- Advanced Features, Sun Microsystems Press ➢Harvey M. Deitel and Paul J. Deitel, Java How to Program, Deitel & Associates ➢Tutorials Point “Java RMI,” tutorialspoint.com ➢Prof. Shailesh T. Gahane, Dr. D Y Patil School of MCA, Pune, “Java Programming Remote Method Invocation ” 22 Gerabirhan Paulos ToCourseInfo@gmail.com