mirror of https://github.com/apache/activemq.git
implement Comparable (well, badly)
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@557384 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
26f4d2a413
commit
71a3324b93
|
@ -18,9 +18,7 @@
|
||||||
package org.apache.activemq.command;
|
package org.apache.activemq.command;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.transaction.xa.Xid;
|
import javax.transaction.xa.Xid;
|
||||||
|
|
||||||
import org.apache.activemq.util.HexSupport;
|
import org.apache.activemq.util.HexSupport;
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +26,7 @@ import org.apache.activemq.util.HexSupport;
|
||||||
* @openwire:marshaller code="112"
|
* @openwire:marshaller code="112"
|
||||||
* @version $Revision: 1.6 $
|
* @version $Revision: 1.6 $
|
||||||
*/
|
*/
|
||||||
public class XATransactionId extends TransactionId implements Xid {
|
public class XATransactionId extends TransactionId implements Xid, Comparable{
|
||||||
|
|
||||||
public static final byte DATA_STRUCTURE_TYPE=CommandTypes.ACTIVEMQ_XA_TRANSACTION_ID;
|
public static final byte DATA_STRUCTURE_TYPE=CommandTypes.ACTIVEMQ_XA_TRANSACTION_ID;
|
||||||
|
|
||||||
|
@ -37,6 +35,7 @@ public class XATransactionId extends TransactionId implements Xid {
|
||||||
private byte[] globalTransactionId;
|
private byte[] globalTransactionId;
|
||||||
|
|
||||||
private transient int hash;
|
private transient int hash;
|
||||||
|
private transient String transactionKey;
|
||||||
|
|
||||||
public XATransactionId() {
|
public XATransactionId() {
|
||||||
}
|
}
|
||||||
|
@ -51,8 +50,12 @@ public class XATransactionId extends TransactionId implements Xid {
|
||||||
return DATA_STRUCTURE_TYPE;
|
return DATA_STRUCTURE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTransactionKey() {
|
public synchronized String getTransactionKey(){
|
||||||
return "XID:"+formatId+":"+HexSupport.toHexFromBytes(globalTransactionId)+":"+HexSupport.toHexFromBytes(branchQualifier);
|
if(transactionKey==null){
|
||||||
|
transactionKey="XID:"+formatId+":"+HexSupport.toHexFromBytes(globalTransactionId)+":"
|
||||||
|
+HexSupport.toHexFromBytes(branchQualifier);
|
||||||
|
}
|
||||||
|
return transactionKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -129,5 +132,12 @@ public class XATransactionId extends TransactionId implements Xid {
|
||||||
return xid.formatId==formatId && Arrays.equals(xid.globalTransactionId,globalTransactionId)
|
return xid.formatId==formatId && Arrays.equals(xid.globalTransactionId,globalTransactionId)
|
||||||
&& Arrays.equals(xid.branchQualifier, branchQualifier);
|
&& Arrays.equals(xid.branchQualifier, branchQualifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object o){
|
||||||
|
if( o==null || o.getClass()!=XATransactionId.class )
|
||||||
|
return -1;
|
||||||
|
XATransactionId xid = (XATransactionId)o;
|
||||||
|
return getTransactionKey().compareTo(xid.getTransactionKey());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue