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