What does RMI do for you?

Download Report

Transcript What does RMI do for you?

RMI
Russell Johnston
Communications II
1
What is RMI?

Remote Method Invocation
2
Overview







Why use RMI?
What does RMI do for you?
What else can RMI do for you?
How does RMI compare to RPC?
How does RMI work?
How do you implement RMI?
Applications of RMI
3
Why use RMI?



RMI makes IPC and Client/Server
programming simpler
RMI makes distributed and parallel
computing simpler
Platform independence
4
What does RMI do for
you?




Data marshalling and external
representation
Transparent parameter passing
When combined with JNDI, true
location transparency
When combined with CORBA,
language independence and
connectivity to legacy systems
5
What else can RMI do
for you?



Distributed garbage collection
Security (authentication support)
Activation (transparent object disk
swapping / memory paging)
6
How does RMI compare
to RPC?







Object oriented vs. procedure
oriented
Registry vs. portmapper
URL vs. program number
Rmic vs. rpcgen
Interface class vs. *.x file
Serialization vs. XDR
CORBA vs. Versioning
7
How does RMI work?



Architecture
Data marshalling and external
representation
Transparent parameter passing
8
Architecture





Client (interface)
Stub
Network
Skeleton
Remote object
9
Data marshalling and
external representation

Object serialization



Primitive data types are automatically
serializable
Objects implement java.lang.Serializable
Transient





Size
Resources that need to be reconstructed
Insecure data
Recursion
Java data representation is portable by
design
10
RMI Transparent
Parameter Passing


Copy-by-value (serialization)
Copy-by-reference (reference to
another remote object)
11
How do you implement
RMI?


Create an interface which extends
java.rmi.Remote. Every method in
the interface must throw
java.rmi.RemoteException
Create the remote object which
implements the interface and
extends
java.rmi.server.UnicastRemoteObj
ect
12
Implementation (cont.)



Generate the stub and skeleton via
rmic.
Create the server which will bind
the RMI service the registry
Create the client which will get the
remote object via Naming.lookup()
and manipulate the remote object
via the interface
13
Implementation (cont.)

Run
Start the registry via rmiregistry
 Start the server
 Start the client

14
Applications of RMI

EJB
EJB Object
 Home Object


Parallel distributed GA
15