FileDocCategorySizeDatePackage
MyServer.javaAPI DocExample1126Thu Nov 13 14:21:54 GMT 1997None

MyServer.java

import java.rmi.*;
import java.util.*;

public class MyServer 
	extends java.rmi.server.UnicastRemoteObject implements Server {   
 
    public MyServer() throws RemoteException { }


	// Implement the Server interface

    public Date getDate() throws RemoteException {
		return new Date();
	}
    public Object execute( WorkRequest work ) throws RemoteException {
		return work.execute();
	}
    public StringEnumeration getList() throws RemoteException {
		return new StringEnumerator( 
			new String [] { "Foo", "Bar", "Gee" } );
	}
    public void asyncExecute( WorkRequest request , WorkListener listener ) 
		throws java.rmi.RemoteException {

		Object result = request.execute();
System.out.println("async req");
		listener.workCompleted( request, result );
System.out.println("async complete");
	}

    public static void main(String args[]) {
		System.setSecurityManager(new RMISecurityManager());
		try {
			Server server = new MyServer();
			Naming.rebind("NiftyServer", server);
System.out.println("bound");
		} catch (java.io.IOException e) {
			System.out.println("// Problem registering server");
		}
    }
}