/** * cleanUpResources(String) : Cleans the resources and remove connection from {@link * ConnectionPool} * * @param connName : The connection for which clean-up will be done. * @return Returns true in case success else returs false */ public static boolean cleanUpResources(String connName, boolean reconnectFlag) { ConcurrentHashMap<String, ServerContainer> ATMSWITCH_CONN_MAP = ConnectionPool.getConnectionMap(); ServerContainer containerHandler = ATMSWITCH_CONN_MAP.get(connName); try { if (containerHandler != null) { containerHandler.cleanResource(reconnectFlag); } else { logger.error( "( " + connName + " ,cleanUpResources(,) ) No Processor found for this message...."); return false; } ConnectionPool.removeConnection(connName); return true; } catch (Exception e) { logger.error(" ( " + connName + " ,cleanUpResources() ) Exception ", e); if (containerHandler != null) containerHandler.closeResource(); return false; } finally { containerHandler = null; } }
/** Closing all the connections one by one from the connection Map */ public static void closeConnections() { StringBuffer strBuf = new StringBuffer(); logger.warn("ATM Switch Interface Shutting Down...."); try { ConcurrentHashMap<String, ServerContainer> ATMSWITCH_CONN_MAP = ConnectionPool.getConnectionMap(); Set connSet = ATMSWITCH_CONN_MAP.keySet(); Iterator It = connSet.iterator(); while (It.hasNext()) { String connName = (String) (It.next()); if (ConnectionPool.getHandleToContainer(connName) != null) { if (cleanUpResources(connName, false)) strBuf.append(connName + " is - Closed. "); else strBuf.append(connName + " could not be - Closed. "); } } } catch (Exception e) { logger.error(" closeConnections() Exception ", e); } logger.info(strBuf.toString()); }