activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r557384 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java
Date Wed, 18 Jul 2007 20:29:14 GMT
Author: rajdavies
Date: Wed Jul 18 13:29:13 2007
New Revision: 557384

URL: http://svn.apache.org/viewvc?view=rev&rev=557384
Log:
implement Comparable (well, badly)

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java?view=diff&rev=557384&r1=557383&r2=557384
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/XATransactionId.java
Wed Jul 18 13:29:13 2007
@@ -18,9 +18,7 @@
 package org.apache.activemq.command;
 
 import java.util.Arrays;
-
 import javax.transaction.xa.Xid;
-
 import org.apache.activemq.util.HexSupport;
 
 
@@ -28,7 +26,7 @@
  * @openwire:marshaller code="112"
  * @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;
 
@@ -37,6 +35,7 @@
     private byte[] globalTransactionId;
     
     private transient int hash;
+    private transient String transactionKey;
     
     public XATransactionId() {        
     }
@@ -51,8 +50,12 @@
         return DATA_STRUCTURE_TYPE;
     }
         
-    public String getTransactionKey() {
-        return "XID:"+formatId+":"+HexSupport.toHexFromBytes(globalTransactionId)+":"+HexSupport.toHexFromBytes(branchQualifier);
+    public synchronized String getTransactionKey(){
+        if(transactionKey==null){
+            transactionKey="XID:"+formatId+":"+HexSupport.toHexFromBytes(globalTransactionId)+":"
+                    +HexSupport.toHexFromBytes(branchQualifier);
+        }
+        return transactionKey;
     }
 
     public String toString() {
@@ -128,6 +131,13 @@
         XATransactionId xid = (XATransactionId)o;
         return xid.formatId==formatId && Arrays.equals(xid.globalTransactionId,globalTransactionId)
                && 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());
     }
     
 }



Mime
View raw message