public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { if (connectionReturnAction == ConnectionReturnAction.DESTROY || connectionInfo.isUnshareable() || !connectionInfo.getManagedConnectionInfo().hasConnectionHandles()) { if (connections.get() == connectionInfo.getManagedConnectionInfo()) { connections.remove(); } next.returnConnection(connectionInfo, connectionReturnAction); } }
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); } } }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { if (connectionInfo.isUnshareable()) { next.getConnection(connectionInfo); return; } ManagedConnectionInfo managedConnectionInfo = connections.get(); if (managedConnectionInfo != null) { if (matchConnections) { ManagedConnectionInfo mciRequest = connectionInfo.getManagedConnectionInfo(); if (null != managedConnectionInfo.getManagedConnectionFactory().matchManagedConnections( Collections.singleton(managedConnectionInfo.getManagedConnection()), mciRequest.getSubject(), mciRequest.getConnectionRequestInfo() )) { connectionInfo.setManagedConnectionInfo(managedConnectionInfo); return; } else { //match failed, get a new cx after returning this one connections.set(null); next.returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE); } } else { connectionInfo.setManagedConnectionInfo(managedConnectionInfo); return; } } //nothing for this thread or match failed next.getConnection(connectionInfo); connections.set(connectionInfo.getManagedConnectionInfo()); }
if (transaction != null) { ManagedConnectionInfos managedConnectionInfos = ConnectorTransactionContext.get(transaction, this); if (connectionInfo.isUnshareable()) { if (!managedConnectionInfos.containsUnshared(connectionInfo.getManagedConnectionInfo())) { next.getConnection(connectionInfo);
Subject oldSubject = originalManagedConnectionInfo.getSubject(); if (currentSubject == null ? oldSubject != null : !currentSubject.equals(oldSubject)) { if (connectionInfo.isUnshareable()) { throw new ApplicationServerInternalException("Unshareable resource is attempting to change security context: expected request under: " + oldSubject + ", received request under: " + currentSubject); } else {