org.activemq.message
Class AbstractPacket

java.lang.Object
  extended by org.activemq.message.AbstractPacket
All Implemented Interfaces:
Packet
Direct Known Subclasses:
ActiveMQMessage, BrokerAdminCommand, BrokerInfo, CachedValue, CapacityInfo, CapacityInfoRequest, CleanupConnectionInfo, ConnectionInfo, ConsumerInfo, DurableUnsubscribe, FlushPacket, KeepAlive, MessageAck, ProducerInfo, Receipt, SessionInfo, TempDestinationAdvisoryEvent, TransactionInfo, WireFormatInfo, XATransactionInfo

public abstract class AbstractPacket
extends Object
implements Packet

Abstract class for a transportable Packet

Version:
$Revision: 1.1.1.1 $

Field Summary
protected  BitArray bitArray
           
static int BROKERS_VISITED_INDEX
           
protected  int cachedHashCode
           
static int RECEIPT_REQUIRED_INDEX
          Message flag indexes (used for writing/reading to/from a Stream
 
Fields inherited from interface org.activemq.message.Packet
ACTIVEMQ_BROKER_INFO, ACTIVEMQ_BYTES_MESSAGE, ACTIVEMQ_CONNECTION_INFO, ACTIVEMQ_MAP_MESSAGE, ACTIVEMQ_MESSAGE, ACTIVEMQ_MSG_ACK, ACTIVEMQ_OBJECT_MESSAGE, ACTIVEMQ_STREAM_MESSAGE, ACTIVEMQ_TEXT_MESSAGE, BROKER_ADMIN_COMMAND, CACHED_VALUE_COMMAND, CAPACITY_INFO, CAPACITY_INFO_REQUEST, CLEANUP_CONNECTION_INFO, CONSUMER_INFO, DURABLE_UNSUBSCRIBE, INT_RESPONSE_RECEIPT_INFO, KEEP_ALIVE, NOT_SET, PRODUCER_INFO, RECEIPT_INFO, RESPONSE_RECEIPT_INFO, SESSION_INFO, TRANSACTION_INFO, WIRE_FORMAT_INFO, XA_TRANSACTION_INFO
 
Constructor Summary
protected AbstractPacket()
           
 
Method Summary
 void addBrokerVisited(String brokerName)
          As the packet passes through the broker add the broker to the visited list
 void clearBrokersVisited()
          clear list of brokers visited
 int decrementMemoryReferenceCount()
          Decrement reference count for bounded memory collections
 boolean equals(Object obj)
          Tests equality with another instance
protected  boolean equals(Object left, Object right)
          A helper method used when implementing equals() which returns true if the objects are identical or equal handling nulls properly
 BitArray getBitArray()
           
 Object[] getBrokersVisited()
           
 String getBrokersVisitedAsString()
           
 short getId()
           
 int getMemoryUsage()
          Get a hint about how much memory this Packet is consuming
 int getMemoryUsageReferenceCount()
           
static String getPacketTypeAsString(int type)
           
 int hashCode()
           
 boolean hasVisited(String brokerName)
          test to see if the named broker has already seen this packet
 int incrementMemoryReferenceCount()
          Increment reference count for bounded memory collections
protected  void initializeOther(AbstractPacket other)
          Initializes another message with current values from this instance
 boolean isJMSMessage()
          Retrieve if a JMS Message type or not
 boolean isReceipt()
           
 boolean isReceiptRequired()
           
 void setBitArray(BitArray bitArray)
           
 void setBrokersVisitedAsString(String value)
           
 void setId(short newId)
          Set the unique id for this Packet
 void setMemoryUsage(int newMemoryUsage)
          Set a hint about how mujch memory this packet is consuming
 void setReceiptRequired(boolean value)
          Set if a Recipt if required on receiving this Packet
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.activemq.message.Packet
getPacketType
 

Field Detail

RECEIPT_REQUIRED_INDEX

public static final int RECEIPT_REQUIRED_INDEX
Message flag indexes (used for writing/reading to/from a Stream

See Also:
Constant Field Values

BROKERS_VISITED_INDEX

public static final int BROKERS_VISITED_INDEX
See Also:
Constant Field Values

bitArray

protected BitArray bitArray

cachedHashCode

protected transient int cachedHashCode
Constructor Detail

AbstractPacket

protected AbstractPacket()
Method Detail

getId

public short getId()
Specified by:
getId in interface Packet
Returns:
the unique id for this Packet

setId

public void setId(short newId)
Set the unique id for this Packet

Specified by:
setId in interface Packet
Parameters:
newId -

isReceiptRequired

public boolean isReceiptRequired()
Specified by:
isReceiptRequired in interface Packet
Returns:
true if a Recipt is required

isReceipt

public boolean isReceipt()
Specified by:
isReceipt in interface Packet
Returns:
false since most packets are not receipt packets

setReceiptRequired

public void setReceiptRequired(boolean value)
Set if a Recipt if required on receiving this Packet

Specified by:
setReceiptRequired in interface Packet
Parameters:
value -

isJMSMessage

public boolean isJMSMessage()
Retrieve if a JMS Message type or not

Specified by:
isJMSMessage in interface Packet
Returns:
true if it is a JMS Message

equals

public boolean equals(Object obj)
Tests equality with another instance

Overrides:
equals in class Object
Parameters:
obj - - the other instance to test equality with
Returns:
Returns true if the objects are equilvant

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
Returns hash code for this instance

getMemoryUsage

public int getMemoryUsage()
Get a hint about how much memory this Packet is consuming

Specified by:
getMemoryUsage in interface Packet
Returns:
an aproximation of the current memory used by this instance

setMemoryUsage

public void setMemoryUsage(int newMemoryUsage)
Set a hint about how mujch memory this packet is consuming

Specified by:
setMemoryUsage in interface Packet
Parameters:
newMemoryUsage -

incrementMemoryReferenceCount

public int incrementMemoryReferenceCount()
Increment reference count for bounded memory collections

Specified by:
incrementMemoryReferenceCount in interface Packet
Returns:
the incremented reference value
See Also:
MemoryBoundedQueue

decrementMemoryReferenceCount

public int decrementMemoryReferenceCount()
Decrement reference count for bounded memory collections

Specified by:
decrementMemoryReferenceCount in interface Packet
Returns:
the decremented reference value
See Also:
MemoryBoundedQueue

getMemoryUsageReferenceCount

public int getMemoryUsageReferenceCount()
Specified by:
getMemoryUsageReferenceCount in interface Packet
Returns:
the current reference count for bounded memory collections
See Also:
MemoryBoundedQueue

addBrokerVisited

public void addBrokerVisited(String brokerName)
As the packet passes through the broker add the broker to the visited list

Specified by:
addBrokerVisited in interface Packet
Parameters:
brokerName - the name of the broker

clearBrokersVisited

public void clearBrokersVisited()
clear list of brokers visited

Specified by:
clearBrokersVisited in interface Packet

hasVisited

public boolean hasVisited(String brokerName)
test to see if the named broker has already seen this packet

Specified by:
hasVisited in interface Packet
Parameters:
brokerName - the name of the broker
Returns:
true if the packet has visited the broker

getBrokersVisitedAsString

public String getBrokersVisitedAsString()
Specified by:
getBrokersVisitedAsString in interface Packet
Returns:
Returns the brokersVisited.

setBrokersVisitedAsString

public void setBrokersVisitedAsString(String value)

toString

public String toString()
Overrides:
toString in class Object
Returns:
pretty print of this Packet

getPacketTypeAsString

public static String getPacketTypeAsString(int type)

equals

protected boolean equals(Object left,
                         Object right)
A helper method used when implementing equals() which returns true if the objects are identical or equal handling nulls properly

Parameters:
left -
right -
Returns:
true if the objects are the same or equal or both null

initializeOther

protected void initializeOther(AbstractPacket other)
Initializes another message with current values from this instance

Parameters:
other - the other ActiveMQMessage to initialize

getBrokersVisited

public Object[] getBrokersVisited()
Returns:
Returns the brokersVisited.

getBitArray

public BitArray getBitArray()
Returns:
Returns the bitArray.

setBitArray

public void setBitArray(BitArray bitArray)
Parameters:
bitArray - The bitArray to set.


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