Java RMI - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Java RMI

Description:

Host titi.epfl.ch. network. Object. Client. Remote. Object. Server ... titi.epfl.ch/LGLBank'); Parameters and Return Values. Remote objects by reference ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 18
Provided by: DIL5
Category:
Tags: rmi | java | titi

less

Transcript and Presenter's Notes

Title: Java RMI


1
Java RMI
  • Stanislav Chachkov
  • LGL-EPFL

2
What is RMI?
  • RMI enables the programmer to create distributed
    Java applications, in which the methods of remote
    Java objects can be invoked from other Java
    virtual machines, possibly on different hosts.
  • A Java program can make a call on a remote object
    once it obtains a reference to the remote object,
    either by looking up the remote object in the
    naming service provided by RMI or by receiving
    the reference as an argument or a return value. A
    client can call a remote object in a server, and
    that server can also be a client of other remote
    objects.
  • RMI uses object serialization to marshal and
    unmarshal parameters.

3
What is RMI?
  • Remote Method Invocation

network
Object Client
Remote Object Server
method invocation
Host tata.epfl.ch
Host titi.epfl.ch
4
NetBank example
Client
Bank Office
BankMgr
Account
Host ecub.ubs.ch
Host serv.ubs.ch
5
Creating a Remote object
interface java.rmi.Remote
java.rmi.server. UnicastRemoteObject
bank.BankMgrImpl
interface bank.BankMgr
createClient() createAccount(Client)
bank.BankMgrImpl_Stub
6
Remote Reference
  • Encapsulates network communication
  • Same interface as Remote object

Object Client
Remote Object Stub
Remote Object
RMI Runtime
01101
f()
f()
true
10010
true
Host tata.epfl.ch
Host titi.epfl.ch
7
Naming Service
  • Directory that associates names to remote objects
    (bind)

Remote Object A
Naming
Remote Object C
X
Y
Remote Object B
Z
Host titi.epfl.ch
8
Naming Service
  • Client use Naming Service to find a particular
    Server object (lookup)

Naming
Object Client
Remote Object Server
X
lookup(Y)
Y
Remote ref. to Server
Z
tata.epfl.ch
Host titi.epfl.ch
9
Creating Remote object
  • Create an interface
  • Create the implementation
  • Compile
  • Create the Stub

10
Interface
  • public interface BankMgr extends Remote
  • public createAccount(Client c)
  • throws RemoteException
  • public createClient(String name)
  • throws RemoteException

11
Implementation class
  • public class BankMgrImpl
  • extends UnicastRemoteObject
  • implements BankMgr
  • public BankMgrImpl()
  • throws RemoteExceptionsuper()
  • public createClient(String a) code
  • public createAccount(Client b) code

12
Stub
  • In JBuilder use JNI/RMI tab in class properties
    to generate it automatically
  • By hand use rmic tool
  • rmic bank.BankMgrImpl

13
Binding (server side)
  • Binding means register the object in local
    Naming service
  • Naming.rebind(
  • LGLBank,
  • new BankMgrImpl())

14
Locating (client side)
  • Lookup operation return the reference (stub) on a
    remote object
  • BankMgr bank
  • (BankMgr)Naming.lookup(
  • //titi.epfl.ch/LGLBank)

15
Parameters and Return Values
  • Remote objects by reference
  • Serializable objects - by copy
  • Others cannot be passed (exception)

16
Deployment
  • On the server host
  • Launch Naming service
  • rmiregistry
  • Launch Server program
  • java bank.BankMgr
  • On the client host(s)
  • Launch the client program

17
References
  • Java Tutorial on RMI
  • http//java.sun.com/j2se/1.4/docs/guide/rmi
  • Book on RMI
  • William Grosso Java RMI, OReilly
Write a Comment
User Comments (0)
About PowerShow.com