org.codehaus.activemq.message
Class ActiveMQXid

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

public class ActiveMQXid
extends java.lang.Object
implements Xid, java.io.Externalizable, java.lang.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.8 $
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(java.lang.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(java.lang.Object object)
           
 boolean equals(ActiveMQXid that)
           
protected  boolean equals(byte[] left, byte[] right)
           
 boolean equals(java.lang.Object that)
           
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(java.io.DataInput dataIn)
          Reads the Xid from a stream
protected static byte[] readBytes(java.io.DataInput dataIn)
           
 void readExternal(java.io.ObjectInput in)
           
 void readState(java.io.DataInput dataIn)
           
 byte[] toBytes()
           
 java.lang.String toLocalTransactionId()
           
 java.lang.String toString()
           
 void write(java.io.DataOutput dataOut)
          Writes the Xid to a stream
protected  void writeBytes(java.io.DataOutput dataOut, byte[] data)
           
 void writeExternal(java.io.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(java.lang.String txid)
            throws JMSException
Creates a new ActiveMQXid object.

Method Detail

fromBytes

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

Parameters:
data -
Returns:
Throws:
java.io.IOException

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object that)

equals

public boolean equals(ActiveMQXid that)

compareTo

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

toLocalTransactionId

public java.lang.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 java.lang.String toString()
See Also:
Object.toString()

writeExternal

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

readExternal

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

readState

public void readState(java.io.DataInput dataIn)
               throws java.io.IOException
Throws:
java.io.IOException

read

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

Parameters:
dataIn -
Returns:
Throws:
java.io.IOException

toBytes

public byte[] toBytes()
               throws java.io.IOException
Throws:
java.io.IOException

write

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

Parameters:
dataOut -
Throws:
java.io.IOException

writeBytes

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

readBytes

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

equals

protected boolean equals(byte[] left,
                         byte[] right)

compareTo

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

hash

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


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