Search in sources :

Example 6 with LocalTransactionException

use of javax.resource.spi.LocalTransactionException in project geode by apache.

the class JCALocalTransaction method begin.

@Override
public void begin() throws ResourceException {
    try {
        if (!this.initDone || this.cache.isClosed()) {
            this.init();
        }
        LogWriter logger = this.cache.getLogger();
        if (logger.fineEnabled()) {
            logger.fine("JCALocalTransaction::begin:");
        }
        TransactionManager tm = this.cache.getJTATransactionManager();
        if (this.tid != null) {
            throw new LocalTransactionException(" A transaction is already in progress");
        }
        if (tm != null && tm.getTransaction() != null) {
            if (logger.fineEnabled()) {
                logger.fine("JCAManagedConnection: JTA transaction is on");
            }
            // This is having a JTA transaction. Assuming ignore jta flag is true,
            // explicitly being a gemfire transaction.
            TXStateProxy tsp = this.gfTxMgr.getTXState();
            if (tsp == null) {
                this.gfTxMgr.begin();
                tsp = this.gfTxMgr.getTXState();
                tsp.setJCATransaction();
                this.tid = tsp.getTransactionId();
                if (logger.fineEnabled()) {
                    logger.fine("JCALocalTransaction:begun GFE transaction");
                }
            } else {
                throw new LocalTransactionException("GemFire is already associated with a transaction");
            }
        } else {
            if (logger.fineEnabled()) {
                logger.fine("JCAManagedConnection: JTA Transaction does not exist.");
            }
        }
    } catch (SystemException e) {
        throw new ResourceException(e);
    }
}
Also used : LocalTransactionException(javax.resource.spi.LocalTransactionException) SystemException(javax.transaction.SystemException) LogWriter(org.apache.geode.LogWriter) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) TransactionManager(javax.transaction.TransactionManager) ResourceException(javax.resource.ResourceException)

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