org.objectweb.joram.shared.messages
Class Message

java.lang.Object
  extended by org.objectweb.joram.shared.messages.Message
All Implemented Interfaces:
Streamable, java.io.Serializable, java.lang.Cloneable

public final class Message
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, Streamable

Implements the Message data structure.

See Also:
Serialized Form

Field Summary
static int ADMIN
          A admin message carries a streamable object.
 byte[] body
          Body of the message.
static int BYTES
          A bytes message carries an array of bytes.
 java.lang.String correlationId
          The correlation identifier field.
static int DEFAULT_DELIVERY_MODE
           
static int DEFAULT_PRIORITY
           
static long DEFAULT_TIME_TO_LIVE
           
 int deliveryCount
          The number of delivery attempts for this message.
 long expiration
          The message expiration time, by default 0 for infinite time-to-live.
 java.lang.String id
          The message identifier.
static org.objectweb.util.monolog.api.Logger logger
          logger
static int MAP
          A map message carries an hashtable.
static int NON_PERSISTENT
           
static int OBJECT
          An object message carries a serializable object.
 Properties optionalHeader
          Table holding header fields that may be required by particular clients (such as JMS clients).
 boolean persistent
          true if the message must be persisted.
static int PERSISTENT
           
static int persistentFlag
           
 int priority
          The message priority from 0 to 9, 9 being the highest.
 Properties properties
          The message properties table.
 boolean redelivered
          true if the message has been denied at least once by a consumer.
static int redeliveredFlag
           
 java.lang.String replyToId
          The reply to destination identifier.
 byte replyToType
          true if the "reply to" destination is a queue.
static int SIMPLE
          A simple message carries an empty body.
static int STREAM
          A stream message carries a bytes stream.
static int TEXT
          A text message carries a String body.
 long timestamp
          The message time stamp.
 java.lang.String toId
          The message destination identifier.
 byte toType
          The message destination type.
 int type
          The client message type: SIMPLE, TEXT, OBJECT, MAP, STREAM, BYTES, ADMIN.
 
Constructor Summary
Message()
          Constructs a bright new Message.
 
Method Summary
 java.lang.Object clone()
          Clones the message.
 AbstractAdminMessage getAdminMessage()
          Returns the AbstractAdminMessage body of the message.
 java.io.Serializable getObject()
          Returns the object body of the message.
 java.lang.Object getOptionalHeader(java.lang.String name)
          Returns an optional header field value.
 java.lang.Object getProperty(java.lang.String name)
          Returns a property as an object.
 java.lang.String getText()
          Returns the text body of the message.
 void readFrom(java.io.InputStream is)
          The object implements the readFrom method to restore its contents from the input stream.
 void readHeaderFrom(java.io.InputStream is)
           
static java.util.Vector readVectorFrom(java.io.InputStream is)
          this method allows to read from the input stream a vector of messages.
 void setAdminMessage(AbstractAdminMessage adminMsg)
          Sets an AbstractAdminMessage as the body of the message.
 void setDestination(java.lang.String id, byte type)
          Sets the message destination.
 void setObject(java.io.Serializable object)
          Sets an object as the body of the message.
 void setOptionalHeader(java.lang.String name, java.lang.Object value)
          Sets an optional header field value.
 void setProperty(java.lang.String name, java.lang.Object value)
          Sets a property value.
 void setReplyTo(java.lang.String id, byte type)
          Sets the destination to which a reply should be sent.
 void setText(java.lang.String text)
          Sets a String as the body of the message.
 java.util.Hashtable soapCode()
           
static Message soapDecode(java.util.Hashtable h)
           
 java.lang.String toString()
           
 void toString(java.lang.StringBuffer strbuf)
           
 void writeHeaderTo(java.io.OutputStream os)
           
 void writeTo(java.io.OutputStream os)
          The object implements the writeTo method to write its contents to the output stream.
static void writeVectorTo(java.util.Vector messages, java.io.OutputStream os)
          this method allows to write to the output stream a vector of message.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NON_PERSISTENT

public static final int NON_PERSISTENT
See Also:
Constant Field Values

PERSISTENT

public static final int PERSISTENT
See Also:
Constant Field Values

DEFAULT_DELIVERY_MODE

public static final int DEFAULT_DELIVERY_MODE
See Also:
Constant Field Values

DEFAULT_PRIORITY

public static final int DEFAULT_PRIORITY
See Also:
Constant Field Values

DEFAULT_TIME_TO_LIVE

public static final long DEFAULT_TIME_TO_LIVE
See Also:
Constant Field Values

logger

public static org.objectweb.util.monolog.api.Logger logger
logger


optionalHeader

public transient Properties optionalHeader
Table holding header fields that may be required by particular clients (such as JMS clients).


body

public transient byte[] body
Body of the message.


properties

public transient Properties properties
The message properties table.


id

public transient java.lang.String id
The message identifier.


persistent

public transient boolean persistent
true if the message must be persisted.


SIMPLE

public static final int SIMPLE
A simple message carries an empty body.

See Also:
Constant Field Values

TEXT

public static final int TEXT
A text message carries a String body.

See Also:
Constant Field Values

OBJECT

public static final int OBJECT
An object message carries a serializable object.

See Also:
Constant Field Values

MAP

public static final int MAP
A map message carries an hashtable.

See Also:
Constant Field Values

STREAM

public static final int STREAM
A stream message carries a bytes stream.

See Also:
Constant Field Values

BYTES

public static final int BYTES
A bytes message carries an array of bytes.

See Also:
Constant Field Values

ADMIN

public static final int ADMIN
A admin message carries a streamable object.

See Also:
Constant Field Values

type

public transient int type
The client message type: SIMPLE, TEXT, OBJECT, MAP, STREAM, BYTES, ADMIN. By default, the message type is SIMPLE.


priority

public transient int priority
The message priority from 0 to 9, 9 being the highest. By default, the priority is 4?


expiration

public transient long expiration
The message expiration time, by default 0 for infinite time-to-live.


timestamp

public transient long timestamp
The message time stamp.


redelivered

public transient boolean redelivered
true if the message has been denied at least once by a consumer.


toId

public transient java.lang.String toId
The message destination identifier.


toType

public transient byte toType
The message destination type.


replyToId

public transient java.lang.String replyToId
The reply to destination identifier.


replyToType

public transient byte replyToType
true if the "reply to" destination is a queue.


correlationId

public transient java.lang.String correlationId
The correlation identifier field.


deliveryCount

public transient int deliveryCount
The number of delivery attempts for this message.


redeliveredFlag

public static int redeliveredFlag

persistentFlag

public static int persistentFlag
Constructor Detail

Message

public Message()
Constructs a bright new Message.

Method Detail

getOptionalHeader

public java.lang.Object getOptionalHeader(java.lang.String name)
Returns an optional header field value.

Parameters:
name - The header field name.

setOptionalHeader

public void setOptionalHeader(java.lang.String name,
                              java.lang.Object value)
Sets an optional header field value.

Parameters:
name - The header field name.
value - The corresponding value.

getProperty

public java.lang.Object getProperty(java.lang.String name)
Returns a property as an object.

Parameters:
name - The property name.

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Sets a property value. If the value is not a Java primitive object its string representation is used.

Parameters:
name - The property name.
value - The property value.
Throws:
java.lang.IllegalArgumentException - If the key name is illegal (null or empty string).

setDestination

public final void setDestination(java.lang.String id,
                                 byte type)
Sets the message destination.

Parameters:
id - The destination identifier.
type - The type of the destination.

setReplyTo

public final void setReplyTo(java.lang.String id,
                             byte type)
Sets the destination to which a reply should be sent.

Parameters:
id - The destination identifier.
type - The destination type.

setText

public void setText(java.lang.String text)
Sets a String as the body of the message.


getText

public java.lang.String getText()
Returns the text body of the message.


setObject

public void setObject(java.io.Serializable object)
               throws java.io.IOException
Sets an object as the body of the message.

Throws:
java.io.IOException - In case of an error while setting the object.

getObject

public java.io.Serializable getObject()
                               throws java.lang.Exception
Returns the object body of the message.

Throws:
java.lang.Exception - In case of an error while getting the object.

setAdminMessage

public void setAdminMessage(AbstractAdminMessage adminMsg)
                     throws java.io.IOException
Sets an AbstractAdminMessage as the body of the message.

Throws:
java.io.IOException - In case of an error while setting the object.

getAdminMessage

public AbstractAdminMessage getAdminMessage()
Returns the AbstractAdminMessage body of the message.

Throws:
java.io.IOException - In case of an error while getting the object.
java.lang.ClassNotFoundException - If the object class is unknown.

toString

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

toString

public void toString(java.lang.StringBuffer strbuf)

clone

public java.lang.Object clone()
Clones the message.

Overrides:
clone in class java.lang.Object

soapCode

public java.util.Hashtable soapCode()

soapDecode

public static Message soapDecode(java.util.Hashtable h)

writeTo

public void writeTo(java.io.OutputStream os)
             throws java.io.IOException
The object implements the writeTo method to write its contents to the output stream.

Specified by:
writeTo in interface Streamable
Parameters:
os - the stream to write the object to
Throws:
java.io.IOException

writeHeaderTo

public void writeHeaderTo(java.io.OutputStream os)
                   throws java.io.IOException
Throws:
java.io.IOException

readFrom

public void readFrom(java.io.InputStream is)
              throws java.io.IOException
The object implements the readFrom method to restore its contents from the input stream.

Specified by:
readFrom in interface Streamable
Parameters:
is - the stream to read data from in order to restore the object
Throws:
java.io.IOException

readHeaderFrom

public void readHeaderFrom(java.io.InputStream is)
                    throws java.io.IOException
Throws:
java.io.IOException

writeVectorTo

public static void writeVectorTo(java.util.Vector messages,
                                 java.io.OutputStream os)
                          throws java.io.IOException
this method allows to write to the output stream a vector of message.

Parameters:
messages - the vector of messages
os - the stream to write the vector to
Throws:
java.io.IOException

readVectorFrom

public static java.util.Vector readVectorFrom(java.io.InputStream is)
                                       throws java.io.IOException
this method allows to read from the input stream a vector of messages.

Parameters:
is - the stream to read data from in order to restore the vector
Returns:
the vector of messages
Throws:
java.io.IOException


Copyright © 2011 ScalAgent D.T.. All Rights Reserved.