RMI

5,456 views

Published on

RMI-REMOTE METHOD INVOCATION

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,456
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
311
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

RMI

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

×