import java.rmi.*;
public class MyClient
extends java.rmi.server.UnicastRemoteObject implements WorkListener {
public static void main(String [] args) throws RemoteException {
System.setSecurityManager(new RMISecurityManager());
new MyClient( args[0] );
}
public MyClient(String host) throws RemoteException {
try {
Server server = (Server)Naming.lookup("//"+host+"/NiftyServer");
System.out.println( server.getDate() );
System.out.println( server.execute( new MyCalculation(2) ) );
StringEnumeration se = server.getList();
while ( se.hasMoreItems() )
System.out.println( se.nextItem() );
server.asyncExecute( new MyCalculation(100), this );
} catch (java.io.IOException e) {
// I/O Error or bad URL
System.out.println(e);
} catch (NotBoundException e) {
// NiftyServer isn't registered
System.out.println(e);
}
}
public void workCompleted( WorkRequest request, Object result ) throws RemoteException {
System.out.println("Async work result = " + result);
System.out.flush();
}
}
|