Beruflich Dokumente
Kultur Dokumente
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
1
OOP is Inherently Distributable
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
2
Key Issues that come up…
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
3
JAVA Security Policies
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
4
The RMI Registry
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
5
The Steps to RMI Outlined:
Client Server
(3) RMI call to the server to run a method
Interface
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
6
RMI – Defining the interfaces
import java.rmi.*
}
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
}
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
7
Implementing a Server’s main
public static void main(String [] args) {
try {
Server theServer = new ServerImpl(); // POLYMORPHISM
Naming.rebind(rmiName, theServer);
System.out.println(“bound as " + rmiName);
} catch (Exception e) {
System.out.println("Error binding as " + rmiName);
System.out.println(e);
}
}
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
}
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
8
Compiling/Running a RMI program
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
9
Forte/NetBeans will automatically…
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
10
RMI Template - The Result
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
Call by what?
11
Normal Method Invocation
public class whatever {
JVM public void callMe(Object A) {
A.doSomeOtherStuff();
}
The actual public static void main(…) {
memory Object myObject = new Object();
contents of myObject.doStuff();
myObject callMe(myObject);
}
}
A myObject
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
Client Server
(1) Client calls
theServer.doSomething(myObject)
myObject
myObject
(2) Serialized myObject data is transferred clone
(3) Serialized
myObject data
is then used to
construct a clone
of myObject
12
Passing References in RMI
Asynchronous Communication
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
13
The RMI Callback Picture
14
RMI Callback Framework: Client
public interface Callback {
public recvMessage(String theMessage) throws RemoteException;
}
In Summary
l RMI is …
– an extension of sockets that is easier to use
– a way to make JAVA objects network accessible
– based on client/server networking principles
l RMI overhead includes …
– security policy setup
– setting up the RMI registry
– creating interfaces, compiling stubs and skeletons
– special framework if asynchronous communication
between server and client is desired
Copyright 1999-2002 Simon Lok Reproduction and/or redistribution in whole or part without written authorization is expressively prohibited
15