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

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

Introduction

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

Prototype

public void commit() throws XAException;

Source Link

Document

Commits the changes done inside this transaction reasource.

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 ww .  j  a v  a2s .  c  om

    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);
}