SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
RMI Fundamentals

  Chung-Kai Chen




         -1-
What is RMI?
• Remote Method Invocation
• A way to invoke the methods of a object
  that resides in a remote site.
• Similar with RPC, but incorporating OO
  concepts.




                     -2-
The Primary Goal of RMI
• The remote objects is used with just the
  same syntax and semantics as the local
  objects!
• How do we achieve this goal?




                      -3-
public class B {
                  public void method1() {
                     ...
                  }
                  public int method2(double d) {
                     ...
                  }
                  ...
               }


...
...            ...
b.method1();   ...
...            B b = new B();
...            ...
m.k(b);        ...
...
...



      Local    Remote


                  -4-
The tricks
• Use a local object serving as an agent to
  send our requests to the remote object and
  receive any results.
• Such a object is called stub.
• There used to be an object called skeleton residing in the
  remote side to handle the requests, but is no more
  needed after Java 1.2.




                              -5-
Extract the interface
   public interface R extends Remote {
       public void method1() throws RemoteException;
       public int method2(double d) throws RemoteException;
   }



                                                         public class B implements R {
                                                             public void method1()
                                                                 throws RemoteException {
                                                                 ...
                                                             }
                                                             public int method2(double d)
                                                                 throws RemoteException {
                                                                 ...
...                                                          }
...                                                          ...
R r;                                                     }
...
...                                    ...
try {                                  ...
    r.method1();
} catch (RemoteException e) {          B b = new B();
    ...                                ...
}                                      ...
...
...
m.k(r);
...
...


               Local                   Remote


                                            -6-
Export the service (1)
   public interface R extends Remote {
       public void method1() throws RemoteException;
       public int method2(double d) throws RemoteException;
   }

                                       public class B
                                               extends UnicastRemoteObject
                                               implements R {
                                           public B() throws RemoteException {
                                               super();
                                           }
                                           public void method1()
                                               throws RemoteException {
                                               ...
                                           }
...                                        public int method2(double d)
...                                            throws RemoteException {
R r;                                           ...
...                                        }
...                                        ...
try {                                  }
    r.method1();
} catch (RemoteException e) {          ...
    ...                                ...
}                                      try {
...                                        B b = new B();
...                                    } catch (RemoteException e) {
m.k(r);                                    ...
...                                    }
...                                    ...
                                       ...

               Local                   Remote


                                            -7-
Export the service (2)
   public interface R extends Remote {
       public void method1() throws RemoteException;
       public int method2(double d) throws RemoteException;
   }


                                       public class B implements R {
                                           public void method1()
                                               throws RemoteException {
                                               ...
                                           }
                                           public int method2(double d)
                                               throws RemoteException {
                                               ...
                                           }
...                                        ...
...                                    }
R r;
...
...                                    ...
try {                                  ...
    r.method1();                       try {
} catch (RemoteException e) {              B b = new B();
    ...                                    UnicastRemoteObject
}                                              .exportObject(b);
...                                    } catch (RemoteException e) {
...                                        ...
m.k(r);                                }
...                                    ...
...                                    ...


               Local                   Remote


                                            -8-
Registration (1)
   public interface R extends Remote {
       public void method1() throws RemoteException;
       public int method2(double d) throws RemoteException;
   }

                                       public class B
                                                   extends UnicastRemoteObject
                                                   implements R {
                                             public B() throws RemoteException {
                                                   super();
                                             }
                                             public void method1()
                                                   throws RemoteException {
                                                   ...
                                             }
                                             public int method2(double d)
                                                   throws RemoteException {
                                                   ...
...                                          }
...                                          ...
R r;                                   }
...
...                                                                                      rmiregistry &
                                       ...
try {                                  ...
    r.method1();                       try {
} catch (RemoteException e) {              B b = new B();
    ...                                    Naming.rebind(quot;rmi://host:port/namequot;, b);
}                                      } catch (Exception e) {
...                                        ...
...                                    }
m.k(r);                                ...
...                                    ...
...


               Local                   Remote


                                              -9-
Registration (2)
   public interface R extends Remote {
       public void method1() throws RemoteException;
       public int method2(double d) throws RemoteException;
   }

                                       public class B
                                                   extends UnicastRemoteObject
                                                   implements R {
                                             public B() throws RemoteException {
                                                   super();
                                             }
                                             public void method1()
                                                   throws RemoteException {
                                                   ...
                                             }
                                             public int method2(double d)
                                                   throws RemoteException {
                                                   ...
...                                          }
...                                          ...
R r;                                   }
...
...                                 ...
try {                               ...
    r.method1();                    try {
} catch (RemoteException e) {           B b = new B();
    ...                                 Registry rmiR = LocateRegistry.createRegistry(1099);
}                                       rmiR.rebind(quot;rmi://host:port/namequot;, b);
...                                 } catch (Exception e) {
...                                     ...
m.k(r);                             }
...                                 ...
...                                 ...


               Local                   Remote


                                             -10-
Get the stub (1)
    public interface R extends Remote {
        public void method1() throws RemoteException;
        public int method2(double d) throws RemoteException;
    }

                                        public class B
                                                    extends UnicastRemoteObject
                                                    implements R {
                                              public B() throws RemoteException {
                                                    super();
                                              }
                                              public void method1()
                                                    throws RemoteException {
                                                    ...
                                              }
                                              public int method2(double d)
                                                    throws RemoteException {
                                                    ...
...                                           }
...                                           ...
R r;                                    }
try {
    r = (R) (Naming.lookup(                                                               rmiregistry &
                                        ...
        quot;rmi://host:port/namequot;));       ...
    r.method1();                        try {
} catch (Exception e) {                     B b = new B();
    ...                                     Naming.rebind(quot;rmi://host:port/namequot;, b);
}                                       } catch (Exception e) {
...                                         ...
...                                     }
m.k(r);                                 ...
...                                     ...
...


               Local                    Remote


                                              -11-
Get the stub (2)
    public interface R extends Remote {
        public void method1() throws RemoteException;
        public int method2(double d) throws RemoteException;
    }

                                        public class B
                                                    extends UnicastRemoteObject
                                                    implements R {
                                              public B() throws RemoteException {
                                                    super();
                                              }
                                              public void method1()
                                                    throws RemoteException {
                                                    ...
                                              }
                                              public int method2(double d)
                                                    throws RemoteException {
                                                    ...
...                                           }
...                                           ...
R r;                                    }
try {
    Registry rmiR =                  ...
        LocateRegistry.              ...
        getRegistry(1099);           try {
    r = (R) (rmiR.lookup(                B b = new B();
        quot;rmi://host:port/name));         Registry rmiR = LocateRegistry.createRegistry(1099);
    r.method1();                         rmiR.rebind(quot;rmi://host:port/namequot;, b);
} catch (Exception e) {              } catch (Exception e) {
    ...                                  ...
}                                    }
...                                  ...
...                                  ...
m.k(r);
...
...            Local                    Remote


                                              -12-
Generate the Stub
    public interface R extends Remote {
        public void method1() throws RemoteException;
        public int method2(double d) throws RemoteException;
    }

                                        public class B
                                                    extends UnicastRemoteObject
                                                    implements R {
                                              public B() throws RemoteException {
                                                    super();
                             rmic             }
        B_stub.class                          public void method1()
                                                    throws RemoteException {
                                                    ...
                                              }
                                              public int method2(double d)
                                                    throws RemoteException {
                                                    ...
...                                           }
...                                           ...
R r;                                    }
try {
    Registry rmiR =                  ...
        LocateRegistry.              ...
        getRegistry(1099);           try {
    r = (R) (rmiR.lookup(                B b = new B();
        quot;rmi://host:port/name));         Registry rmiR = LocateRegistry.createRegistry(1099);
    r.method1();                         rmiR.rebind(quot;rmi://host:port/namequot;, b);
} catch (Exception e) {              } catch (Exception e) {
    ...                                  ...
}                                    }
...                                  ...
...                                  ...
m.k(r);
...
...            Local                    Remote


                                              -13-
More about this scheme
• The stub takes care of the marshelling of parameters and
  the unmarshelling of returned results, so as the opposite
  side.
• How data is passed around?
   – Primitive data
   – Objects
       • Object serialization
       • Stubs is also objects and can be passed as well.
• Where is the class?




                                    -14-
Issues on RMI
• Create an object remotely?
   – Remote Object Activation
• Garbage collection?
   – Distributed Garbage Collection
• Portings of RMI?
   – various way to substitute the transport layer with others
• Optimization of RMI?
   – lots of researches
   – KaRMI




                                  -15-
Recommanded Readings
• http://java.sun.com/docs/books/tutorial/rmi
  /index.html
• http://developer.java.sun.com/developer/on
  lineTraining/rmi/RMI.html
• http://java.sun.com/j2se/1.4.1/docs/guide/r
  mi/index.html



                      -16-

Contenu connexe

Tendances

GoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google GoGoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google GoEleanor McHugh
 
Dead locks9cm604.39
Dead locks9cm604.39Dead locks9cm604.39
Dead locks9cm604.39myrajendra
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchMatteo Battaglio
 
Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009Jan Wedekind
 
Detecting Occurrences of Refactoring with Heuristic Search
Detecting Occurrences of Refactoring with Heuristic SearchDetecting Occurrences of Refactoring with Heuristic Search
Detecting Occurrences of Refactoring with Heuristic SearchShinpei Hayashi
 
Dependency Breaking Techniques
Dependency Breaking TechniquesDependency Breaking Techniques
Dependency Breaking Techniqueshyun soomyung
 
Learn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentLearn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentMaty Fedak
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09Guy Korland
 
Whats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoWhats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoPaulo Morgado
 
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITEgor Bogatov
 
Dynamic Binary Analysis and Obfuscated Codes
Dynamic Binary Analysis and Obfuscated Codes Dynamic Binary Analysis and Obfuscated Codes
Dynamic Binary Analysis and Obfuscated Codes Jonathan Salwan
 
.NET 2015: Будущее рядом
.NET 2015: Будущее рядом.NET 2015: Будущее рядом
.NET 2015: Будущее рядомAndrey Akinshin
 
Sentence-to-Code Traceability Recovery with Domain Ontologies
Sentence-to-Code Traceability Recovery with Domain OntologiesSentence-to-Code Traceability Recovery with Domain Ontologies
Sentence-to-Code Traceability Recovery with Domain OntologiesShinpei Hayashi
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksJinTaek Seo
 
C++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime NumbersC++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime NumbersAdam Feldscher
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!José Paumard
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9tomaspavelka
 

Tendances (20)

GoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google GoGoLightly: Building VM-Based Language Runtimes with Google Go
GoLightly: Building VM-Based Language Runtimes with Google Go
 
Dead locks9cm604.39
Dead locks9cm604.39Dead locks9cm604.39
Dead locks9cm604.39
 
Objective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central DispatchObjective-C Blocks and Grand Central Dispatch
Objective-C Blocks and Grand Central Dispatch
 
Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009Computer Vision using Ruby and libJIT - RubyConf 2009
Computer Vision using Ruby and libJIT - RubyConf 2009
 
Detecting Occurrences of Refactoring with Heuristic Search
Detecting Occurrences of Refactoring with Heuristic SearchDetecting Occurrences of Refactoring with Heuristic Search
Detecting Occurrences of Refactoring with Heuristic Search
 
Dependency Breaking Techniques
Dependency Breaking TechniquesDependency Breaking Techniques
Dependency Breaking Techniques
 
Learn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentLearn basics of Clojure/script and Reagent
Learn basics of Clojure/script and Reagent
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09
 
分散式系統
分散式系統分散式系統
分散式系統
 
Whats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoWhats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPonto
 
C++11
C++11C++11
C++11
 
Ocl 09
Ocl 09Ocl 09
Ocl 09
 
How to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJITHow to add an optimization for C# to RyuJIT
How to add an optimization for C# to RyuJIT
 
Dynamic Binary Analysis and Obfuscated Codes
Dynamic Binary Analysis and Obfuscated Codes Dynamic Binary Analysis and Obfuscated Codes
Dynamic Binary Analysis and Obfuscated Codes
 
.NET 2015: Будущее рядом
.NET 2015: Будущее рядом.NET 2015: Будущее рядом
.NET 2015: Будущее рядом
 
Sentence-to-Code Traceability Recovery with Domain Ontologies
Sentence-to-Code Traceability Recovery with Domain OntologiesSentence-to-Code Traceability Recovery with Domain Ontologies
Sentence-to-Code Traceability Recovery with Domain Ontologies
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
 
C++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime NumbersC++ & Java JIT Optimizations: Finding Prime Numbers
C++ & Java JIT Optimizations: Finding Prime Numbers
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9
 

Similaire à RMI Fundamentals

Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performanceintelliyole
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsPrincess Sam
 
PROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdfPROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdfezonesolutions
 
RMI Java Programming Lab Manual 2019
RMI Java Programming Lab Manual 2019RMI Java Programming Lab Manual 2019
RMI Java Programming Lab Manual 2019Gebreigziabher Ab
 
Unit3 java
Unit3 javaUnit3 java
Unit3 javamrecedu
 

Similaire à RMI Fundamentals (7)

Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functions
 
PROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdfPROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdf
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 
RMI Java Programming Lab Manual 2019
RMI Java Programming Lab Manual 2019RMI Java Programming Lab Manual 2019
RMI Java Programming Lab Manual 2019
 
F#3.0
F#3.0 F#3.0
F#3.0
 
Unit3 java
Unit3 javaUnit3 java
Unit3 java
 

Plus de elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 

Plus de elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Dernier

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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...Neo4j
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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 productivityPrincipled Technologies
 
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.pdfsudhanshuwaghmare1
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Dernier (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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 Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.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
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

RMI Fundamentals

  • 1. RMI Fundamentals Chung-Kai Chen -1-
  • 2. What is RMI? • Remote Method Invocation • A way to invoke the methods of a object that resides in a remote site. • Similar with RPC, but incorporating OO concepts. -2-
  • 3. The Primary Goal of RMI • The remote objects is used with just the same syntax and semantics as the local objects! • How do we achieve this goal? -3-
  • 4. public class B { public void method1() { ... } public int method2(double d) { ... } ... } ... ... ... b.method1(); ... ... B b = new B(); ... ... m.k(b); ... ... ... Local Remote -4-
  • 5. The tricks • Use a local object serving as an agent to send our requests to the remote object and receive any results. • Such a object is called stub. • There used to be an object called skeleton residing in the remote side to handle the requests, but is no more needed after Java 1.2. -5-
  • 6. Extract the interface public interface R extends Remote { public void method1() throws RemoteException; public int method2(double d) throws RemoteException; } public class B implements R { public void method1() throws RemoteException { ... } public int method2(double d) throws RemoteException { ... ... } ... ... R r; } ... ... ... try { ... r.method1(); } catch (RemoteException e) { B b = new B(); ... ... } ... ... ... m.k(r); ... ... Local Remote -6-
  • 7. Export the service (1) public interface R extends Remote { public void method1() throws RemoteException; public int method2(double d) throws RemoteException; } public class B extends UnicastRemoteObject implements R { public B() throws RemoteException { super(); } public void method1() throws RemoteException { ... } ... public int method2(double d) ... throws RemoteException { R r; ... ... } ... ... try { } r.method1(); } catch (RemoteException e) { ... ... ... } try { ... B b = new B(); ... } catch (RemoteException e) { m.k(r); ... ... } ... ... ... Local Remote -7-
  • 8. Export the service (2) public interface R extends Remote { public void method1() throws RemoteException; public int method2(double d) throws RemoteException; } public class B implements R { public void method1() throws RemoteException { ... } public int method2(double d) throws RemoteException { ... } ... ... ... } R r; ... ... ... try { ... r.method1(); try { } catch (RemoteException e) { B b = new B(); ... UnicastRemoteObject } .exportObject(b); ... } catch (RemoteException e) { ... ... m.k(r); } ... ... ... ... Local Remote -8-
  • 9. Registration (1) public interface R extends Remote { public void method1() throws RemoteException; public int method2(double d) throws RemoteException; } public class B extends UnicastRemoteObject implements R { public B() throws RemoteException { super(); } public void method1() throws RemoteException { ... } public int method2(double d) throws RemoteException { ... ... } ... ... R r; } ... ... rmiregistry & ... try { ... r.method1(); try { } catch (RemoteException e) { B b = new B(); ... Naming.rebind(quot;rmi://host:port/namequot;, b); } } catch (Exception e) { ... ... ... } m.k(r); ... ... ... ... Local Remote -9-
  • 10. Registration (2) public interface R extends Remote { public void method1() throws RemoteException; public int method2(double d) throws RemoteException; } public class B extends UnicastRemoteObject implements R { public B() throws RemoteException { super(); } public void method1() throws RemoteException { ... } public int method2(double d) throws RemoteException { ... ... } ... ... R r; } ... ... ... try { ... r.method1(); try { } catch (RemoteException e) { B b = new B(); ... Registry rmiR = LocateRegistry.createRegistry(1099); } rmiR.rebind(quot;rmi://host:port/namequot;, b); ... } catch (Exception e) { ... ... m.k(r); } ... ... ... ... Local Remote -10-
  • 11. Get the stub (1) public interface R extends Remote { public void method1() throws RemoteException; public int method2(double d) throws RemoteException; } public class B extends UnicastRemoteObject implements R { public B() throws RemoteException { super(); } public void method1() throws RemoteException { ... } public int method2(double d) throws RemoteException { ... ... } ... ... R r; } try { r = (R) (Naming.lookup( rmiregistry & ... quot;rmi://host:port/namequot;)); ... r.method1(); try { } catch (Exception e) { B b = new B(); ... Naming.rebind(quot;rmi://host:port/namequot;, b); } } catch (Exception e) { ... ... ... } m.k(r); ... ... ... ... Local Remote -11-
  • 12. Get the stub (2) public interface R extends Remote { public void method1() throws RemoteException; public int method2(double d) throws RemoteException; } public class B extends UnicastRemoteObject implements R { public B() throws RemoteException { super(); } public void method1() throws RemoteException { ... } public int method2(double d) throws RemoteException { ... ... } ... ... R r; } try { Registry rmiR = ... LocateRegistry. ... getRegistry(1099); try { r = (R) (rmiR.lookup( B b = new B(); quot;rmi://host:port/name)); Registry rmiR = LocateRegistry.createRegistry(1099); r.method1(); rmiR.rebind(quot;rmi://host:port/namequot;, b); } catch (Exception e) { } catch (Exception e) { ... ... } } ... ... ... ... m.k(r); ... ... Local Remote -12-
  • 13. Generate the Stub public interface R extends Remote { public void method1() throws RemoteException; public int method2(double d) throws RemoteException; } public class B extends UnicastRemoteObject implements R { public B() throws RemoteException { super(); rmic } B_stub.class public void method1() throws RemoteException { ... } public int method2(double d) throws RemoteException { ... ... } ... ... R r; } try { Registry rmiR = ... LocateRegistry. ... getRegistry(1099); try { r = (R) (rmiR.lookup( B b = new B(); quot;rmi://host:port/name)); Registry rmiR = LocateRegistry.createRegistry(1099); r.method1(); rmiR.rebind(quot;rmi://host:port/namequot;, b); } catch (Exception e) { } catch (Exception e) { ... ... } } ... ... ... ... m.k(r); ... ... Local Remote -13-
  • 14. More about this scheme • The stub takes care of the marshelling of parameters and the unmarshelling of returned results, so as the opposite side. • How data is passed around? – Primitive data – Objects • Object serialization • Stubs is also objects and can be passed as well. • Where is the class? -14-
  • 15. Issues on RMI • Create an object remotely? – Remote Object Activation • Garbage collection? – Distributed Garbage Collection • Portings of RMI? – various way to substitute the transport layer with others • Optimization of RMI? – lots of researches – KaRMI -15-
  • 16. Recommanded Readings • http://java.sun.com/docs/books/tutorial/rmi /index.html • http://developer.java.sun.com/developer/on lineTraining/rmi/RMI.html • http://java.sun.com/j2se/1.4.1/docs/guide/r mi/index.html -16-