Example usage for javax.transaction Status STATUS_ROLLING_BACK

List of usage examples for javax.transaction Status STATUS_ROLLING_BACK

Introduction

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

Prototype

int STATUS_ROLLING_BACK

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

Click Source Link

Document

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

Usage

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

public static String getTransactionStateString(int state) {
    /*/*from   w  w  w  .ja  v  a 2s.  com*/
     * 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./*from  www  .  j  av a  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 a v a2s .  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 rollbackTransaction(AbstractTransactionContext context) throws ResourceManagerException {
    assureReady();//  w  w  w .j ava2s  . c  om
    synchronized (context) {
        if (logger.isDebugEnabled()) {
            logger.debug("Rolling back transaction " + context);
        }
        try {
            context.status = Status.STATUS_ROLLING_BACK;
            doRollback(context);
            context.status = Status.STATUS_ROLLEDBACK;
        } catch (Error e) {
            setDirty(context, e);
            throw e;
        } catch (RuntimeException e) {
            setDirty(context, e);
            throw e;
        } catch (ResourceManagerSystemException e) {
            setDirty(context, e);
            throw e;
        } finally {
            globalTransactions.remove(context);
            context.finalCleanUp();
            // tell shutdown thread this tx is finished
            context.notifyFinish();
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Rolled back transaction " + context);
        }
    }
}