private static void assertPositive(int port) { if (port < 0) { handleException("Invalid port number : " + port); } }
private static void assertPositive(int port) { if (port < 0) { handleException("Invalid port number : " + port); } }
/** * Creates a RMI local registry with given port * * @param port The port of the RMI registry to be created */ public void createLocalRegistry(int port) { try { String key = toKey(port); synchronized (registriesCache) { if (registriesCache.containsKey(key)) { if (log.isDebugEnabled()) { log.debug("There is an RMI registry bound to given port :" + port); } return; } Registry locateRegistry = LocateRegistry.createRegistry(port); if (locateRegistry == null) { handleException("Unable to create a RMI registry with port : " + port); } registriesCache.put(key, locateRegistry); } } catch (RemoteException e) { String msg = "Couldn't create a local registry(RMI) : port " + port + " already in use."; handleException(msg, e); } }
/** * Creates a RMI local registry with given port * * @param port The port of the RMI registry to be created */ public void createLocalRegistry(int port) { try { String key = toKey(port); synchronized (registriesCache) { if (registriesCache.containsKey(key)) { if (log.isDebugEnabled()) { log.debug("There is an RMI registry bound to given port :" + port); } return; } Registry locateRegistry = LocateRegistry.createRegistry(port); if (locateRegistry == null) { handleException("Unable to create a RMI registry with port : " + port); } registriesCache.put(key, locateRegistry); } } catch (RemoteException e) { String msg = "Couldn't create a local registry(RMI) : port " + port + " already in use."; handleException(msg, e); } }
/** * Helper method to remove a RMI registry instance * * @param key The port of the RMI registry to be removed * @param registry Registry instance */ private void removeRegistry(String key, Registry registry) { if (registry != null) { synchronized (registriesCache) { try { log.info("Removing the RMI registry bound to port : " + key); UnicastRemoteObject.unexportObject(registry, true); registriesCache.remove(key); } catch (NoSuchObjectException e) { String msg = "Error when stopping local registry(RMI)"; handleException(msg, e); } } } }
/** * Helper method to remove a RMI registry instance * * @param key The port of the RMI registry to be removed * @param registry Registry instance */ private void removeRegistry(String key, Registry registry) { if (registry != null) { synchronized (registriesCache) { try { log.info("Removing the RMI registry bound to port : " + key); UnicastRemoteObject.unexportObject(registry, true); registriesCache.remove(key); } catch (NoSuchObjectException e) { String msg = "Error when stopping local registry(RMI)"; handleException(msg, e); } } } }