public void exit(ConnectorInstanceContext oldContext) throws ResourceException { ConnectorInstanceContext currentContext = currentInstanceContexts.get(); try { // for each connection type opened in this componet Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> resources = currentContext.getConnectionManagerMap(); for (Iterator<Map.Entry<ConnectionTrackingInterceptor, Set<ConnectionInfo>>> iterator = resources.entrySet().iterator(); iterator.hasNext();) { Map.Entry<ConnectionTrackingInterceptor, Set<ConnectionInfo>> entry = iterator.next(); ConnectionTrackingInterceptor mcci = entry.getKey(); Set<ConnectionInfo> connections = entry.getValue(); // release proxy connections if (lazyConnect) { for (ConnectionInfo connectionInfo : connections) { releaseProxyConnection(connectionInfo); } } // use connection interceptor to dissociate connections that support disassociation mcci.exit(connections); // if no connection remain clear context... we could support automatic commit, rollback or exception here if (connections.isEmpty()) { iterator.remove(); } } } finally { // when lazy we do not need or want to track open connections... they will automatically reconnect if (lazyConnect) { currentContext.getConnectionManagerMap().clear(); } currentInstanceContexts.set(oldContext); } }