SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
Advanced Java Programming
Topic: Distributed Programming (RMI)

By
Ravi Kant Sahu
Asst. Professor, LPU
Remote method INVoCAtIoN
(RMI)

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Introduction


RMI is a mechanism for communicating (only) between two
machines running Java Virtual Machines.



When Java code on machine A needs a service or a method,
respectively, of (remote Java object) objB on machine B it starts
a remote method invocation.



It does this the same way as invoking a local (Java) object's
method.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Method Invocation


Java RMI is a mechanism that allows one to invoke a method on
an object that exists in another address space.



The other address space could be on the same machine or a
different one.



The RMI mechanism is basically an object-oriented RPC
mechanism.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
RMI ARchItectuRe

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Communication


RMI allows an object to invoke methods on an object running in
another JVM.



RMI provides remote communication between the applications
using two objects:
1. Stub
2. Skeleton



A remote object is an object whose method can be invoked from
another JVM.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Understanding Stub and Skeleton

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Stub



Stub is an object which acts as a gateway for the client side.
All the outgoing requests are routed through Stub.
It represents the remote object at the client side.



Stub performs the following tasks:




1. It initiates a connection with remote JVM.
2. It writes and transmits the parameters to remote JVM
(Marshaling).
3. It reads the returned value or exception (Unmarshaling).
4. Finally, returns the result to the Caller.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Skeleton


Skeleton is an object which acts as a gateway for the srver side.



All the outgoing requests are routed through Stub.



Skeleton performs the following tasks:
1. It reads the parameters for the remote method.
2. It reads the parameters from caller (Unmarshaling).
3. It invokes the method on the actual remote object.
4. It writes and transmits the result to the caller (Marshaling).

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Writing rMi ApplicAtions

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Writing RMI Programs
Steps to write RMI program:
1. Create a remote Interface.
2. Provide implementation of the remote interface (Remote
class).
3. Compile the implementation class and create the stub and
skeleton objects using rmic tool (rmic remoteclass).
4. Start the registry service by rmiregistry tool (start rmiregistry).
5. Create and start the remote application.
6. Create and start the client application.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote InteRface & class

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Class


A Remote class has two parts: the interface and the class itself.

Remote Interface:
The Remote interface must have the following properties:
1. The interface must be public.
2. The interface must extend the interface java.rmi.Remote.
3. Every method in the interface must declare that it throws
java.rmi.RemoteException. Other exceptions may also be
thrown.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Interface
import java.rmi.*;
public interface RemoteInterface extends Remote
{
double sum(double d1, double d2) throws RemoteException;
}

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Class


The Remote class itself has the following properties:
1. It must implement a Remote interface.
2. It should extend the java.rmi.server.UnicastRemoteObject
class.
3. It can have methods that are not in its Remote interface. These
can only be invoked locally.

Note: Objects of such a class exist in the address space of the
server and can be invoked remotely.

Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Remote Class
import java.rmi.*;
import java.rmi.server.*;
public class RemoteClass extends UnicastRemoteObject implements
RemoteInterface
{
public RemoteClass() throws RemoteException
{}
public double sum(double d1, double d2) throws RemoteException
{
return d1 + d2;
}
}
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Distributed Programming (RMI)

Mais conteúdo relacionado

Mais procurados

Java interview questions 1
Java interview questions 1Java interview questions 1
Java interview questions 1Sherihan Anver
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2Sherihan Anver
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocksİbrahim Kürce
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 iimjobs and hirist
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructorShivam Singhal
 
Java se 8 fundamentals
Java se 8 fundamentalsJava se 8 fundamentals
Java se 8 fundamentalsmegharajk
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java ProgrammingMath-Circle
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interviewKuntal Bhowmick
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statementsİbrahim Kürce
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)Ravi Kant Sahu
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsİbrahim Kürce
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfnofakeNews
 
Lecture 3 java basics
Lecture 3 java basicsLecture 3 java basics
Lecture 3 java basicsthe_wumberlog
 
Core java lessons
Core java lessonsCore java lessons
Core java lessonsvivek shah
 

Mais procurados (20)

Java interview questions 1
Java interview questions 1Java interview questions 1
Java interview questions 1
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructor
 
Java se 8 fundamentals
Java se 8 fundamentalsJava se 8 fundamentals
Java se 8 fundamentals
 
Core java
Core javaCore java
Core java
 
Java notes
Java notesJava notes
Java notes
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
 
Core Java
Core JavaCore Java
Core Java
 
Java questions for interview
Java questions for interviewJava questions for interview
Java questions for interview
 
Java reflection
Java reflectionJava reflection
Java reflection
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
 
Presentation on java
Presentation  on  javaPresentation  on  java
Presentation on java
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIs
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
 
Lecture 3 java basics
Lecture 3 java basicsLecture 3 java basics
Lecture 3 java basics
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
 

Destaque (12)

Jun 2012(1)
Jun 2012(1)Jun 2012(1)
Jun 2012(1)
 
Internationalization
InternationalizationInternationalization
Internationalization
 
Basic IO
Basic IOBasic IO
Basic IO
 
Collection framework
Collection frameworkCollection framework
Collection framework
 
Jdbc
JdbcJdbc
Jdbc
 
Questions for Class I & II
Questions for Class I & IIQuestions for Class I & II
Questions for Class I & II
 
Event handling
Event handlingEvent handling
Event handling
 
Servlets
ServletsServlets
Servlets
 
List classes
List classesList classes
List classes
 
Sms several papers
Sms several papersSms several papers
Sms several papers
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
 
Generics
GenericsGenerics
Generics
 

Semelhante a Distributed Programming (RMI)

Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method InvocationPaul Pajo
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocationVeni7
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocationDew Shishir
 
Report on mini project(Student database handling using RMI)
Report on mini project(Student database handling using RMI)Report on mini project(Student database handling using RMI)
Report on mini project(Student database handling using RMI)shraddha mane
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method InvocationSonali Parab
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)Ghadeer AlHasan
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Sonali Parab
 
Module 3 remote method invocation-2
Module 3   remote method  invocation-2Module 3   remote method  invocation-2
Module 3 remote method invocation-2Ankit Dubey
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01heenamithadiya
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVAPrankit Mishra
 

Semelhante a Distributed Programming (RMI) (20)

Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Java rmi tutorial
Java rmi tutorialJava rmi tutorial
Java rmi tutorial
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Report on mini project(Student database handling using RMI)
Report on mini project(Student database handling using RMI)Report on mini project(Student database handling using RMI)
Report on mini project(Student database handling using RMI)
 
Oracle docs rmi applications
Oracle docs rmi applicationsOracle docs rmi applications
Oracle docs rmi applications
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)
 
Java RMI
Java RMIJava RMI
Java RMI
 
Rmi
RmiRmi
Rmi
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java 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 invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Basic java
Basic java Basic java
Basic java
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01
 
Java rmi
Java rmiJava rmi
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
 
RMI (Remote Method Invocation)
RMI (Remote Method Invocation)RMI (Remote Method Invocation)
RMI (Remote Method Invocation)
 
ADB Lab Manual.docx
ADB Lab Manual.docxADB Lab Manual.docx
ADB Lab Manual.docx
 

Último

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 

Último (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Distributed Programming (RMI)

  • 1. Advanced Java Programming Topic: Distributed Programming (RMI) By Ravi Kant Sahu Asst. Professor, LPU
  • 2. Remote method INVoCAtIoN (RMI) Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 3. Introduction  RMI is a mechanism for communicating (only) between two machines running Java Virtual Machines.  When Java code on machine A needs a service or a method, respectively, of (remote Java object) objB on machine B it starts a remote method invocation.  It does this the same way as invoking a local (Java) object's method. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 4. Remote Method Invocation  Java RMI is a mechanism that allows one to invoke a method on an object that exists in another address space.  The other address space could be on the same machine or a different one.  The RMI mechanism is basically an object-oriented RPC mechanism. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 5. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 6. RMI ARchItectuRe Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 7. Remote Communication  RMI allows an object to invoke methods on an object running in another JVM.  RMI provides remote communication between the applications using two objects: 1. Stub 2. Skeleton  A remote object is an object whose method can be invoked from another JVM. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 8. Understanding Stub and Skeleton Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 9. Stub  Stub is an object which acts as a gateway for the client side. All the outgoing requests are routed through Stub. It represents the remote object at the client side.  Stub performs the following tasks:   1. It initiates a connection with remote JVM. 2. It writes and transmits the parameters to remote JVM (Marshaling). 3. It reads the returned value or exception (Unmarshaling). 4. Finally, returns the result to the Caller. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 10. Skeleton  Skeleton is an object which acts as a gateway for the srver side.  All the outgoing requests are routed through Stub.  Skeleton performs the following tasks: 1. It reads the parameters for the remote method. 2. It reads the parameters from caller (Unmarshaling). 3. It invokes the method on the actual remote object. 4. It writes and transmits the result to the caller (Marshaling). Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 11. Writing rMi ApplicAtions Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 12. Writing RMI Programs Steps to write RMI program: 1. Create a remote Interface. 2. Provide implementation of the remote interface (Remote class). 3. Compile the implementation class and create the stub and skeleton objects using rmic tool (rmic remoteclass). 4. Start the registry service by rmiregistry tool (start rmiregistry). 5. Create and start the remote application. 6. Create and start the client application. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 13. Remote InteRface & class Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 14. Remote Class  A Remote class has two parts: the interface and the class itself. Remote Interface: The Remote interface must have the following properties: 1. The interface must be public. 2. The interface must extend the interface java.rmi.Remote. 3. Every method in the interface must declare that it throws java.rmi.RemoteException. Other exceptions may also be thrown. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 15. Remote Interface import java.rmi.*; public interface RemoteInterface extends Remote { double sum(double d1, double d2) throws RemoteException; } Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 16. Remote Class  The Remote class itself has the following properties: 1. It must implement a Remote interface. 2. It should extend the java.rmi.server.UnicastRemoteObject class. 3. It can have methods that are not in its Remote interface. These can only be invoked locally. Note: Objects of such a class exist in the address space of the server and can be invoked remotely. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 17. Remote Class import java.rmi.*; import java.rmi.server.*; public class RemoteClass extends UnicastRemoteObject implements RemoteInterface { public RemoteClass() throws RemoteException {} public double sum(double d1, double d2) throws RemoteException { return d1 + d2; } } Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)