org.jboss.messaging.core.message
Class MessageSupport

java.lang.Object
  extended byorg.jboss.messaging.core.message.MessageSupport
All Implemented Interfaces:
Message, java.io.Serializable, 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't 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  byte priority
           
protected  boolean reliable
           
protected  long timestamp
           
 
Fields inherited from interface org.jboss.messaging.core.message.Message
FAILED_NODE_ID
 
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
protected  void clearPayloadAsByteArray()
           
 boolean containsHeader(java.lang.String name)
          Returns true if the Routable contains the specified header.
protected  void copyPayloadAsByteArrayToPayload()
          It makes sense to use this method only from within JBossBytesMessage (optimization).
 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.Set getHeaderNames()
          Returns a copy of the header name set.
 java.util.Map getHeaders()
           
 long getMessageID()
           
 java.lang.Object getPayload()
          Warning! Calling getPayload will cause the payload to be deserialized so should not be called on the server.
 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)
           
protected  java.lang.Object readPayload(java.io.DataInputStream in, int length)
          Override this if you want more sophisticated payload externalization.
 java.lang.Object removeHeader(java.lang.String name)
          Removes the header.
 void setExpiration(long expiration)
           
 void setHeaders(java.util.Map headers)
           
 void setPayload(java.io.Serializable payload)
           
 void setPersisted(boolean persisted)
           
 void setPriority(byte priority)
           
 java.lang.String toString()
           
 void write(java.io.DataOutputStream out)
           
protected  void writePayload(java.io.DataOutputStream out, java.lang.Object thePayload)
          Override this if you want more sophisticated payload externalization.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.messaging.core.message.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
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

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 (in GMT milliseconds) 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)
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

getHeaderNames

public java.util.Set getHeaderNames()
Description copied from interface: Message
Returns a copy of the header name set.

Specified by:
getHeaderNames in interface Message

getHeaders

public java.util.Map getHeaders()
Specified by:
getHeaders in interface Message

setHeaders

public void setHeaders(java.util.Map headers)
Specified by:
setHeaders in interface Message

getPriority

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

setPriority

public void setPriority(byte priority)
Specified by:
setPriority in interface Message

isReference

public boolean isReference()

getPayloadAsByteArray

public byte[] getPayloadAsByteArray()
Specified by:
getPayloadAsByteArray in interface Message

getPayload

public java.lang.Object getPayload()
Warning! Calling getPayload will cause the payload to be deserialized so should not be called on the server.

Specified by:
getPayload in interface Message

setPayload

public void setPayload(java.io.Serializable payload)

clearPayloadAsByteArray

protected void clearPayloadAsByteArray()

isPersisted

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

setPersisted

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

isExpired

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

equals

public boolean equals(java.lang.Object o)

hashCode

public int hashCode()

toString

public java.lang.String toString()

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

writePayload

protected void writePayload(java.io.DataOutputStream out,
                            java.lang.Object thePayload)
                     throws java.lang.Exception
Override this if you want more sophisticated payload externalization.

Throws:
java.lang.Exception - TODO

readPayload

protected java.lang.Object readPayload(java.io.DataInputStream in,
                                       int length)
                                throws java.lang.Exception
Override this if you want more sophisticated payload externalization.

Throws:
java.lang.Exception - TODO

copyPayloadAsByteArrayToPayload

protected final void copyPayloadAsByteArrayToPayload()
It makes sense to use this method only from within JBossBytesMessage (optimization). Using it from anywhere else will lead to corrupted data.



Copyright © 2006 JBoss Inc. All Rights Reserved.