Example usage for javax.transaction.xa XAResource hashCode

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

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public native int hashCode();

Source Link

Document

Returns a hash code value for the object.

Usage

From source file:org.apache.synapse.commons.transaction.TranscationManger.java

public static void bindConnection(final Connection conn) throws Exception {
    long key = Thread.currentThread().getId();
    try {/*from w w  w .j ava  2  s  .  c  o m*/
        if (conn instanceof XAConnection) {
            Transaction tx = transactions.get().get(key);
            XAResource xaRes = ((XAConnection) conn).getXAResource();

            if (!isXAResourceEnlisted(xaRes)) {
                tx.enlistResource(xaRes);
                addToEnlistedXADataSources(xaRes, key);
                log.debug(" DS enlisted in thread " + key + " XA Resource : " + xaRes.hashCode());
            }
        }

    } catch (Exception ex) {
        StringBuilder logMsg = new StringBuilder();
        Connection actual = ((javax.sql.PooledConnection) conn).getConnection();
        logMsg.append(" Thread Id : " + key)
                .append(" BIND ERROR , Transaction Manager status : " + txManagers.get().get(key).getStatus())
                .append("\n")
                .append(" BIND ERROR , Transaction status : " + transactions.get().get(key).getStatus())
                .append("\n").append(" JDBC Connection status : " + actual.isClosed()).append("\n")
                .append(" BIND ERROR  : " + ex);
        log.error(logMsg.toString());
        rollbackTransaction(true, key);
        throw ex;
    }
}