SlideShare a Scribd company logo
1 of 4
Download to read offline
w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e
www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace
www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace



                                                   RMI tips and tricks




                                                                                                                           by Achraf SFAXI
                                                                                                                  SUN Certified Professional

            The RMI architects tried to make the use of distributed Java objects similar to using
            local Java objects. While they succeeded, some important differences are listed in the
            table below

                                    Local Object                                 Remote Object

             Object                 A local object is defined by a               A remote object's exported behavior is defined by an
             Definition             Java class.                                  interface that must extend the Remote interface.
             Object         A local object is implemented                        A remote object's behavior is executed by a Java
             Implementation by its Java class.                                   class that implements the remote interface.
             Object Creation A new instance of a local                           A new instance of a remote object is created on the
                             object is created by the new                        host computer with the new operator. A client cannot
                             operator.                                           directly create a new remote object (unless using
                                                                                 Java 2 Remote Object Activation).
             Object Access          A local object is accessed       A remote object is accessed via an object reference
                                    directly via an object reference variable which points to a proxy stub implementation
                                    variable.                        of the remote interface.
             References             In a single JVM, an object                   A quot;remote referencequot; is a pointer to a proxy object (a
                                    reference points directly at an              quot;stubquot;) in the local heap. That stub contains
                                    object in the heap.                          information that allows it to connect to a remote
                                                                                 object, which contains the implementation of the
                                                                                 methods.
             Active                 In a single JVM, an object is     In a distributed environment, remote JVMs may
             References             considered quot;alivequot; if there is at crash, and network connections may be lost. A
                                    least one reference to it.        remote object is considered to have an active remote
                                                                      reference to it if it has been accessed within a certain
                                                                      time period (the lease period). If all remote
                                                                      references have been explicitly dropped, or if all
                                                                      remote references have expired leases, then a
                                                                      remote object is available for distributed garbage
                                                                      collection.
             Finalization           If an object implements the                  If a remote object implements the Unreferenced
                                    final ize() method, it is                    interface, the unreferenced method of that interface
                                    called before an object is                   is called when all remote references have been
                                    reclaimed by the garbage                     dropped.
                                    collector.
             Garbage                When all local references to an              The distributed garbage collector works with the local
             Collection             object have been dropped, an                 garbage collector. If there are no remote references
                                    object becomes a candidate                   and all local references to a remote object have been
                                    for garbage collection.                      dropped, then it becomes a candidate for garbage
                                                                                 collection through the normal means.
             Exceptions             Exceptions are either Runtime                RMI forces programs to deal with any possible
                                    exceptions or Exceptions. The                RemoteException objects that may be thrown. This
                                    Java compiler forces a                       was done to ensure the robustness of distributed
                                    program to handle all                        applications.
                                    Exceptions.


                                                                   Pa ge 1 of 1
w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e
www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace
www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace
w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e
www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace
www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace


            The RMI architecture is based on one important principle: the definition of behavior
            and the implementation of that behavior are separate concepts. RMI allows the code
            that defines the behavior and the code that implements the behavior to remain
            separate and to run on separate JVMs.
            Specifically, in RMI, the definition of a remote service is coded using a Java interface.
            The implementation of the remote service is coded in a class. Therefore, the key to
            understanding RMI is to remember that interfaces define behavior and classes define
            implementation.




            RMI supports two classes that implement the same interface. The first class is the
            implementation of the behavior, and it runs on the server. The second class acts as a
            proxy for the remote service and it runs on the client. This is shown in the following
            diagram.




            The RMI implementation is essentially built from three abstraction layers. The first is
            the Stub and Skeleton layer, which lies just beneath the view of the developer. This
            layer intercepts method calls made by the client to the interface reference variable
            and redirects these calls to a remote RMI service. The next layer is the Remote
            Reference Layer. This layer understands how to interpret and manage references
            made from clients to the remote service objects.
            The transport layer is based on TCP/IP connections between machines in a network.
            It provides basic connectivity, as well as some firewall penetration strategies.




                                                                   Pa ge 2 of 2
w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e
www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace
www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace
w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e
www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace
www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace


            The stub and skeleton layer of RMI lie just beneath the view of the Java developer. In
            this layer, RMI uses the Proxy design pattern. The following class diagram illustrates
            the Proxy pattern.




            In RMI's use of the Proxy pattern, the stub class plays the role of the proxy, and the
            remote service implementation class plays the role of the RealSubject. A skeleton is a
            helper class that is generated for RMI to use. The skeleton understands how to
            communicate with the stub across the RMI link. The skeleton carries on a
            conversation with the stub; it reads the parameters for the method call from the link,
            makes the call to the remote service implementation object, accepts the return value,
            and then writes the return value back to the stub.

            quot;How does a client find an RMI remote service? quot;. Clients find remote services by
            using a naming or directory service. A naming or directory service is run on a well-
            known host and port number.
            RMI can use many different directory services, including the Java Naming and
            Directory Interface (JNDI). RMI itself includes a simple service called the RMI
            Registry, rmiregistry. The RMI Registry runs on each machine that hosts remote
            service objects and accepts queries for services, by default on port 1099.
            On the client side, the RMI Registry is accessed through the static class Naming. It
            provides the method lookup() that a client uses to query a registry. The method
            lookup() accepts a URL that specifies the server host name and the name of the
            desired service. The method returns a remote reference to the service object. The URL
            takes the form:

                                 rmi://<host_name>
                                       [:<name_service_port>]
                                             /<service_name>

            where the host_name is a name recognized on the local area network (LAN) or a
            DNS name on the Internet. The name_service_port only needs to be specified
            only if the naming service is running on a different port to the default 1099 (the JRMP
            port).
            Since the RMI transport layer opens dynamic socket connections between the client
            and the server to facilitate communication, the JRMP traffic is typically blocked by
            most firewall implementations. But luckily, the RMI designers had anticipated this

                                                                   Pa ge 3 of 3
w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e
www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace
www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace
w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e
www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace
www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace


            problem, and a solution is provided by the RMI transport layer itself. To get across
            firewalls, RMI makes use of HTTP tunneling by encapsulating the RMI calls within
            an HTTP POST request.
            One of the joys of programming for the Java platform is not worrying about memory
            allocation. The JVM has an automatic garbage collector that will reclaim the memory
            from any object that has been discarded by the running program.
            Designing an efficient single-machine garbage collector is hard; designing a
            distributed garbage collector is very hard. The RMI system provides a reference
            counting distributed garbage collection algorithm based on Modula-3's Network
            Objects.
            The solution to the mobile computing agent using RMI is, at best, a work-around.
            Other distributed Java architectures have been designed to address this issue and
            others. These are collectively called mobile agent architectures. These systems are
            specifically designed to allow and support the movement of Java objects between
            JVMs, carrying their data along with their execution instructions.




                    If y ou ap p reciate this document make a donation to a
            worl dwide chil dren as s ociation or organiz ation. I sugges t the SOS
            as s ociation. This document has b een downl oaded f rom the
            maghrebspace.blogspot.com b l og ; y ou can us e and b roadcas t it f or
            non l ucrative p urp os es . Further inf ormation are avail ab l e up on
            reques t.

                   Si vous ap p réciez ce document f aites un don p our l e comp te
            d’une as s ociation ou une organis ation qui s ’occup e des enf ants . Je
            vous cons eil l e l ’as s ociation SOS. Ce document es t dis p onib l e s ur
            maghrebspace.blogspot.com ; s on util is ation ains i que s a
            p rop agation p our des f ins non l ucratives s ont gratuites .




                                                                   Pa ge 4 of 4
w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e
www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace
www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace

More Related Content

Viewers also liked

Anthracite Small Final Presentation
Anthracite Small Final PresentationAnthracite Small Final Presentation
Anthracite Small Final Presentation
guest5cb03c
 
Test - Andy Lewis
Test - Andy LewisTest - Andy Lewis
Test - Andy Lewis
andylewis
 
Jardines De Montreal P
Jardines De Montreal PJardines De Montreal P
Jardines De Montreal P
nimiaazucena
 
Taller Rubricas 2007
Taller Rubricas 2007Taller Rubricas 2007
Taller Rubricas 2007
edomingu
 
Anthracite Big Final Presentation
Anthracite Big Final PresentationAnthracite Big Final Presentation
Anthracite Big Final Presentation
guest5cb03c
 

Viewers also liked (20)

Empregado Exemplar
Empregado ExemplarEmpregado Exemplar
Empregado Exemplar
 
Tic Investigacion
Tic InvestigacionTic Investigacion
Tic Investigacion
 
Lesson
LessonLesson
Lesson
 
Anthracite Small Final Presentation
Anthracite Small Final PresentationAnthracite Small Final Presentation
Anthracite Small Final Presentation
 
Conte Carlota
Conte CarlotaConte Carlota
Conte Carlota
 
Chinesenewyear
Chinesenewyear Chinesenewyear
Chinesenewyear
 
Test - Andy Lewis
Test - Andy LewisTest - Andy Lewis
Test - Andy Lewis
 
sabias que
sabias quesabias que
sabias que
 
Elfje
ElfjeElfje
Elfje
 
M M Interactive Applications0708 Assignment A 2
M M Interactive Applications0708  Assignment  A 2M M Interactive Applications0708  Assignment  A 2
M M Interactive Applications0708 Assignment A 2
 
Sabiasque
SabiasqueSabiasque
Sabiasque
 
Serious Game Of Schoolplein 1
Serious Game Of Schoolplein 1Serious Game Of Schoolplein 1
Serious Game Of Schoolplein 1
 
Presentation1
Presentation1Presentation1
Presentation1
 
Analizando mi vida
Analizando mi vidaAnalizando mi vida
Analizando mi vida
 
Jardines De Montreal P
Jardines De Montreal PJardines De Montreal P
Jardines De Montreal P
 
Taller Rubricas 2007
Taller Rubricas 2007Taller Rubricas 2007
Taller Rubricas 2007
 
Fivelittlegrogs
FivelittlegrogsFivelittlegrogs
Fivelittlegrogs
 
Le Carnet Rose
Le Carnet RoseLe Carnet Rose
Le Carnet Rose
 
Anthracite Big Final Presentation
Anthracite Big Final PresentationAnthracite Big Final Presentation
Anthracite Big Final Presentation
 
Concurs de telefonia mòbil
Concurs de telefonia mòbil Concurs de telefonia mòbil
Concurs de telefonia mòbil
 

Similar to My Rmi F

Rmi, corba and java beans
Rmi, corba and java beansRmi, corba and java beans
Rmi, corba and java beans
Raghu nath
 

Similar to My Rmi F (20)

Net remoting
Net remotingNet remoting
Net remoting
 
javarmi
javarmijavarmi
javarmi
 
Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01Javarmi 130925082348-phpapp01
Javarmi 130925082348-phpapp01
 
Java rmi
Java rmiJava rmi
Java rmi
 
Module 3 remote method invocation-2
Module 3   remote method  invocation-2Module 3   remote method  invocation-2
Module 3 remote method invocation-2
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Remote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVARemote Method Innovation (RMI) In JAVA
Remote Method Innovation (RMI) In JAVA
 
Java RMI
Java RMIJava RMI
Java RMI
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
DS R16 - UNIT-3.pdf
DS R16 - UNIT-3.pdfDS R16 - UNIT-3.pdf
DS R16 - UNIT-3.pdf
 
Lec7
Lec7Lec7
Lec7
 
Rmi ppt-2003
Rmi ppt-2003Rmi ppt-2003
Rmi ppt-2003
 
Java GC
Java GCJava GC
Java GC
 
Java rmi tutorial
Java rmi tutorialJava rmi tutorial
Java rmi tutorial
 
#4 (Remote Method Invocation)
#4 (Remote Method Invocation)#4 (Remote Method Invocation)
#4 (Remote Method Invocation)
 
Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)Remote Method Invocation (Java RMI)
Remote Method Invocation (Java RMI)
 
Rmi
RmiRmi
Rmi
 
oop Lecture19
oop Lecture19oop Lecture19
oop Lecture19
 
Remote method invocation
Remote method invocationRemote method invocation
Remote method invocation
 
Rmi, corba and java beans
Rmi, corba and java beansRmi, corba and java beans
Rmi, corba and java beans
 

More from achraf_ing (10)

Ejb - september 2006
Ejb  - september 2006Ejb  - september 2006
Ejb - september 2006
 
Clustering - october 2006
Clustering  - october 2006Clustering  - october 2006
Clustering - october 2006
 
Distributed computing - november 2006
Distributed computing  - november 2006Distributed computing  - november 2006
Distributed computing - november 2006
 
Initiation à Linux - Fundamentals
Initiation à Linux  - FundamentalsInitiation à Linux  - Fundamentals
Initiation à Linux - Fundamentals
 
Apache server configuration & sécurisation -
Apache server configuration & sécurisation  -Apache server configuration & sécurisation  -
Apache server configuration & sécurisation -
 
Ssl et certification electronique - (construction de certification)
Ssl et certification electronique  - (construction de certification)Ssl et certification electronique  - (construction de certification)
Ssl et certification electronique - (construction de certification)
 
Crise financiere
Crise financiereCrise financiere
Crise financiere
 
Stratégie
StratégieStratégie
Stratégie
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summary
 
Internationalization in Java
Internationalization in JavaInternationalization in Java
Internationalization in Java
 

Recently uploaded

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
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
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...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

My Rmi F

  • 1. w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace RMI tips and tricks by Achraf SFAXI SUN Certified Professional The RMI architects tried to make the use of distributed Java objects similar to using local Java objects. While they succeeded, some important differences are listed in the table below Local Object Remote Object Object A local object is defined by a A remote object's exported behavior is defined by an Definition Java class. interface that must extend the Remote interface. Object A local object is implemented A remote object's behavior is executed by a Java Implementation by its Java class. class that implements the remote interface. Object Creation A new instance of a local A new instance of a remote object is created on the object is created by the new host computer with the new operator. A client cannot operator. directly create a new remote object (unless using Java 2 Remote Object Activation). Object Access A local object is accessed A remote object is accessed via an object reference directly via an object reference variable which points to a proxy stub implementation variable. of the remote interface. References In a single JVM, an object A quot;remote referencequot; is a pointer to a proxy object (a reference points directly at an quot;stubquot;) in the local heap. That stub contains object in the heap. information that allows it to connect to a remote object, which contains the implementation of the methods. Active In a single JVM, an object is In a distributed environment, remote JVMs may References considered quot;alivequot; if there is at crash, and network connections may be lost. A least one reference to it. remote object is considered to have an active remote reference to it if it has been accessed within a certain time period (the lease period). If all remote references have been explicitly dropped, or if all remote references have expired leases, then a remote object is available for distributed garbage collection. Finalization If an object implements the If a remote object implements the Unreferenced final ize() method, it is interface, the unreferenced method of that interface called before an object is is called when all remote references have been reclaimed by the garbage dropped. collector. Garbage When all local references to an The distributed garbage collector works with the local Collection object have been dropped, an garbage collector. If there are no remote references object becomes a candidate and all local references to a remote object have been for garbage collection. dropped, then it becomes a candidate for garbage collection through the normal means. Exceptions Exceptions are either Runtime RMI forces programs to deal with any possible exceptions or Exceptions. The RemoteException objects that may be thrown. This Java compiler forces a was done to ensure the robustness of distributed program to handle all applications. Exceptions. Pa ge 1 of 1 w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace
  • 2. w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace The RMI architecture is based on one important principle: the definition of behavior and the implementation of that behavior are separate concepts. RMI allows the code that defines the behavior and the code that implements the behavior to remain separate and to run on separate JVMs. Specifically, in RMI, the definition of a remote service is coded using a Java interface. The implementation of the remote service is coded in a class. Therefore, the key to understanding RMI is to remember that interfaces define behavior and classes define implementation. RMI supports two classes that implement the same interface. The first class is the implementation of the behavior, and it runs on the server. The second class acts as a proxy for the remote service and it runs on the client. This is shown in the following diagram. The RMI implementation is essentially built from three abstraction layers. The first is the Stub and Skeleton layer, which lies just beneath the view of the developer. This layer intercepts method calls made by the client to the interface reference variable and redirects these calls to a remote RMI service. The next layer is the Remote Reference Layer. This layer understands how to interpret and manage references made from clients to the remote service objects. The transport layer is based on TCP/IP connections between machines in a network. It provides basic connectivity, as well as some firewall penetration strategies. Pa ge 2 of 2 w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace
  • 3. w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace The stub and skeleton layer of RMI lie just beneath the view of the Java developer. In this layer, RMI uses the Proxy design pattern. The following class diagram illustrates the Proxy pattern. In RMI's use of the Proxy pattern, the stub class plays the role of the proxy, and the remote service implementation class plays the role of the RealSubject. A skeleton is a helper class that is generated for RMI to use. The skeleton understands how to communicate with the stub across the RMI link. The skeleton carries on a conversation with the stub; it reads the parameters for the method call from the link, makes the call to the remote service implementation object, accepts the return value, and then writes the return value back to the stub. quot;How does a client find an RMI remote service? quot;. Clients find remote services by using a naming or directory service. A naming or directory service is run on a well- known host and port number. RMI can use many different directory services, including the Java Naming and Directory Interface (JNDI). RMI itself includes a simple service called the RMI Registry, rmiregistry. The RMI Registry runs on each machine that hosts remote service objects and accepts queries for services, by default on port 1099. On the client side, the RMI Registry is accessed through the static class Naming. It provides the method lookup() that a client uses to query a registry. The method lookup() accepts a URL that specifies the server host name and the name of the desired service. The method returns a remote reference to the service object. The URL takes the form: rmi://<host_name> [:<name_service_port>] /<service_name> where the host_name is a name recognized on the local area network (LAN) or a DNS name on the Internet. The name_service_port only needs to be specified only if the naming service is running on a different port to the default 1099 (the JRMP port). Since the RMI transport layer opens dynamic socket connections between the client and the server to facilitate communication, the JRMP traffic is typically blocked by most firewall implementations. But luckily, the RMI designers had anticipated this Pa ge 3 of 3 w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace
  • 4. w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace problem, and a solution is provided by the RMI transport layer itself. To get across firewalls, RMI makes use of HTTP tunneling by encapsulating the RMI calls within an HTTP POST request. One of the joys of programming for the Java platform is not worrying about memory allocation. The JVM has an automatic garbage collector that will reclaim the memory from any object that has been discarded by the running program. Designing an efficient single-machine garbage collector is hard; designing a distributed garbage collector is very hard. The RMI system provides a reference counting distributed garbage collection algorithm based on Modula-3's Network Objects. The solution to the mobile computing agent using RMI is, at best, a work-around. Other distributed Java architectures have been designed to address this issue and others. These are collectively called mobile agent architectures. These systems are specifically designed to allow and support the movement of Java objects between JVMs, carrying their data along with their execution instructions. If y ou ap p reciate this document make a donation to a worl dwide chil dren as s ociation or organiz ation. I sugges t the SOS as s ociation. This document has b een downl oaded f rom the maghrebspace.blogspot.com b l og ; y ou can us e and b roadcas t it f or non l ucrative p urp os es . Further inf ormation are avail ab l e up on reques t. Si vous ap p réciez ce document f aites un don p our l e comp te d’une as s ociation ou une organis ation qui s ’occup e des enf ants . Je vous cons eil l e l ’as s ociation SOS. Ce document es t dis p onib l e s ur maghrebspace.blogspot.com ; s on util is ation ains i que s a p rop agation p our des f ins non l ucratives s ont gratuites . Pa ge 4 of 4 w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e ...b llo g s p o tt...c o m w w w ...m a g h rre b s p a c e www maghrebspace blogspot com www maghrebspace blogspot com www maghrebspace www magh ebspace b ogspo com www magh ebspace b ogspo com www magh ebspace