use of javax.resource.spi.LocalTransactionException in project spring-framework by spring-projects.
the class CciLocalTransactionManager method doCommit.
@Override
protected void doCommit(DefaultTransactionStatus status) {
CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
Connection con = txObject.getConnectionHolder().getConnection();
if (status.isDebug()) {
logger.debug("Committing CCI local transaction on Connection [" + con + "]");
}
try {
con.getLocalTransaction().commit();
} catch (LocalTransactionException ex) {
throw new TransactionSystemException("Could not commit CCI local transaction", ex);
} catch (ResourceException ex) {
throw new TransactionSystemException("Unexpected failure on commit of CCI local transaction", ex);
}
}
use of javax.resource.spi.LocalTransactionException in project spring-framework by spring-projects.
the class CciLocalTransactionManager method doRollback.
@Override
protected void doRollback(DefaultTransactionStatus status) {
CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
Connection con = txObject.getConnectionHolder().getConnection();
if (status.isDebug()) {
logger.debug("Rolling back CCI local transaction on Connection [" + con + "]");
}
try {
con.getLocalTransaction().rollback();
} catch (LocalTransactionException ex) {
throw new TransactionSystemException("Could not roll back CCI local transaction", ex);
} catch (ResourceException ex) {
throw new TransactionSystemException("Unexpected failure on rollback of CCI local transaction", ex);
}
}
use of javax.resource.spi.LocalTransactionException in project geode by apache.
the class JCALocalTransaction method commit.
@Override
public void commit() throws ResourceException {
LogWriter logger = this.cache.getLogger();
if (logger.fineEnabled()) {
logger.fine("JCALocalTransaction:invoked commit");
}
TXStateProxy tsp = this.gfTxMgr.getTXState();
if (tsp != null && this.tid != tsp.getTransactionId()) {
throw new IllegalStateException("Local Transaction associated with Tid = " + this.tid + " attempting to commit a different transaction");
}
try {
this.gfTxMgr.commit();
this.tid = null;
} catch (Exception e) {
// TODO: consider wrapping the cause
throw new LocalTransactionException(e.toString());
}
}
use of javax.resource.spi.LocalTransactionException in project wildfly by wildfly.
the class MessageEndpointInvocationHandler method afterDelivery.
@Override
public void afterDelivery() throws ResourceException {
final TransactionManager tm = getTransactionManager();
try {
if (currentTx != null) {
if (currentTx.getStatus() == Status.STATUS_MARKED_ROLLBACK)
tm.rollback();
else
tm.commit();
currentTx = null;
}
if (previousTx != null) {
tm.resume(previousTx);
previousTx = null;
}
} catch (InvalidTransactionException e) {
throw new LocalTransactionException(e);
} catch (HeuristicMixedException e) {
throw new LocalTransactionException(e);
} catch (SystemException e) {
throw new LocalTransactionException(e);
} catch (HeuristicRollbackException e) {
throw new LocalTransactionException(e);
} catch (RollbackException e) {
throw new LocalTransactionException(e);
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(previousClassLoader);
previousClassLoader = null;
}
}
use of javax.resource.spi.LocalTransactionException in project spring-framework by spring-projects.
the class CciLocalTransactionManager method doBegin.
@Override
protected void doBegin(Object transaction, TransactionDefinition definition) {
CciLocalTransactionObject txObject = (CciLocalTransactionObject) transaction;
Connection con = null;
try {
con = getConnectionFactory().getConnection();
if (logger.isDebugEnabled()) {
logger.debug("Acquired Connection [" + con + "] for local CCI transaction");
}
txObject.setConnectionHolder(new ConnectionHolder(con));
txObject.getConnectionHolder().setSynchronizedWithTransaction(true);
con.getLocalTransaction().begin();
int timeout = determineTimeout(definition);
if (timeout != TransactionDefinition.TIMEOUT_DEFAULT) {
txObject.getConnectionHolder().setTimeoutInSeconds(timeout);
}
TransactionSynchronizationManager.bindResource(getConnectionFactory(), txObject.getConnectionHolder());
} catch (NotSupportedException ex) {
ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory());
throw new CannotCreateTransactionException("CCI Connection does not support local transactions", ex);
} catch (LocalTransactionException ex) {
ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory());
throw new CannotCreateTransactionException("Could not begin local CCI transaction", ex);
} catch (Throwable ex) {
ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory());
throw new TransactionSystemException("Unexpected failure on begin of CCI local transaction", ex);
}
}
Aggregations