Example usage for org.apache.commons.transaction.file ResourceManager PREPARE_SUCCESS_READONLY

List of usage examples for org.apache.commons.transaction.file ResourceManager PREPARE_SUCCESS_READONLY

Introduction

In this page you can find the example usage for org.apache.commons.transaction.file ResourceManager PREPARE_SUCCESS_READONLY.

Prototype

int PREPARE_SUCCESS_READONLY

To view the source code for org.apache.commons.transaction.file ResourceManager PREPARE_SUCCESS_READONLY.

Click Source Link

Document

Prepare result: resource manager guarantees a successful commit as there is nothing to commit

Usage

From source file:org.apache.slide.store.txfile.AbstractTxFileStoreService.java

public synchronized int prepare(Xid xid) throws XAException {
    Object txId = wrap(xid);/*  w w  w . jav a 2  s  .  c  o m*/
    Thread currentThread = Thread.currentThread();
    getLogger().log("Thread " + currentThread + " prepares transaction branch " + txId, getLogChannel(),
            DEBUG_LEVEL);
    try {
        int status = rm.prepareTransaction(txId);
        switch (status) {
        case ResourceManager.PREPARE_SUCCESS_READONLY:
            return XA_RDONLY;
        case ResourceManager.PREPARE_SUCCESS:
            return XA_OK;
        default:
            throw new XAException(XAException.XA_RBROLLBACK);
        }
    } catch (ResourceManagerException e) {
        getLogger().log("Thread " + currentThread + " failed to prepare transaction branch " + txId, e,
                getLogChannel(), Logger.CRITICAL);
        throw createXAException(e);
    }
}

From source file:org.apache.slide.store.txfile.TxXMLFileDescriptorsStore.java

public synchronized int prepare(Xid xid) throws XAException {
    Object txId = wrap(xid);/*www. j a  v a2  s . c o  m*/
    getLogger().log("Thread " + Thread.currentThread() + " prepares transaction branch " + txId, LOG_CHANNEL,
            Logger.DEBUG);
    try {
        if (deferSaving) {
            // save all descriptors registered for saving
            TxContext txContext = (TxContext) activeContexts.get(txId);
            if (txContext == null)
                txContext = (TxContext) suspendedContexts.get(txId);
            // really should not, but only to be sure...
            if (txContext != null) {
                try {
                    txContext.saveDescriptors();
                } catch (ObjectNotFoundException onfe) {
                    getLogger().log("Thread " + Thread.currentThread()
                            + " failed to prepare transaction branch " + txId, onfe, LOG_CHANNEL,
                            Logger.CRITICAL);
                    throw new XAException(onfe.toString());
                } catch (ServiceAccessException sae) {
                    getLogger().log("Thread " + Thread.currentThread()
                            + " failed to prepare transaction branch " + txId, sae, LOG_CHANNEL,
                            Logger.CRITICAL);
                    throw new XAException(sae.toString());
                }
            } else {
                getLogger().log("Thread " + Thread.currentThread()
                        + " could prepare *unknown* transaction branch " + txId, LOG_CHANNEL, Logger.WARNING);
            }
        }
        int status = rm.prepareTransaction(txId);
        switch (status) {
        case ResourceManager.PREPARE_SUCCESS_READONLY:
            return XA_RDONLY;
        case ResourceManager.PREPARE_SUCCESS:
            return XA_OK;
        default:
            throw new XAException(XAException.XA_RBROLLBACK);
        }
    } catch (ResourceManagerException e) {
        getLogger().log("Thread " + Thread.currentThread() + " failed to prepare transaction branch " + txId, e,
                LOG_CHANNEL, Logger.CRITICAL);
        throw createXAException(e);
    }
}