Search in sources :

Example 1 with LocalTransactionException

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);
    }
}
Also used : LocalTransactionException(javax.resource.spi.LocalTransactionException) Connection(javax.resource.cci.Connection) ResourceException(javax.resource.ResourceException) TransactionSystemException(org.springframework.transaction.TransactionSystemException)

Example 2 with LocalTransactionException

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);
    }
}
Also used : LocalTransactionException(javax.resource.spi.LocalTransactionException) Connection(javax.resource.cci.Connection) ResourceException(javax.resource.ResourceException) TransactionSystemException(org.springframework.transaction.TransactionSystemException)

Example 3 with LocalTransactionException

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());
    }
}
Also used : LocalTransactionException(javax.resource.spi.LocalTransactionException) LogWriter(org.apache.geode.LogWriter) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) ResourceException(javax.resource.ResourceException) SystemException(javax.transaction.SystemException) LocalTransactionException(javax.resource.spi.LocalTransactionException)

Example 4 with LocalTransactionException

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;
    }
}
Also used : HeuristicRollbackException(javax.transaction.HeuristicRollbackException) LocalTransactionException(javax.resource.spi.LocalTransactionException) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager) HeuristicMixedException(javax.transaction.HeuristicMixedException) InvalidTransactionException(javax.transaction.InvalidTransactionException) HeuristicRollbackException(javax.transaction.HeuristicRollbackException) RollbackException(javax.transaction.RollbackException)

Example 5 with LocalTransactionException

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);
    }
}
Also used : LocalTransactionException(javax.resource.spi.LocalTransactionException) CannotCreateTransactionException(org.springframework.transaction.CannotCreateTransactionException) Connection(javax.resource.cci.Connection) TransactionSystemException(org.springframework.transaction.TransactionSystemException) NotSupportedException(javax.resource.NotSupportedException)

Aggregations

LocalTransactionException (javax.resource.spi.LocalTransactionException)6 ResourceException (javax.resource.ResourceException)4 Connection (javax.resource.cci.Connection)3 SystemException (javax.transaction.SystemException)3 TransactionSystemException (org.springframework.transaction.TransactionSystemException)3 TransactionManager (javax.transaction.TransactionManager)2 LogWriter (org.apache.geode.LogWriter)2 TXStateProxy (org.apache.geode.internal.cache.TXStateProxy)2 NotSupportedException (javax.resource.NotSupportedException)1 HeuristicMixedException (javax.transaction.HeuristicMixedException)1 HeuristicRollbackException (javax.transaction.HeuristicRollbackException)1 InvalidTransactionException (javax.transaction.InvalidTransactionException)1 RollbackException (javax.transaction.RollbackException)1 CannotCreateTransactionException (org.springframework.transaction.CannotCreateTransactionException)1