Java RMI
Summary
Java History
Invented by James Gosling at Sun
Originally called Oak
Originally used for PDAs then to set-top boxes, then to the internet
Java Distributed Object Model
- Remote Object
- Accessible from different address spaces
- Remote Interface
- Declarations for methods in a remote object
- Failure Semantics
- Clients deal with RMI exceptions
- Similarities/differences to local objects
- Object references can be params
- Param only as value/result
Bank Account Example
- Server API:
- Deposit
- Withdraw
- Balance
Reuse of Local Implementation
Interfaces are available everywhere, but specific instantiations (objects) may not be. It’s up to the implementer.
Reuse of Remote
More work on programmer in terms of extensions/implementations, but objects are immediately visible.
Java RMI at work
Server
BankAccount acct = new BankAcctImpl();
URL url = new URL("mywebaddress");
Java.rmi.Naming.bind(url, acct);
Client
BankAccount acct = Java.rmi.Naming.lookup(url);
float balance;
acct.deposit(5);
acct.withdraw(3);
balance = acct.balance();
RMI Implementation
RRL handles ser/des
- Similar to subcontract
RMI Implementation Transport
Endpoints
contain transports
which connect to other transports via
channels
.
- Endpoint
- Protection Domain
- JVM
- Table of Remote Objects
- Protection Domain
- Connection Management
- Setup, Teardown, Listen for connections
- Liveness monitoring
- Choice of transport
- TCP/UDPA
IO on channel using connections
RRL decides which transport to use depending on location of client/server