private static XID getXid(Uid uid, Uid branch, int formatId, Integer eisName) throws IllegalStateException { if (uid == null) { throw new IllegalStateException(); } XID xid = new XID(); xid.formatID = formatId; // gtrid is uid byte form followed by as many chars of the node name as will fit. byte[] gtridUid = uid.getBytes(); if (gtridUid.length > XID.MAXGTRIDSIZE) { throw new IllegalStateException(); // Uid is too long!!!! } String nodeName = TxControl.getXANodeName(); int nodeNameLengthToUse = nodeName.getBytes().length; xid.gtrid_length = gtridUid.length + nodeNameLengthToUse; // src, srcPos, dest, destPos, length System.arraycopy(gtridUid, 0, xid.data, 0, gtridUid.length); System.arraycopy(nodeName.getBytes(), 0, xid.data, gtridUid.length, nodeNameLengthToUse); if (branch.notEquals(Uid.nullUid())) { // bqual is uid byte form plus EIS name. byte[] bqualUid = branch.getBytes(); if (bqualUid.length > XID.MAXBQUALSIZE) { throw new IllegalStateException(); // Uid is too long!!!! } int spareBqualBytes = XID.MAXBQUALSIZE - (bqualUid.length + 4); xid.bqual_length = bqualUid.length + 4 + 4; // src, srcPos, dest, destPos, length int offset = xid.gtrid_length; System.arraycopy(bqualUid, 0, xid.data, offset, bqualUid.length); setEisName(xid, eisName); } else { /* * Note: for some dbs we seem to be able to get * away with setting the size field to the size * of the actual branch. However, for Oracle, * it appears as though it must always be 64. * (At least for zero branches.) */ xid.data[xid.gtrid_length] = (byte) 0; xid.bqual_length = 64; } return xid; }
public RecoveryXAResource() { if (xids == null) { xids = new Xid[2]; AtomicAction a = new AtomicAction(); xids[0] = new XidImple(a); String c = com.arjuna.ats.arjuna.coordinator.TxControl.getXANodeName(); String b = "2"; com.arjuna.ats.arjuna.coordinator.TxControl.setXANodeName(b); xids[1] = new XidImple(new Uid()); com.arjuna.ats.arjuna.coordinator.TxControl.setXANodeName(c); } }