// Implementation class for remote sorting (RMI). This includes the remote sort method // and a main()... import java.net.*; // need this for MalformedURLException import java.rmi.server.UnicastRemoteObject; import java.rmi.*; import java.util.*; // The interface must extend the Remote interface to become something // that RMI can serve up. public class RemoteSortImpl extends UnicastRemoteObject implements RemoteSort { // constructor just calls the UnicastRemoteObject constructor that // exports this object as a remote object public RemoteSortImpl() throws RemoteException { super(); } // here is the actual sort - wow... public List sort(List l) throws RemoteException { Collections.sort(l); return(l); } public static void main(String args[]) { try { RemoteSortImpl s = new RemoteSortImpl(); // register with the rmi registry Naming.rebind("sort",s); System.out.println("Sort is ready for trouble..."); } catch (RemoteException e) { System.out.println("RemoteException: " + e.getMessage()); e.printStackTrace(); } catch (MalformedURLException m) { System.out.println("URL Problem: " + m.getMessage()); m.printStackTrace(); } } }