public void clear() { initialized = false; initialContext = null; jndiProperties.clear(); perDataSourceICMap.clear(); cachedNameList.clear(); for (int port : cachedPorts) { RMIRegistryController.getInstance().removeLocalRegistry(port); } cachedPorts.clear(); }
private static String toKey(int port) { assertPositive(port); return String.valueOf(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); } }
/** * removes if there is a RMI local registry instance * * @param port The port of the RMI registry to be removed */ public void removeLocalRegistry(int port) { String key = toKey(port); synchronized (registriesCache) { if (registriesCache.containsKey(key)) { removeRegistry(key, registriesCache.get(key)); } else { if (log.isDebugEnabled()) { log.debug("There is no RMi registry for port : " + port); } } } }
RMIRegistryController.getInstance().createLocalRegistry(port); cachedPorts.add(port); providerUrl = "rmi://" + providerHost + ":" + port;
/** * {@inheritDoc} */ public void destroy() { try { // only if we have created the server if (serverConfigurationInformation.isCreateNewInstance()) { // destroy listener manager if (listenerManager != null) { listenerManager.destroy(); } stopJmxAdapter(); RMIRegistryController.getInstance().shutDown(); // we need to call this method to clean the temp files we created. if (configurationContext != null) { configurationContext.terminate(); } } initialized = false; } catch (Exception e) { log.error("Error stopping the Axis2 Based Server Environment", e); } }
private static void assertPositive(int port) { if (port < 0) { handleException("Invalid port number : " + port); } }
/** * Removes all registered RMI registries */ public void shutDown() { synchronized (registriesCache) { Collection<String> registryKeys = new ArrayList<String>(registriesCache.size()); registryKeys.addAll(registriesCache.keySet()); for (String key : registryKeys) { removeRegistry(key, registriesCache.get(key)); } } }
RMIRegistryController.getInstance().createLocalRegistry(port); cachedPorts.add(port); providerUrl = "rmi://" + providerHost + ":" + port;
/** * {@inheritDoc} */ public void destroy() { try { // only if we have created the server if (serverConfigurationInformation.isCreateNewInstance()) { // destroy listener manager if (listenerManager != null) { listenerManager.destroy(); } stopJmxAdapter(); RMIRegistryController.getInstance().shutDown(); if (snmpAgent != null) { snmpAgent.stop(); } // we need to call this method to clean the temp files we created. if (configurationContext != null) { configurationContext.terminate(); } } initialized = false; } catch (Exception e) { log.error("Error stopping the Axis2 Based Server Environment", e); } }
/** * removes if there is a RMI local registry instance * * @param port The port of the RMI registry to be removed */ public void removeLocalRegistry(int port) { String key = toKey(port); synchronized (registriesCache) { if (registriesCache.containsKey(key)) { removeRegistry(key, registriesCache.get(key)); } else { if (log.isDebugEnabled()) { log.debug("There is no RMi registry for port : " + port); } } } }
private static void assertPositive(int port) { if (port < 0) { handleException("Invalid port number : " + port); } }
/** * Removes all registered RMI registries */ public void shutDown() { synchronized (registriesCache) { Collection<String> registryKeys = new ArrayList<String>(registriesCache.size()); registryKeys.addAll(registriesCache.keySet()); for (String key : registryKeys) { removeRegistry(key, registriesCache.get(key)); } } }
public void clear() { initialized = false; initialContext = null; jndiProperties.clear(); perDataSourceICMap.clear(); cachedNameList.clear(); for (int port : cachedPorts) { RMIRegistryController.getInstance().removeLocalRegistry(port); } cachedPorts.clear(); }
for (int retries = 0; !registryCreated && (retries < 100); retries++) { try { RMIRegistryController.getInstance().createLocalRegistry(jndiPort); registryCreated = true; } catch (Exception ignored) { RMIRegistryController.getInstance().createLocalRegistry(jndiPort); registryCreated = true;
/** * 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); } } } }
private static String toKey(int port) { assertPositive(port); return String.valueOf(port); }
/** * Stops the JMX connector server. */ public void stop() { if (connectorServer != null) { log.info("JMXConnectorServer stopping on " + jmxInformation.getJmxUrl()); try { connectorServer.stop(); RMIRegistryController.getInstance().removeLocalRegistry(jmxInformation.getJndiPort()); jmxInformation = null; } catch (IOException ex) { log.error("Error while stopping remote JMX connector", ex); } connectorServer = null; } }
for (int retries = 0; !registryCreated && (retries < 100); retries++) { try { RMIRegistryController.getInstance().createLocalRegistry(jndiPort); registryCreated = true; } catch (Exception ignored) { RMIRegistryController.getInstance().createLocalRegistry(jndiPort); registryCreated = true;