org.jboss.messaging.core.impl.message
Class MessageSupport

java.lang.Object
  extended by org.jboss.messaging.core.impl.message.MessageSupport
All Implemented Interfaces:
java.io.Serializable, Message, Streamable
Direct Known Subclasses:
CoreMessage, JBossMessage

public abstract class MessageSupport
extends java.lang.Object
implements Message, java.io.Serializable

A message base.

Version:
$Revision: 2740 $ Note this class is only serializable so messages can be returned from JMX operations e.g. listAllMessages. For normal message transportation serialization is not used $Id: MessageSupport.java 2740 2007-05-30 11:36:28Z timfox $
Author:
Ovidiu Feodorov, Tim Fox
See Also:
Serialized Form

Field Summary
protected  long expiration
          GMT milliseconds at which this message expires.
protected  java.util.Map headers
           
protected  long messageID
           
protected  java.lang.Object payload
           
protected  byte[] payloadAsByteArray
           
protected  byte priority
           
protected  boolean reliable
           
protected  long timestamp
           
 
Fields inherited from interface org.jboss.messaging.core.contract.Message
CLUSTER_SUCKED
 
Constructor Summary
  MessageSupport()
           
  MessageSupport(long messageID)
           
  MessageSupport(long messageID, boolean reliable, long expiration, long timestamp, byte priority, java.util.Map headers, byte[] payloadAsByteArray)
           
protected MessageSupport(MessageSupport that)
           
 
Method Summary
 boolean containsHeader(java.lang.String name)
          Returns true if the Routable contains the specified header.
 MessageReference createReference()
           
 boolean equals(java.lang.Object o)
           
 long getExpiration()
           
 java.lang.Object getHeader(java.lang.String name)
          Returns the value corresponding to the header name.
 java.util.Map getHeaders()
           
 long getMessageID()
           
 java.lang.Object getPayload()
           
 byte[] getPayloadAsByteArray()
           
 byte getPriority()
           
 long getTimestamp()
           
 int hashCode()
           
 boolean isExpired()
           
 boolean isPersisted()
           
 boolean isReference()
           
 boolean isReliable()
           
 java.lang.Object putHeader(java.lang.String name, java.lang.Object value)
          Binds a header.
 void read(java.io.DataInputStream in)
           
 java.lang.Object removeHeader(java.lang.String name)
          Removes the header.
 void setExpiration(long expiration)
          Set the expiration for this message
 void setPayload(java.lang.Object payload)
           
 void setPersisted(boolean persisted)
           
 void setPriority(byte priority)
          Get the priority of the message.
 java.lang.String toString()
           
 void write(java.io.DataOutputStream out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.messaging.core.contract.Message
getType
 

Field Detail

messageID

protected long messageID

reliable

protected boolean reliable

expiration

protected long expiration
GMT milliseconds at which this message expires. 0 means never expires *


timestamp

protected long timestamp

headers

protected java.util.Map headers

priority

protected byte priority

payload

protected transient java.lang.Object payload

payloadAsByteArray

protected byte[] payloadAsByteArray
Constructor Detail

MessageSupport

public MessageSupport()

MessageSupport

public MessageSupport(long messageID)

MessageSupport

public MessageSupport(long messageID,
                      boolean reliable,
                      long expiration,
                      long timestamp,
                      byte priority,
                      java.util.Map headers,
                      byte[] payloadAsByteArray)

MessageSupport

protected MessageSupport(MessageSupport that)
Method Detail

getMessageID

public long getMessageID()
Specified by:
getMessageID in interface Message
Returns:
The unique id of the message

isReliable

public boolean isReliable()
Specified by:
isReliable in interface Message
Returns:
true if the delivery must be guaranteed for this routable, false otherwise.

getExpiration

public long getExpiration()
Specified by:
getExpiration in interface Message
Returns:
the time when this routable expires and must be removed from the system. A zero value means this routable never expires.

setExpiration

public void setExpiration(long expiration)
Description copied from interface: Message
Set the expiration for this message

Specified by:
setExpiration in interface Message

getTimestamp

public long getTimestamp()
Specified by:
getTimestamp in interface Message
Returns:
the time (in GMT milliseconds) when this routable was delivered to the provider.

putHeader

public java.lang.Object putHeader(java.lang.String name,
                                  java.lang.Object value)
Description copied from interface: Message
Binds a header. If the header map previously contained a mapping for this name, the old value is replaced by the specified value.

Specified by:
putHeader in interface Message
Returns:
the value associated with the name or null if there is no mapping for the name. A null can also indicate that the header map previously associated null with the specified name.

getHeader

public java.lang.Object getHeader(java.lang.String name)
Description copied from interface: Message
Returns the value corresponding to the header name. Returns null if the map contains no mapping for the name. A return value of null does not necessarily indicate that the map contains no mapping for the name; it's also possible that the map explicitly maps the name to null. The containsHeader() operation may be used to distinguish these two cases.

Specified by:
getHeader in interface Message
Returns:
the value associated with the header, or null if there is no mapping for the header.

removeHeader

public java.lang.Object removeHeader(java.lang.String name)
Description copied from interface: Message
Removes the header.

Specified by:
removeHeader in interface Message
Returns:
previous value associated with the header, or null if there was no mapping.

containsHeader

public boolean containsHeader(java.lang.String name)
Description copied from interface: Message
Returns true if the Routable contains the specified header.

Specified by:
containsHeader in interface Message

getHeaders

public java.util.Map getHeaders()
Specified by:
getHeaders in interface Message
Returns:
The message's headers

getPriority

public byte getPriority()
Specified by:
getPriority in interface Message

setPriority

public void setPriority(byte priority)
Description copied from interface: Message
Get the priority of the message. Priorities range from 0 to 9. Where 0 is the lowest priority and 9 is the highest priority

Specified by:
setPriority in interface Message

isReference

public boolean isReference()

getPayloadAsByteArray

public byte[] getPayloadAsByteArray()
Specified by:
getPayloadAsByteArray in interface Message
Returns:
The message's payload in byte[] form

getPayload

public java.lang.Object getPayload()
Specified by:
getPayload in interface Message
Returns:
The message's payload

setPayload

public void setPayload(java.lang.Object payload)

isExpired

public boolean isExpired()
Specified by:
isExpired in interface Message
Returns:
true if the message has expired

createReference

public MessageReference createReference()
Specified by:
createReference in interface Message

isPersisted

public boolean isPersisted()
Specified by:
isPersisted in interface Message

setPersisted

public void setPersisted(boolean persisted)
Specified by:
setPersisted in interface Message

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

write

public void write(java.io.DataOutputStream out)
           throws java.lang.Exception
Specified by:
write in interface Streamable
Throws:
java.lang.Exception

read

public void read(java.io.DataInputStream in)
          throws java.lang.Exception
Specified by:
read in interface Streamable
Throws:
java.lang.Exception


Copyright © 2006 JBoss Inc. All Rights Reserved.