in geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java [64:111]
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
//There can be an inactive transaction context when a connection is requested in
//Synchronization.afterCompletion().
// get the current transaction and status... if there is a problem just assume there is no transaction present
Transaction transaction = TxUtil.getTransactionIfActive(transactionManager);
if (transaction != null) {
ManagedConnectionInfos managedConnectionInfos = ConnectorTransactionContext.get(transaction, this);
if (connectionInfo.isUnshareable()) {
if (!managedConnectionInfos.containsUnshared(connectionInfo.getManagedConnectionInfo())) {
next.getConnection(connectionInfo);
managedConnectionInfos.addUnshared(connectionInfo.getManagedConnectionInfo());
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST,"Enlisting connection already associated with handle " + infoString(connectionInfo));
}
}
} else {
ManagedConnectionInfo managedConnectionInfo = managedConnectionInfos.getShared();
if (managedConnectionInfo != null) {
ManagedConnectionInfo previousMci = connectionInfo.getManagedConnectionInfo();
if (previousMci != null && previousMci != managedConnectionInfo && previousMci.getManagedConnection() != null) {
//This might occur if more than one connection were obtained before a UserTransaction were started.
//enlists connection
next.getConnection(connectionInfo);
managedConnectionInfos.addUnshared(previousMci);
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST,"Enlisting existing connection associated with connection handle with current tx " + infoString(connectionInfo));
}
} else {
connectionInfo.setManagedConnectionInfo(managedConnectionInfo);
//return;
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST,"supplying connection from tx cache " + infoString(connectionInfo));
}
}
} else {
next.getConnection(connectionInfo);
managedConnectionInfos.setShared(connectionInfo.getManagedConnectionInfo());
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST,"supplying connection from pool " + connectionInfo.getConnectionHandle() + " for managed connection " + connectionInfo.getManagedConnectionInfo().getManagedConnection() + " to tx caching interceptor " + this);
}
}
}
} else {
next.getConnection(connectionInfo);
}
}