Example usage for javax.transaction Status STATUS_COMMITTING

List of usage examples for javax.transaction Status STATUS_COMMITTING

Introduction

In this page you can find the example usage for javax.transaction Status STATUS_COMMITTING.

Prototype

int STATUS_COMMITTING

To view the source code for javax.transaction Status STATUS_COMMITTING.

Click Source Link

Document

A transaction is associated with the target object and it is in the process of committing.

Usage

From source file:org.commonjava.maven.galley.cache.infinispan.FastLocalCacheProvider.java

private boolean isTxActive(CacheInstance<String, String> cacheInstance) throws SystemException {
    final int[] ACTIVE_STATUS = new int[] { Status.STATUS_ACTIVE, Status.STATUS_COMMITTING,
            Status.STATUS_PREPARING, Status.STATUS_PREPARED, Status.STATUS_ROLLING_BACK };
    boolean isActive = false;
    for (int status : ACTIVE_STATUS) {
        if (cacheInstance.getTransactionStatus() == status) {
            isActive = true;/*from  w w w  .  j av a2  s. co m*/
            break;
        }
    }
    return isActive;
}

From source file:org.etk.entity.engine.plugins.transaction.TransactionUtil.java

public static String getTransactionStateString(int state) {
    /*//from  www.j  ava2s . c  o m
     * javax.transaction.Status STATUS_ACTIVE 0 STATUS_MARKED_ROLLBACK 1
     * STATUS_PREPARED 2 STATUS_COMMITTED 3 STATUS_ROLLEDBACK 4 STATUS_UNKNOWN 5
     * STATUS_NO_TRANSACTION 6 STATUS_PREPARING 7 STATUS_COMMITTING 8
     * STATUS_ROLLING_BACK 9
     */
    switch (state) {
    case Status.STATUS_ACTIVE:
        return "Transaction Active (" + state + ")";
    case Status.STATUS_COMMITTED:
        return "Transaction Committed (" + state + ")";
    case Status.STATUS_COMMITTING:
        return "Transaction Committing (" + state + ")";
    case Status.STATUS_MARKED_ROLLBACK:
        return "Transaction Marked Rollback (" + state + ")";
    case Status.STATUS_NO_TRANSACTION:
        return "No Transaction (" + state + ")";
    case Status.STATUS_PREPARED:
        return "Transaction Prepared (" + state + ")";
    case Status.STATUS_PREPARING:
        return "Transaction Preparing (" + state + ")";
    case Status.STATUS_ROLLEDBACK:
        return "Transaction Rolledback (" + state + ")";
    case Status.STATUS_ROLLING_BACK:
        return "Transaction Rolling Back (" + state + ")";
    case Status.STATUS_UNKNOWN:
        return "Transaction Status Unknown (" + state + ")";
    default:
        return "Not a valid state code (" + state + ")";
    }
}

From source file:org.j2free.jpa.Controller.java

/**
 * Ends the contatiner managed <tt>UserTransaction</tt>, committing
 * or rolling back as necessary./*w w  w .  j  a  va 2 s.  co  m*/
 *
 * @throws SystemException
 * @throws RollbackException
 * @throws HeuristicMixedException
 * @throws HeuristicRollbackException
 */
public void end()
        throws SystemException, RollbackException, HeuristicMixedException, HeuristicRollbackException {
    try {
        switch (tx.getStatus()) {
        case Status.STATUS_MARKED_ROLLBACK:
            tx.rollback();
            break;
        case Status.STATUS_ACTIVE:
            tx.commit();
            break;
        case Status.STATUS_COMMITTED:
            // somebody called end() twice
            break;
        case Status.STATUS_COMMITTING:
            log.warn("uh oh, concurrency problem! end() called when transaction already committing");
            break;
        case Status.STATUS_ROLLEDBACK:
            // somebody called end() twice
            break;
        case Status.STATUS_ROLLING_BACK:
            log.warn("uh oh, concurrency problem! end() called when transaction already rolling back");
            break;
        default:
            throw new IllegalStateException("Unknown status in endTransaction: " + getTransactionStatus());
        }

        problem = null;
        errors = null;
    } catch (InvalidStateException ise) {
        problem = ise;
        this.errors = ise.getInvalidValues();
    }
}

From source file:org.j2free.jpa.Controller.java

/**
 * //ww w .j ava 2  s.c  o m
 * @return
 * @throws SystemException
 */
public String getTransactionStatus() throws SystemException {
    if (tx == null) {
        return "Null transaction";
    }

    switch (tx.getStatus()) {
    case Status.STATUS_ACTIVE:
        return "Active";
    case Status.STATUS_COMMITTED:
        return "Committed";
    case Status.STATUS_COMMITTING:
        return "Committing";
    case Status.STATUS_MARKED_ROLLBACK:
        return "Marked for rollback";
    case Status.STATUS_NO_TRANSACTION:
        return "No Transaction";
    case Status.STATUS_PREPARED:
        return "Prepared";
    case Status.STATUS_ROLLEDBACK:
        return "Rolledback";
    case Status.STATUS_ROLLING_BACK:
        return "Rolling back";
    case Status.STATUS_UNKNOWN:
        return "Declared Unknown";
    default:
        return "Undeclared Unknown Status";
    }
}

From source file:org.mule.util.xa.AbstractResourceManager.java

public void commitTransaction(AbstractTransactionContext context) throws ResourceManagerException {
    assureReady();//ww  w .  j a v a2 s.  c o m
    if (context.status == Status.STATUS_MARKED_ROLLBACK) {
        throw new ResourceManagerException(CoreMessages.transactionMarkedForRollback());
    }
    synchronized (context) {
        if (logger.isDebugEnabled()) {
            logger.debug("Committing transaction " + context);
        }
        try {
            context.status = Status.STATUS_COMMITTING;
            doCommit(context);
            context.status = Status.STATUS_COMMITTED;
        } catch (Error e) {
            setDirty(context, e);
            throw e;
        } catch (RuntimeException e) {
            setDirty(context, e);
            throw e;
        } catch (ResourceManagerSystemException e) {
            setDirty(context, e);
            throw e;
        } catch (ResourceManagerException e) {
            logger.warn("Could not commit tx " + context + ", rolling back instead", e);
            doRollback(context);
        } finally {
            globalTransactions.remove(context);
            context.finalCleanUp();
            // tell shutdown thread this tx is finished
            context.notifyFinish();
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Committed transaction " + context);
        }
    }
}