/* Richard A. DeVenezia * SUGI 29 - "Greetings from the Edge" * www.devenezia.com/papers */ import java.rmi.registry.LocateRegistry; import java.rmi.*; public class HashServer { protected static final String RMI_NAME = "PERSISTENT-HASH-MANAGER"; private String exceptionMessage; // This method is run when class is run as stand-alone java application, // from whence comes run-time persistence public static void main(String args[]){ // sets security according to file named in environment variable java.security.policy System.setSecurityManager(new RMISecurityManager()); try{ // 1099 is the default port for RMI // This method removes the need to also run "rmiregistry" as stand-alone process prior // to starting this class as a stand-alone process LocateRegistry.createRegistry(1099); // Instantiate the implementation of the interface that will persist as long as this server runs Integer n = Integer.getInteger("number.of.hashes", 5); HashManager manager = new HashManager (n.intValue()); // Give this process the name that localhost clients use with Naming.lookup() Naming.rebind (RMI_NAME, manager); System.out.println(manager.getClass().getName() + " ready to manage " + n + " hashes."); } catch(Exception e) { System.out.println("Error: " + e); } } //--------------------------------------------------------------------------- public static HashInterface getReferenceToPersistentManager () { int numberOfTimesToWait = 4; long durationToWaitInMillis = 250; Remote remote = null; try { for (int i = 0; (i