SlideShare uma empresa Scribd logo
1 de 16
Baixar para ler offline
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-

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais 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
 

Mais 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
 

Último

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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 DevelopmentsTrustArc
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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 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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
🐬 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
 
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 2024The Digital Insurer
 
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
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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 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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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?
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
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
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

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-