org.codehaus.activemq.message
Class AbstractPacket

java.lang.Object
  extended byorg.codehaus.activemq.message.AbstractPacket
All Implemented Interfaces:
Packet
Direct Known Subclasses:
ActiveMQMessage, BrokerInfo, CapacityInfo, CapacityInfoRequest, ConnectionInfo, ConsumerInfo, DurableUnsubscribe, MessageAck, ProducerInfo, Receipt, SessionInfo, TransactionInfo, XATransactionInfo

public abstract class AbstractPacket
extends java.lang.Object
implements Packet

Abstract class for a transportable Packet

Version:
$Revision: 1.10 $

Field Summary
 
Fields inherited from interface org.codehaus.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, CAPACITY_INFO, CAPACITY_INFO_REQUEST, CONSUMER_INFO, DURABLE_UNSUBSCRIBE, INT_RESPONSE_RECEIPT_INFO, PRODUCER_INFO, RECEIPT_INFO, RESPONSE_RECEIPT_INFO, SESSION_INFO, TRANSACTION_INFO, XA_TRANSACTION_INFO
 
Constructor Summary
AbstractPacket()
           
 
Method Summary
 int decrementMemoryReferenceCount()
          Decrement reference count for bounded memory collections
 boolean equals(java.lang.Object obj)
          Tests equality with another instance
protected  boolean equals(java.lang.Object left, java.lang.Object right)
          A helper method used when implementing equals() which returns true if the objects are identical or equal handling nulls properly
 java.lang.String getId()
           
 int getMemoryUsage()
          Get a hint about how much memory this Packet is consuming
 int getMemoryUsageReferenceCount()
           
protected static java.lang.String getPacketTypeAsString(int type)
           
 int hashCode()
           
 int incrementMemoryReferenceCount()
          Increment reference count for bounded memory collections
 boolean isJMSMessage()
          Retrieve if a JMS Message type or not
 boolean isReceipt()
           
 boolean isReceiptRequired()
           
 void setId(java.lang.String 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
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.codehaus.activemq.message.Packet
getPacketType
 

Constructor Detail

AbstractPacket

public AbstractPacket()
Method Detail

getId

public java.lang.String getId()
Specified by:
getId in interface Packet
Returns:
the unique id for this Packet

setId

public void setId(java.lang.String 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(java.lang.Object obj)
Tests equality with another instance

Parameters:
obj - - the other instance to test equality with
Returns:
Returns true if the objects are equilvant

hashCode

public int hashCode()
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

toString

public java.lang.String toString()
Returns:
pretty print of this Packet

getPacketTypeAsString

protected static java.lang.String getPacketTypeAsString(int type)

equals

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

Returns:
true if the objects are the same or equal or both null


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