Transaction transaction = TxUtil.getTransactionIfActive(transactionManager); if (transaction != null) { XAResource xares = mci.getXAResource(); if (log.isTraceEnabled()) { log.trace("Delisting connection " + connectionInfo + " with XAResource " + xares + " in transaction: " + transaction, new Exception("stack trace")); } else { if (log.isTraceEnabled()) { log.trace("not delisting connection " + connectionInfo + " with XAResource " + mci.getXAResource() + " no transaction"); log.info("Could not delist resource: " + connectionInfo + " with XAResource: " + connectionInfo.getManagedConnectionInfo().getXAResource(), e); connectionReturnAction = ConnectionReturnAction.DESTROY; } catch (IllegalStateException e) {
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { next.getConnection(connectionInfo); try { ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); // get the current transation and status... if there is a problem just assume there is no transaction present Transaction transaction = TxUtil.getTransactionIfActive(transactionManager); if (transaction != null) { XAResource xares = mci.getXAResource(); if (log.isTraceEnabled()) { log.trace("Enlisting connection " + connectionInfo + " with XAResource " + xares + " in transaction: " + transaction); } transaction.enlistResource(xares); } else { if (log.isTraceEnabled()) { log.trace("not enlisting connection " + connectionInfo + " with XAResource " + mci.getXAResource() + " no transaction"); } } } catch (SystemException e) { returnConnection(connectionInfo, ConnectionReturnAction.DESTROY); throw new ResourceException("Could not get transaction", e); } catch (RollbackException e) { //transaction is marked rolled back, so the xaresource could not have been enlisted next.returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE); throw new ResourceException("Could not enlist resource in rolled back transaction", e); } catch (Throwable t) { returnConnection(connectionInfo, ConnectionReturnAction.DESTROY); throw new ResourceException("Unknown throwable when trying to enlist connection in tx", t); } }
public NamedXAResource getNamedXAResource() throws SystemException { try { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, null); ConnectionInfo recoveryConnectionInfo = new ConnectionInfo(mci); recoveryStack.getConnection(recoveryConnectionInfo); // For pooled resources, we may now have a new MCI (not the one constructed above). Make sure we use the correct MCI return new NamedXAResourceWithConnectioninfo((NamedXAResource) recoveryConnectionInfo.getManagedConnectionInfo().getXAResource(), recoveryConnectionInfo); } catch (ResourceException e) { throw (SystemException) new SystemException("Could not get XAResource for recovery for mcf: " + name).initCause(e); } }