Example usage for org.apache.commons.transaction.util.xa TransactionalResource suspend

List of usage examples for org.apache.commons.transaction.util.xa TransactionalResource suspend

Introduction

In this page you can find the example usage for org.apache.commons.transaction.util.xa TransactionalResource suspend.

Prototype

public void suspend() throws XAException;

Source Link

Usage

From source file:org.apache.slide.common.AbstractXAServiceBase.java

public void end(Xid xid, int flags) throws XAException {
    TransactionalResource ts = getActiveTransactionalResource(xid);
    if (ts == null) {
        setCurrentlyActiveTransactionalResource(null);
        throw new XAException(XAException.XAER_NOTA);
    }// w w w  .j a va  2s  .c  om
    if (getCurrentlyActiveTransactionalResource() == null) {
        throw new XAException(XAException.XAER_INVAL);
    }
    if (getLoggerFacade().isFineEnabled()) {
        getLoggerFacade().logFine(new StringBuffer(128).append("Thread ").append(Thread.currentThread())
                .append(flags == TMSUSPEND ? " suspends" : flags == TMFAIL ? " fails" : " ends")
                .append(" work on behalf of transaction branch ").append(ts).toString());
    }

    switch (flags) {
    case TMSUSPEND:
        ts.suspend();
        addSuspendedTransactionalResource(xid, ts);
        removeActiveTransactionalResource(xid);
        break;
    case TMFAIL:
        ts.setStatus(STATUS_MARKED_ROLLBACK);
        break;
    case TMSUCCESS:
        break;
    }
    setCurrentlyActiveTransactionalResource(null);
}