Example usage for javax.transaction.xa XAResource TMJOIN

List of usage examples for javax.transaction.xa XAResource TMJOIN

Introduction

In this page you can find the example usage for javax.transaction.xa XAResource TMJOIN.

Prototype

int TMJOIN

To view the source code for javax.transaction.xa XAResource TMJOIN.

Click Source Link

Document

Caller is joining existing transaction branch.

Usage

From source file:it.doqui.index.ecmengine.business.personalization.multirepository.index.lucene.RepositoryAwareAbstractLuceneIndexerAndSearcherFactory.java

public void start(Xid xid, int flag) throws XAException {

    Map<String, LuceneIndexer> active = activeIndexersInGlobalTx.get(xid);
    Map<String, LuceneIndexer> suspended = suspendedIndexersInGlobalTx.get(xid);

    if (flag == XAResource.TMJOIN) {
        // must be active
        if ((active != null) && (suspended == null)) {
            return;
        } else {//from   ww w .j a  v  a 2 s .  c  om
            throw new XAException("Trying to rejoin transaction in an invalid state");
        }

    } else if (flag == XAResource.TMRESUME) {
        // must be suspended
        if ((active == null) && (suspended != null)) {
            suspendedIndexersInGlobalTx.remove(xid);
            activeIndexersInGlobalTx.put(xid, suspended);
            return;
        } else {
            throw new XAException("Trying to rejoin transaction in an invalid state");
        }

    } else if (flag == XAResource.TMNOFLAGS) {
        if ((active == null) && (suspended == null)) {
            return;
        } else {
            throw new XAException("Trying to start an existing or suspended transaction");
        }
    } else {
        throw new XAException("Unkown flags for start " + flag);
    }
}

From source file:org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerAndSearcherFactory.java

public void start(Xid xid, int flag) throws XAException {
    Map<StoreRef, LuceneIndexer> active = activeIndexersInGlobalTx.get(xid);
    Map<StoreRef, LuceneIndexer> suspended = suspendedIndexersInGlobalTx.get(xid);
    if (flag == XAResource.TMJOIN) {
        // must be active
        if ((active != null) && (suspended == null)) {
            return;
        } else {//from  www . j ava2  s  . c  o  m
            throw new XAException("Trying to rejoin transaction in an invalid state");
        }

    } else if (flag == XAResource.TMRESUME) {
        // must be suspended
        if ((active == null) && (suspended != null)) {
            suspendedIndexersInGlobalTx.remove(xid);
            activeIndexersInGlobalTx.put(xid, suspended);
            return;
        } else {
            throw new XAException("Trying to rejoin transaction in an invalid state");
        }

    } else if (flag == XAResource.TMNOFLAGS) {
        if ((active == null) && (suspended == null)) {
            return;
        } else {
            throw new XAException("Trying to start an existing or suspended transaction");
        }
    } else {
        throw new XAException("Unkown flags for start " + flag);
    }

}

From source file:org.wso2.andes.client.XASession_9_1.java

/**
 * Send startDtx command to server//from  www .j a  v a  2s  .  co  m
 *
 * @param xid  q global transaction identifier to be associated with the resource
 * @param flag one of TMNOFLAGS, TMJOIN, or TMRESUME
 * @return XaStatus returned by server
 * @throws FailoverException when a connection issue is detected
 * @throws AMQException      when an error is detected in AMQ state manager
 */
XaStatus startDtx(Xid xid, int flag) throws FailoverException, AMQException, XAException {

    throwErrorIfClosed();

    DtxStartBody dtxStartBody = methodRegistry.createDtxStartBody(xid.getFormatId(),
            xid.getGlobalTransactionId(), xid.getBranchQualifier(), flag == XAResource.TMJOIN,
            flag == XAResource.TMRESUME);

    AMQMethodEvent amqMethodEvent = _connection._protocolHandler
            .syncWrite(dtxStartBody.generateFrame(_channelId), DtxStartOkBody.class);

    DtxStartOkBodyImpl response = (DtxStartOkBodyImpl) amqMethodEvent.getMethod();

    return XaStatus.valueOf(response.getXaResult());
}