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

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

Introduction

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

Prototype

public int prepare() throws XAException;

Source Link

Document

Prepares 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  va  2 s.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);
}

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  .  ja va  2 s. c om*/

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