org.codehaus.activemq.message
Class ActiveMQXid

java.lang.Object
  extended byorg.codehaus.activemq.message.ActiveMQXid
All Implemented Interfaces:
Comparable, Externalizable, Serializable, Xid

public class ActiveMQXid
extends Object
implements Xid, Externalizable, Comparable

A ActiveMQXid object holds the distributed transaction id that is passed around in an ActiveMQ system.

Eventhough a Transaction Manager (TM) has his own Xid implementation that he uses when he talks to the our ActiveMQXAResource, we need to send the Xid data down to the server in our format.

ActiveMQ uses Strings as the transaction id. This class coverts an Xid to and from a string.

Version:
$Revision: 1.1 $
See Also:
Xid, Serialized Form

Field Summary
 
Fields inherited from interface javax.transaction.xa.Xid
MAXBQUALSIZE, MAXGTRIDSIZE
 
Constructor Summary
ActiveMQXid()
          This constructor is only used for serialization
ActiveMQXid(int formatId, byte[] branchQualifier, byte[] globalTransactionId)
           
ActiveMQXid(String txid)
          Creates a new ActiveMQXid object.
ActiveMQXid(Xid xid)
          Creates a new ActiveMQXid object with the Xid data contained in xid
 
Method Summary
protected  int compareTo(byte[] left, byte[] right)
           
 int compareTo(Object object)
           
static boolean equals(byte[] left, byte[] right)
           
 boolean equals(Object that)
           
static boolean equals(Xid tis, Xid that)
          Test for equivlance between two Xid
static ActiveMQXid fromBytes(byte[] data)
          Deserializes the data into an Xid
 byte[] getBranchQualifier()
           
 int getFormatId()
           
 byte[] getGlobalTransactionId()
           
protected  int hash(byte[] bytes, int hash)
           
 int hashCode()
           
static ActiveMQXid read(DataInput dataIn)
          Reads the Xid from a stream
protected static byte[] readBytes(DataInput dataIn)
           
 void readExternal(ObjectInput in)
           
 void readState(DataInput dataIn)
           
 byte[] toBytes()
           
 String toLocalTransactionId()
           
 String toString()
           
 void write(DataOutput dataOut)
          Writes the Xid to a stream
protected  void writeBytes(DataOutput dataOut, byte[] data)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ActiveMQXid

public ActiveMQXid()
This constructor is only used for serialization


ActiveMQXid

public ActiveMQXid(Xid xid)
Creates a new ActiveMQXid object with the Xid data contained in xid


ActiveMQXid

public ActiveMQXid(int formatId,
                   byte[] branchQualifier,
                   byte[] globalTransactionId)

ActiveMQXid

public ActiveMQXid(String txid)
            throws JMSException
Creates a new ActiveMQXid object.

Method Detail

fromBytes

public static ActiveMQXid fromBytes(byte[] data)
                             throws IOException
Deserializes the data into an Xid

Parameters:
data -
Returns:
Throws:
IOException

hashCode

public int hashCode()

equals

public boolean equals(Object that)

equals

public static boolean equals(Xid tis,
                             Xid that)
Test for equivlance between two Xid

Parameters:
tis -
that -
Returns:

compareTo

public int compareTo(Object object)
Specified by:
compareTo in interface Comparable

toLocalTransactionId

public String toLocalTransactionId()

getBranchQualifier

public byte[] getBranchQualifier()
Specified by:
getBranchQualifier in interface Xid
See Also:
Xid.getBranchQualifier()

getFormatId

public int getFormatId()
Specified by:
getFormatId in interface Xid
See Also:
Xid.getFormatId()

getGlobalTransactionId

public byte[] getGlobalTransactionId()
Specified by:
getGlobalTransactionId in interface Xid
See Also:
Xid.getGlobalTransactionId()

toString

public String toString()
See Also:
Object.toString()

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

readState

public void readState(DataInput dataIn)
               throws IOException
Throws:
IOException

read

public static ActiveMQXid read(DataInput dataIn)
                        throws IOException
Reads the Xid from a stream

Parameters:
dataIn -
Returns:
Throws:
IOException

toBytes

public byte[] toBytes()
               throws IOException
Throws:
IOException

write

public void write(DataOutput dataOut)
           throws IOException
Writes the Xid to a stream

Parameters:
dataOut -
Throws:
IOException

writeBytes

protected void writeBytes(DataOutput dataOut,
                          byte[] data)
                   throws IOException
Throws:
IOException

readBytes

protected static byte[] readBytes(DataInput dataIn)
                           throws IOException
Throws:
IOException

equals

public static boolean equals(byte[] left,
                             byte[] right)

compareTo

protected int compareTo(byte[] left,
                        byte[] right)

hash

protected int hash(byte[] bytes,
                   int hash)


Copyright © 2004-2005 Protique, Ltd.. All Rights Reserved.