org.mule.impl
Class MuleMessage

java.lang.Object
  extended byorg.mule.impl.MuleMessage
All Implemented Interfaces:
java.io.Serializable, UMOMessage, UMOMessageAdapter

public class MuleMessage
extends java.lang.Object
implements UMOMessage

MuleMessage is a wrapper that contains a payload payload and properties associated with the payload.

Version:
$Revision: 1.5 $
Author:
Ross Mason
See Also:
Serialized Form

Field Summary
protected  UMOExceptionPayload exceptionPayload
           
 
Constructor Summary
MuleMessage(java.lang.Object message, java.util.Map props)
           
MuleMessage(UMOMessageAdapter message)
           
 
Method Summary
 void addProperties(java.util.Map properties)
          Adds a map of properties to associated with this message
 void clearProperties()
          Removes all properties on this message
 UMOMessageAdapter getAdapter()
           
 boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
          Gets a boolean property from the event
 int getCorrelationGroupSize()
          Determines how many messages are in the correlation group
 java.lang.String getCorrelationId()
          Sets a correlationId for this message.
 int getCorrelationSequence()
          Gets the sequence or ordering number for this message in the the correlation group (as defined by the correlationId)
 double getDoubleProperty(java.lang.String name, double defaultValue)
          Gets a double property from the event
 UMOExceptionPayload getExceptionPayload()
          If an error occurred during the processing of this message this will return a ErrorPayload that contains the root exception and Mule error code, plus any otherr releated info
 int getIntProperty(java.lang.String name, int defaultValue)
          Gets an integer property from the event
 long getLongProperty(java.lang.String name, long defaultValue)
          Gets a long property from the event
 java.lang.Object getPayload()
           
 byte[] getPayloadAsBytes()
          Converts the payload implementation into a String representation
 java.lang.String getPayloadAsString()
          Converts the payload implementation into a String representation
 java.util.Map getProperties()
          Returns a map of all properties on this message
 java.lang.Object getProperty(java.lang.Object key)
          Gets a property of the payload implementation
 java.lang.Object getProperty(java.lang.String name, java.lang.Object defaultValue)
          Gets a property from the event
 java.util.Iterator getPropertyNames()
           
 java.lang.Object getReplyTo()
          Sets a replyTo address for this message.
 java.lang.String getUniqueId()
          gets the unique identifier for the message.
 java.lang.Object removeProperty(java.lang.Object key)
          Removes a property on this message
 void setBooleanProperty(java.lang.String name, boolean value)
          Sets a boolean property on the event
 void setCorrelationGroupSize(int size)
          Determines how many messages are in the correlation group
 void setCorrelationId(java.lang.String id)
          Sets a correlationId for this message.
 void setCorrelationSequence(int sequence)
          Gets the sequence or ordering number for this message in the the correlation group (as defined by the correlationId)
 void setDoubleProperty(java.lang.String name, double value)
          Sets a double property on the event
 void setExceptionPayload(UMOExceptionPayload exceptionPayload)
          If an error occurs while processing this message, a ErrorPayload is attached which contains the root exception and Mule error code, plus any otherr releated info
 void setIntProperty(java.lang.String name, int value)
          Sets a integerproperty on the event
 void setLongProperty(java.lang.String name, long value)
          Sets a long property on the event
 void setProperty(java.lang.Object key, java.lang.Object value)
          Gets a property of the payload implementation
 void setReplyTo(java.lang.Object replyTo)
          Sets a replyTo address for this message.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

exceptionPayload

protected UMOExceptionPayload exceptionPayload
Constructor Detail

MuleMessage

public MuleMessage(UMOMessageAdapter message)

MuleMessage

public MuleMessage(java.lang.Object message,
                   java.util.Map props)
Method Detail

getAdapter

public UMOMessageAdapter getAdapter()

getProperty

public java.lang.Object getProperty(java.lang.Object key)
Gets a property of the payload implementation

Specified by:
getProperty in interface UMOMessageAdapter
Parameters:
key - the key on which to lookup the property value
Returns:
the property value or null if the property does not exist

removeProperty

public java.lang.Object removeProperty(java.lang.Object key)
Description copied from interface: UMOMessageAdapter
Removes a property on this message

Specified by:
removeProperty in interface UMOMessageAdapter
Parameters:
key - the property key to remove
Returns:
the removed property value or null if the property did not exist

setProperty

public void setProperty(java.lang.Object key,
                        java.lang.Object value)
Gets a property of the payload implementation

Specified by:
setProperty in interface UMOMessageAdapter
Parameters:
key - the key on which to associate the value
value - the property value

getPayloadAsString

public java.lang.String getPayloadAsString()
                                    throws java.lang.Exception
Converts the payload implementation into a String representation

Specified by:
getPayloadAsString in interface UMOMessageAdapter
Returns:
String representation of the payload
Throws:
java.lang.Exception - Implemetation may throw an endpoint specific exception

getPropertyNames

public java.util.Iterator getPropertyNames()
Specified by:
getPropertyNames in interface UMOMessageAdapter
Returns:
all properties on this payload

getPayloadAsBytes

public byte[] getPayloadAsBytes()
                         throws java.lang.Exception
Converts the payload implementation into a String representation

Specified by:
getPayloadAsBytes in interface UMOMessageAdapter
Returns:
String representation of the payload
Throws:
java.lang.Exception - Implemetation may throw an endpoint specific exception

getPayload

public java.lang.Object getPayload()
Specified by:
getPayload in interface UMOMessageAdapter
Returns:
the current payload

addProperties

public void addProperties(java.util.Map properties)
Description copied from interface: UMOMessage
Adds a map of properties to associated with this message

Specified by:
addProperties in interface UMOMessage
Parameters:
properties - the properties add to this message

getProperties

public java.util.Map getProperties()
Description copied from interface: UMOMessage
Returns a map of all properties on this message

Specified by:
getProperties in interface UMOMessage
Returns:
a map of all properties on this message

clearProperties

public void clearProperties()
Description copied from interface: UMOMessage
Removes all properties on this message

Specified by:
clearProperties in interface UMOMessage

getDoubleProperty

public double getDoubleProperty(java.lang.String name,
                                double defaultValue)
Gets a double property from the event

Specified by:
getDoubleProperty in interface UMOMessageAdapter
Parameters:
name - the name or key of the property
defaultValue - a default value if the property doesn't exist in the event
Returns:
the property value or the defaultValue if the property does not exist

setDoubleProperty

public void setDoubleProperty(java.lang.String name,
                              double value)
Sets a double property on the event

Specified by:
setDoubleProperty in interface UMOMessageAdapter
Parameters:
name - the property name or key
value - the property value

getUniqueId

public java.lang.String getUniqueId()
                             throws UniqueIdNotSupportedException
Description copied from interface: UMOMessageAdapter
gets the unique identifier for the message. It's up to the implementation to ensure a unique id

Specified by:
getUniqueId in interface UMOMessageAdapter
Returns:
a unique message id
Throws:
UniqueIdNotSupportedException - if the message does not support a unique identifier

getProperty

public java.lang.Object getProperty(java.lang.String name,
                                    java.lang.Object defaultValue)
Description copied from interface: UMOMessageAdapter
Gets a property from the event

Specified by:
getProperty in interface UMOMessageAdapter
Parameters:
name - the name or key of the property
defaultValue - a default value if the property doesn't exist in the event
Returns:
the property value or the defaultValue if the property does not exist

getIntProperty

public int getIntProperty(java.lang.String name,
                          int defaultValue)
Description copied from interface: UMOMessageAdapter
Gets an integer property from the event

Specified by:
getIntProperty in interface UMOMessageAdapter
Parameters:
name - the name or key of the property
defaultValue - a default value if the property doesn't exist in the event
Returns:
the property value or the defaultValue if the property does not exist

getLongProperty

public long getLongProperty(java.lang.String name,
                            long defaultValue)
Description copied from interface: UMOMessageAdapter
Gets a long property from the event

Specified by:
getLongProperty in interface UMOMessageAdapter
Parameters:
name - the name or key of the property
defaultValue - a default value if the property doesn't exist in the event
Returns:
the property value or the defaultValue if the property does not exist

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name,
                                  boolean defaultValue)
Description copied from interface: UMOMessageAdapter
Gets a boolean property from the event

Specified by:
getBooleanProperty in interface UMOMessageAdapter
Parameters:
name - the name or key of the property
defaultValue - a default value if the property doesn't exist in the event
Returns:
the property value or the defaultValue if the property does not exist

setBooleanProperty

public void setBooleanProperty(java.lang.String name,
                               boolean value)
Description copied from interface: UMOMessageAdapter
Sets a boolean property on the event

Specified by:
setBooleanProperty in interface UMOMessageAdapter
Parameters:
name - the property name or key
value - the property value

setIntProperty

public void setIntProperty(java.lang.String name,
                           int value)
Description copied from interface: UMOMessageAdapter
Sets a integerproperty on the event

Specified by:
setIntProperty in interface UMOMessageAdapter
Parameters:
name - the property name or key
value - the property value

setLongProperty

public void setLongProperty(java.lang.String name,
                            long value)
Description copied from interface: UMOMessageAdapter
Sets a long property on the event

Specified by:
setLongProperty in interface UMOMessageAdapter
Parameters:
name - the property name or key
value - the property value

setCorrelationId

public void setCorrelationId(java.lang.String id)
Sets a correlationId for this message. The correlation Id can be used by components in the system to manage message relations

transport protocol. As such not all messages will support the notion of a correlationId i.e. tcp or file. In this situation the correlation Id is set as a property of the message where it's up to developer to keep the association with the message. For example if the message is serialised to xml the correlationId will be available in the message.

Specified by:
setCorrelationId in interface UMOMessageAdapter
Parameters:
id - the Id reference for this relationship

getCorrelationId

public java.lang.String getCorrelationId()
Sets a correlationId for this message. The correlation Id can be used by components in the system to manage message relations.

The correlationId is associated with the message using the underlying transport protocol. As such not all messages will support the notion of a correlationId i.e. tcp or file. In this situation the correlation Id is set as a property of the message where it's up to developer to keep the association with the message. For example if the message is serialised to xml the correlationId will be available in the message.

Specified by:
getCorrelationId in interface UMOMessageAdapter
Returns:
the correlationId for this message or null if one hasn't been set

setReplyTo

public void setReplyTo(java.lang.Object replyTo)
Sets a replyTo address for this message. This is useful in an asynchronous environment where the caller doesn't wait for a response and the response needs to be routed somewhere for further processing. The value of this field can be any valid endpointUri url.

Specified by:
setReplyTo in interface UMOMessageAdapter
Parameters:
replyTo - the endpointUri url to reply to

getReplyTo

public java.lang.Object getReplyTo()
Sets a replyTo address for this message. This is useful in an asynchronous environment where the caller doesn't wait for a response and the response needs to be routed somewhere for further processing. The value of this field can be any valid endpointUri url.

Specified by:
getReplyTo in interface UMOMessageAdapter
Returns:
the endpointUri url to reply to or null if one has not been set

getCorrelationSequence

public int getCorrelationSequence()
Gets the sequence or ordering number for this message in the the correlation group (as defined by the correlationId)

Specified by:
getCorrelationSequence in interface UMOMessageAdapter
Returns:
the sequence number or -1 if the sequence is not important

setCorrelationSequence

public void setCorrelationSequence(int sequence)
Gets the sequence or ordering number for this message in the the correlation group (as defined by the correlationId)

Specified by:
setCorrelationSequence in interface UMOMessageAdapter
Parameters:
sequence - the sequence number or -1 if the sequence is not important

getCorrelationGroupSize

public int getCorrelationGroupSize()
Determines how many messages are in the correlation group

Specified by:
getCorrelationGroupSize in interface UMOMessageAdapter
Returns:
total messages in this group or -1 if the size is not known

setCorrelationGroupSize

public void setCorrelationGroupSize(int size)
Determines how many messages are in the correlation group

Specified by:
setCorrelationGroupSize in interface UMOMessageAdapter
Parameters:
size - the total messages in this group or -1 if the size is not known

getExceptionPayload

public UMOExceptionPayload getExceptionPayload()
Description copied from interface: UMOMessageAdapter
If an error occurred during the processing of this message this will return a ErrorPayload that contains the root exception and Mule error code, plus any otherr releated info

Specified by:
getExceptionPayload in interface UMOMessageAdapter
Returns:

setExceptionPayload

public void setExceptionPayload(UMOExceptionPayload exceptionPayload)
Description copied from interface: UMOMessageAdapter
If an error occurs while processing this message, a ErrorPayload is attached which contains the root exception and Mule error code, plus any otherr releated info

Specified by:
setExceptionPayload in interface UMOMessageAdapter
Parameters:
exceptionPayload - The exception payloaad to attach to this message

toString

public java.lang.String toString()


Copyright © 2003-2005 SymphonySoft Limited. All Rights Reserved.