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

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

Introduction

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

Prototype

public int getStatus();

Source Link

Document

Returns the current status of this transaction resource.

Usage

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

public void commit(Xid xid, boolean onePhase) throws XAException {
    TransactionalResource ts = getTransactionalResource(xid);
    if (ts == null) {
        throw new XAException(XAException.XAER_NOTA);
    }//from w  w  w  . j  a v  a 2  s  .  c  o m

    if (getLoggerFacade().isFineEnabled()) {
        getLoggerFacade().logFine("Committing transaction branch " + ts);
    }

    if (ts.getStatus() == STATUS_MARKED_ROLLBACK) {
        throw new XAException(XAException.XA_RBROLLBACK);
    }

    if (ts.getStatus() != STATUS_PREPARED) {
        if (onePhase) {
            ts.prepare();
        } else {
            throw new XAException(XAException.XAER_PROTO);
        }
    }
    ts.commit();
    setCurrentlyActiveTransactionalResource(null);
    removeActiveTransactionalResource(xid);
    removeSuspendedTransactionalResource(xid);
}

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

public int prepare(Xid xid) throws XAException {
    TransactionalResource ts = getTransactionalResource(xid);
    if (ts == null) {
        throw new XAException(XAException.XAER_NOTA);
    }//  www  . j  av  a2 s  .  co  m

    if (getLoggerFacade().isFineEnabled()) {
        getLoggerFacade().logFine("Preparing transaction branch " + ts);
    }

    if (ts.getStatus() == STATUS_MARKED_ROLLBACK) {
        throw new XAException(XAException.XA_RBROLLBACK);
    }

    int result = ts.prepare();
    ts.setStatus(STATUS_PREPARED);
    return result;
}

From source file:org.apache.slide.store.impl.rdbms.AbstractRDBMSStore.java

public Xid[] recover(int flag) throws XAException {

    getLogger().log("recover() for thread: " + Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
    TransactionalResource id = getCurrentlyActiveTransactionalResource();

    if (id != null && id.getStatus() == STATUS_PREPARED) {
        Xid[] xids = new Xid[1];
        xids[0] = id.getXid();//w  w  w .  j  ava2  s. c o  m
        return xids;
    } else
        return new Xid[0];
}