Java Reference
In-Depth Information
public Client( int path[], String address, String name,
String serverURL)
throws java.rmi.RemoteException {
super (address, name);
try {
// gets a reference to the remote server and
// starts an Animator service
server # (ServerInterface) Naming.lookup(serverURL);
startActivity( new Animator( this , path));
} catch (Exception e) { e.printStackTrace(); }
public interface AnimatorInterface extends java.rmi.Remote {}
public class Animator extends DActivity
implements AnimatorInterface {
private PathFrame pathFrame # new PathFrame( this );
// the GUI
private ServerInterface server;
// reference to the remote server
private RunnerInterface runner;
// reference to the remote service
private String runnerURL # null ;
// URL of the remote service
private int path[];
// runner's sequence of lay-bys
private long refresh # 100;
// refresh interval in milliseconds
public Animator(Client c, int path[])
throws java.rmi.RemoteException{
super (c);
this .path # path;
// this method requests the remote server to start a
// "runner" service; it gets the service's URL which is
// used to create a reference to the remote service
public void init() {
try {
runnerURL # ((Client) process).server.startRunner(path);
runner # (RunnerInterface) Naming.lookup(runnerURL);
} catch (Exception e) { e.printStackTrace(); }
// this is invoked by the run() method of class DActivity
// repeatedly; every "refresh" milliseconds it gets the
// runner's current position from the remote service
// "runner" and displays it in the graphical interface.
Search WWH ::

Custom Search