Java Transaction Xid Check getRedisKey(String keyPrefix, Xid xid)

Here you can find the source of getRedisKey(String keyPrefix, Xid xid)

Description

get Redis Key

License

Apache License

Declaration

public static byte[] getRedisKey(String keyPrefix, Xid xid) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.transaction.xa.Xid;

public class Main {
    public static byte[] getRedisKey(String keyPrefix, Xid xid) {
        byte[] prefix = keyPrefix.getBytes();
        byte[] globalTransactionId = xid.getGlobalTransactionId();
        byte[] branchQualifier = xid.getBranchQualifier();

        byte[] key = new byte[prefix.length + globalTransactionId.length + branchQualifier.length];
        System.arraycopy(prefix, 0, key, 0, prefix.length);
        System.arraycopy(globalTransactionId, 0, key, prefix.length, globalTransactionId.length);
        System.arraycopy(branchQualifier, 0, key, prefix.length + globalTransactionId.length,
                branchQualifier.length);
        return key;
    }//ww  w  .  j av  a  2 s . com
}

Related

  1. getXidSize(Xid xid)
  2. sameTransaction(Xid x1, Xid x2)
  3. sameXID(Xid x1, Xid x2)
  4. xidToString(Xid xid, boolean includeBranchQualifier)