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

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

Introduction

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

Prototype

public void resume() throws XAException;

Source Link

Usage

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

public void start(Xid xid, int flags) throws XAException {
    if (getCurrentlyActiveTransactionalResource() != null) {
        throw new XAException(XAException.XAER_INVAL);
    }/*w w  w.j  a  va 2 s  . com*/
    if (getLoggerFacade().isFineEnabled()) {
        getLoggerFacade().logFine(new StringBuffer(128).append("Thread ").append(Thread.currentThread())
                .append(flags == TMNOFLAGS ? " starts" : flags == TMJOIN ? " joins" : " resumes")
                .append(" work on behalf of transaction branch ").append(xid).toString());
    }

    TransactionalResource ts;
    switch (flags) {
    // a new transaction
    case TMNOFLAGS:
    case TMJOIN:
    default:
        try {
            ts = createTransactionResource(xid);
            ts.begin();
        } catch (Exception e) {
            getLoggerFacade().logSevere("Could not create new transactional  resource", e);
            throw new XAException(e.getMessage());
        }
        break;
    case TMRESUME:
        ts = getSuspendedTransactionalResource(xid);
        if (ts == null) {
            throw new XAException(XAException.XAER_NOTA);
        }
        ts.resume();
        removeSuspendedTransactionalResource(xid);
        break;
    }
    setCurrentlyActiveTransactionalResource(ts);
    addAcitveTransactionalResource(xid, ts);
}

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

public void start(Xid xid, int flags) throws XAException {
    TransactionalResource resource = getCurrentlyActiveTransactionalResource();
    if (resource != null) {
        throw new XAException(XAException.XAER_INVAL);
    }/*from   www .j  a  v  a  2 s  . c  om*/
    if (getLoggerFacade().isFineEnabled()) {
        getLoggerFacade().logFine(new StringBuffer(128).append("Thread ").append(Thread.currentThread())
                .append(flags == TMNOFLAGS ? " starts" : flags == TMJOIN ? " joins" : " resumes")
                .append(" work on behalf of transaction branch ").append(xid).toString());
    }

    TransactionalResource ts;
    switch (flags) {
    // a new transaction
    case TMNOFLAGS:
    case TMJOIN:
    default:
        try {
            ts = createTransactionResource(xid);
            ts.begin();
        } catch (Exception e) {
            getLoggerFacade().logSevere("Could not create new transactional  resource", e);
            throw new XAException(e.getMessage());
        }
        break;
    case TMRESUME:
        ts = getSuspendedTransactionalResource(xid);
        if (ts == null) {
            throw new XAException(XAException.XAER_NOTA);
        }
        ts.resume();
        removeSuspendedTransactionalResource(xid);
        break;
    }
    setCurrentlyActiveTransactionalResource(ts);
    addAcitveTransactionalResource(xid, ts);
}