SlideShare une entreprise Scribd logo
1  sur  14
Remote Method Invocation (RMI)

          Session 11




                       Master Java - Level 2/ Session 11 / 1 of 14
Session Objectives
   Describe the Java Distributed Model

   Analyse RMI Architeture

   Discuss RMI packages

   Explain how to implement RMI
    client and server
                              Master Java - Level 2/ Session 11/ 2 of 14
Distributed Application
   A Distributed application is an application whose
    processing is distributed across multiple networked
    computers.

   The various models that can be used for developing
    distributed applications
     Distributed Component Object Model(DCOM)
     Common Object Request Broker Architecture(CORBA)

     Remote Method Invocation(RMI)




                                    Master Java - Level 2/ Session 11/ 3 of 14
Remote Method Invocation (RMI)
The distributed object model used by Java allows objects
in one JVM to invoke methods of objects in a separate
JVM. This is known as RMI.

  Java Virtual Machine         Java Virtual Machine


       Client Object     TCP   Server Object




                                   Master Java - Level 2/ Session 11/ 4 of 14
RMI System Layers
   The RMI system consists of three layers in its
    architecture:

       Stub/Skeleton Layer

       Remote Reference Layer

       Transport Layer



                                    Master Java - Level 2/ Session 11/ 5 of 14
RMI Architecture
Java Virtual Machine         Java Virtual Machine

   Client Object               Server Object ‘S’


  Object ‘S’ Stub            Object ‘S’ Skeleton


 Remote Reference             Remote Reference
      Layer                        Layer
  TransportLayer       TCP       TransportLayer

                              Master Java - Level 2/ Session 11/ 6 of 14
Remote Method Invocation API
   The five packages in RMI API are:
           java.rmi
           java.rmi.registry
           java.rmi.server
          java.rmi.activation
          java.rmi.dgc


We shall be examining the first three in detail

                                  Master Java - Level 2/ Session 11/ 7 of 14
The java.rmi Package
   The java.rmi package declares
       The Remote interface

       The MarshalledObject class

       The Naming class

       The RMISecurityManager class

       A number of exceptions that are used with remote
        method invocations
                                         Master Java - Level 2/ Session 11/ 8 of 14
The java.rmi.registry Package
   The interfaces and class of the java.rmi.registry
    package are used to handle remote objects by
    name and also to register those remote objects

   The java.rmi.registry package provides

       The Registry interface

       The RegistryHandler interface

       The LocateRegistry class.       Master Java - Level 2/ Session 11/ 9 of 14
The java.rmi.server Package
   The java.rmi.server package supports both client and
    server aspects of RMI like a class implementation of
    Remote interface, client stub and server skeleton
   Classes and Interfaces declared are :

       RemoteObject class             Skeleton interface

       RemoteServer class             RMIClassLoader class

       UnicastRemoteObject class      RMISocketFactory class

       RemoteStub class
                                          Master Java - Level 2/ Session 11/ 10 of 14
Implementing RMI
   Implement RMI server
     Create Remote Interface
     Create a class that implements the remote interface

     Create stub and skeleton classes

     Copy Remote interface and stub to client

     Create and register remote objcet



   Implement the RMI client
       Call the remote interface by using the ‘lookup()’
        method of the Naming class.


                                          Master Java - Level 2/ Session 11/ 11 of 14
RMI flow - I

Client Virtual Machine          Server Virtual Machine

     Client                                 Remote Object                         1


                 Stub            Skeleton                   Server


1. Server Creates Remote      Registry Virtual Machine
                                                                                  2
   object.
                                   Remote Object
2. Server Registers Remote          Registered
   object with RMI registry
                                    Master Java - Level 2/ Session 11/ 12 of 14
RMI flow - II

    Client Virtual Machine      Server Virtual Machine

        Client                               Remote Object


                  Stub            Skeleton                 Server

                        4
3
                               3. Client requests object from
    Registry Virtual Machine
                                 registry

        Remote Object          4. Registry returns remote
         Registered               reference through interface
                                     Master Java - Level 2/ Session 11/ 13 of 14
RMI flow - III

Client Virtual Machine             Server Virtual Machine
                                     7
    Client                                 Remote Object

        5                  6                             Server
              Stub                  Skeleton


                               5. Client invokes stub method
Registry Virtual Machine
                               6. Stub talks to skeleton
    Remote Object
     Registered                7. Skeleton invokes remote
                                   object method.2/ Session 11/ 14 of 14
                                       Master Java - Level

Contenu connexe

Tendances

Multithreading models.ppt
Multithreading models.pptMultithreading models.ppt
Multithreading models.ppt
Luis Goldster
 

Tendances (20)

2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts
 
servlet in java
servlet in javaservlet in java
servlet in java
 
Locks In Disributed Systems
Locks In Disributed SystemsLocks In Disributed Systems
Locks In Disributed Systems
 
Remote Method Invocation in JAVA
Remote Method Invocation in JAVARemote Method Invocation in JAVA
Remote Method Invocation in JAVA
 
IIS
IISIIS
IIS
 
enterprise java bean
enterprise java beanenterprise java bean
enterprise java bean
 
Enterprise Java Beans - EJB
Enterprise Java Beans - EJBEnterprise Java Beans - EJB
Enterprise Java Beans - EJB
 
Corba
CorbaCorba
Corba
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
Naming in Distributed System
Naming in Distributed SystemNaming in Distributed System
Naming in Distributed System
 
CORBA.ppt
CORBA.pptCORBA.ppt
CORBA.ppt
 
Java Garbage Collection - How it works
Java Garbage Collection - How it worksJava Garbage Collection - How it works
Java Garbage Collection - How it works
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
 
Multithreading models.ppt
Multithreading models.pptMultithreading models.ppt
Multithreading models.ppt
 
message passing
 message passing message passing
message passing
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
Html5 for mobiles
Html5 for mobilesHtml5 for mobiles
Html5 for mobiles
 

Similaire à RMI

A Short Java RMI Tutorial
A Short Java RMI TutorialA Short Java RMI Tutorial
A Short Java RMI Tutorial
Guo Albert
 
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
backdoor
 

Similaire à RMI (20)

Distributed objects
Distributed objectsDistributed objects
Distributed objects
 
Rmi ppt-2003
Rmi ppt-2003Rmi ppt-2003
Rmi ppt-2003
 
Rmi
RmiRmi
Rmi
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Module 3 remote method invocation-2
Module 3   remote method  invocation-2Module 3   remote method  invocation-2
Module 3 remote method invocation-2
 
Rmi ppt
Rmi pptRmi ppt
Rmi ppt
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Java RMI
Java RMIJava RMI
Java RMI
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01
 
Rmi
RmiRmi
Rmi
 
Java rmi tutorial
Java rmi tutorialJava rmi tutorial
Java rmi tutorial
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programmingRemote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
 
ADB Lab Manual.docx
ADB Lab Manual.docxADB Lab Manual.docx
ADB Lab Manual.docx
 
A Short Java RMI Tutorial
A Short Java RMI TutorialA Short Java RMI Tutorial
A Short Java RMI Tutorial
 
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
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

RMI

  • 1. Remote Method Invocation (RMI) Session 11 Master Java - Level 2/ Session 11 / 1 of 14
  • 2. Session Objectives  Describe the Java Distributed Model  Analyse RMI Architeture  Discuss RMI packages  Explain how to implement RMI client and server Master Java - Level 2/ Session 11/ 2 of 14
  • 3. Distributed Application  A Distributed application is an application whose processing is distributed across multiple networked computers.  The various models that can be used for developing distributed applications  Distributed Component Object Model(DCOM)  Common Object Request Broker Architecture(CORBA)  Remote Method Invocation(RMI) Master Java - Level 2/ Session 11/ 3 of 14
  • 4. Remote Method Invocation (RMI) The distributed object model used by Java allows objects in one JVM to invoke methods of objects in a separate JVM. This is known as RMI. Java Virtual Machine Java Virtual Machine Client Object TCP Server Object Master Java - Level 2/ Session 11/ 4 of 14
  • 5. RMI System Layers  The RMI system consists of three layers in its architecture:  Stub/Skeleton Layer  Remote Reference Layer  Transport Layer Master Java - Level 2/ Session 11/ 5 of 14
  • 6. RMI Architecture Java Virtual Machine Java Virtual Machine Client Object Server Object ‘S’ Object ‘S’ Stub Object ‘S’ Skeleton Remote Reference Remote Reference Layer Layer TransportLayer TCP TransportLayer Master Java - Level 2/ Session 11/ 6 of 14
  • 7. Remote Method Invocation API  The five packages in RMI API are:  java.rmi  java.rmi.registry  java.rmi.server  java.rmi.activation  java.rmi.dgc We shall be examining the first three in detail Master Java - Level 2/ Session 11/ 7 of 14
  • 8. The java.rmi Package  The java.rmi package declares  The Remote interface  The MarshalledObject class  The Naming class  The RMISecurityManager class  A number of exceptions that are used with remote method invocations Master Java - Level 2/ Session 11/ 8 of 14
  • 9. The java.rmi.registry Package  The interfaces and class of the java.rmi.registry package are used to handle remote objects by name and also to register those remote objects  The java.rmi.registry package provides  The Registry interface  The RegistryHandler interface  The LocateRegistry class. Master Java - Level 2/ Session 11/ 9 of 14
  • 10. The java.rmi.server Package  The java.rmi.server package supports both client and server aspects of RMI like a class implementation of Remote interface, client stub and server skeleton  Classes and Interfaces declared are :  RemoteObject class  Skeleton interface  RemoteServer class  RMIClassLoader class  UnicastRemoteObject class  RMISocketFactory class  RemoteStub class Master Java - Level 2/ Session 11/ 10 of 14
  • 11. Implementing RMI  Implement RMI server  Create Remote Interface  Create a class that implements the remote interface  Create stub and skeleton classes  Copy Remote interface and stub to client  Create and register remote objcet  Implement the RMI client  Call the remote interface by using the ‘lookup()’ method of the Naming class. Master Java - Level 2/ Session 11/ 11 of 14
  • 12. RMI flow - I Client Virtual Machine Server Virtual Machine Client Remote Object 1 Stub Skeleton Server 1. Server Creates Remote Registry Virtual Machine 2 object. Remote Object 2. Server Registers Remote Registered object with RMI registry Master Java - Level 2/ Session 11/ 12 of 14
  • 13. RMI flow - II Client Virtual Machine Server Virtual Machine Client Remote Object Stub Skeleton Server 4 3 3. Client requests object from Registry Virtual Machine registry Remote Object 4. Registry returns remote Registered reference through interface Master Java - Level 2/ Session 11/ 13 of 14
  • 14. RMI flow - III Client Virtual Machine Server Virtual Machine 7 Client Remote Object 5 6 Server Stub Skeleton 5. Client invokes stub method Registry Virtual Machine 6. Stub talks to skeleton Remote Object Registered 7. Skeleton invokes remote object method.2/ Session 11/ 14 of 14 Master Java - Level