public ConnectionInterceptor addTransactionInterceptors(ConnectionInterceptor stack, TransactionManager transactionManager) { stack = new TransactionEnlistingInterceptor(stack, transactionManager); return new TransactionCachingInterceptor(stack, transactionManager); }
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 ConnectionInterceptor addTransactionInterceptors(ConnectionInterceptor stack, TransactionManager transactionManager) { stack = new TransactionEnlistingInterceptor(stack, transactionManager); return new TransactionCachingInterceptor(stack, transactionManager); }
public ConnectionInterceptor addTransactionInterceptors(ConnectionInterceptor stack, TransactionManager transactionManager) { //experimental thread local caching if (isUseThreadCaching()) { //useMatching should be configurable stack = new ThreadLocalCachingConnectionInterceptor(stack, false); } stack = new TransactionEnlistingInterceptor(stack, transactionManager); if (isUseTransactionCaching()) { stack = new TransactionCachingInterceptor(stack, transactionManager); } return stack; }