import java.rmi.registry.LocateRegistry; import java.rmi.*; public class GatewayServer { protected static final String RMI_NAME = "JDBC-GATEWAY-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 int nCon = 5; GatewayManager manager = new GatewayManager (nCon); // 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 " + nCon + " connections."); } catch(Exception e) { System.out.println("Error: " + e); } } //--------------------------------------------------------------------------- public static GatewayInterface getReferenceToPersistentManager () { int numberOfTimesToWait = 4; long durationToWaitInMillis = 250; Remote remote = null; try { for (int i = 0; (i