/** * Releases any managed connections held by a garbage collected connection proxy. * @param connectionInfo the connection to be obtained * @param key the unique id of the connection manager */ public void setEnvironment(ConnectionInfo connectionInfo, String key) { ProxyPhantomReference reference = (ProxyPhantomReference) referenceQueue.poll(); while (reference != null) { reference.clear(); references.remove(reference.managedConnectionInfo); ConnectionInfo released = new ConnectionInfo(reference.managedConnectionInfo); reference.interceptor.returnConnection(released, ConnectionReturnAction.DESTROY); reference = (ProxyPhantomReference) referenceQueue.poll(); } }
/** * Releases any managed connections held by a garbage collected connection proxy. * * @param connectionInfo the connection to be obtained * @param key the unique id of the connection manager */ public void setEnvironment(final ConnectionInfo connectionInfo, final String key) { ProxyPhantomReference reference = (ProxyPhantomReference) referenceQueue.poll(); while (reference != null) { reference.clear(); references.remove(reference.managedConnectionInfo); final ConnectionInfo released = new ConnectionInfo(reference.managedConnectionInfo); reference.interceptor.returnConnection(released, ConnectionReturnAction.DESTROY); reference = (ProxyPhantomReference) referenceQueue.poll(); } }
/** * Releases any managed connections held by a garbage collected connection proxy. * * @param connectionInfo the connection to be obtained * @param key the unique id of the connection manager */ public void setEnvironment(final ConnectionInfo connectionInfo, final String key) { ProxyPhantomReference reference = (ProxyPhantomReference) referenceQueue.poll(); while (reference != null) { reference.clear(); references.remove(reference.managedConnectionInfo); final ConnectionInfo released = new ConnectionInfo(reference.managedConnectionInfo); reference.interceptor.returnConnection(released, ConnectionReturnAction.DESTROY); reference = (ProxyPhantomReference) referenceQueue.poll(); } }
public void exit(Collection<ConnectionInfo> connectionInfos) throws ResourceException { for (Iterator<ConnectionInfo> iterator = connectionInfos.iterator(); iterator.hasNext();) { ConnectionInfo connectionInfo = iterator.next(); if (connectionInfo.isUnshareable()) { //if one is, they all are return; } ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo(); ManagedConnection managedConnection = managedConnectionInfo.getManagedConnection(); if (managedConnection instanceof DissociatableManagedConnection && managedConnectionInfo.isFirstConnectionInfo(connectionInfo)) { iterator.remove(); ((DissociatableManagedConnection) managedConnection).dissociateConnections(); managedConnectionInfo.clearConnectionHandles(); //todo this needs some kind of check so cx isn't returned more than once //in case dissociate calls connection closed event and returns cx to pool. returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE); } } }