Example usage for javax.transaction.xa Xid equals

List of usage examples for javax.transaction.xa Xid equals

Introduction

In this page you can find the example usage for javax.transaction.xa Xid equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.enhydra.jdbc.standard.StandardXADataSource.java

/**
 * Checks the start of the free list to see if the connection
 * previously associated with the supplied Xid has timed out.
 * <P>/*from ww  w  .  j  av a 2s .  c  o  m*/
 * Note that this can be an expensive operation as it has to
 * scan all free connections. so it should only be called in
 * the event of an error.
 */
synchronized private void checkTimeouts(Xid xid) throws XAException {
    log.debug("StandardXADataSource:checkTimeouts");
    for (int i = 0; i < freeConnections.size(); i++) { // check each free connection
        Object o = freeConnections.elementAt(i); // get next connection
        StandardXAStatefulConnection cur = (StandardXAStatefulConnection) o;
        // cast to something more convenient
        if (!cur.timedOut) { // if it hasn't timed out
            continue; // skip it
        }
        log.debug("StandardXADataSource:checkTimeouts (" + i + "/" + freeConnections.size() + ") xid     = "
                + xid);
        log.debug("StandardXADataSource:checkTimeouts cur.xid = " + cur.xid);
        if (xid.equals(cur.xid)) { // if we've found our xid
            cur.timedOut = false; // cancel time out
            throw new XAException(XAException.XA_RBTIMEOUT);
        }
    }
}

From source file:org.jboss.jbossts.fileio.xalib.txdirs.dir.XAFileResourceManager.java

/**
 * Method to commit the global transaction with the given <code>xid</code>.
 * <p/>/* w ww.  j a v a  2  s .c  o m*/
 * It also acts like the {@link org.apache.commons.transaction.file.FileResourceManager#commitTransaction(Object)}
 * does.
 *
 * @param xid      a global Transaction id
 * @param onePhase If true, the resource manager should use a one-phase
 *                 commit protocol to commit the work done on behalf of xid
 * @throws XAException
 *         if a <code>ResourceManagerException</code> is thrown
 */
public void commit(Xid xid, boolean onePhase) throws XAException {
    System.out.println("XAFileResourceManager.commit(Xid=" + xid + ", onePhase=" + onePhase + ")");
    if (!xid.equals(currentXid)) {
        System.out.println("XAFileResourceManager.commit - wrong Xid!");
    }
    try {
        if (!recovers) {
            freMngr.commitTransaction(curTxId);
        } else {
            // the initFREM() method will take care of incomplete txs
        }
    } catch (ResourceManagerException rme) {
        throw new XAException(rme.getMessage());
    }
    currentXid = null;
}

From source file:org.jboss.jbossts.fileio.xalib.txdirs.dir.XAFileResourceManager.java

/**
 * Forget about a heuristically completed transaction branch.
 * The <code>currentXid</code> is set to null
 *
 * @param xid a global Transaction id/*from   w ww .j a  v  a2 s .c o m*/
 */
public void forget(Xid xid) {
    System.out.println("XAFileResourceManager.forget(Xid=" + xid + ")");
    if (!xid.equals(currentXid)) {
        System.out.println("XAFileResourceManager.forget - wrong Xid!");
    }
    currentXid = null;
}