org.mule.umo.provider
Interface UMOMessageAdapter

All Superinterfaces:
Serializable
All Known Subinterfaces:
UMOMessage, UMOStreamMessageAdapter
All Known Implementing Classes:
AbstractMessageAdapter, MuleMessage, StreamMessageAdapter, TestConnector.DummyMessageAdapter

public interface UMOMessageAdapter
extends Serializable

UMOMessageAdapter provides a common abstraction of different message implementations provided by different underlying technologies.


Method Summary
 void addAttachment(String name, DataHandler dataHandler)
           
 void addProperties(Map properties)
          Adds a map of properties to be associated with this message
 void clearProperties()
          Removes all properties on this message
 DataHandler getAttachment(String name)
           
 Set getAttachmentNames()
           
 boolean getBooleanProperty(String name, boolean defaultValue)
          Gets a boolean property from the event
 int getCorrelationGroupSize()
          Determines how many messages are in the correlation group
 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(String name, double defaultValue)
          Gets a double property from the event
 String getEncoding()
          Gets the encoding for the current message.
 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 other releated info
 int getIntProperty(String name, int defaultValue)
          Gets an integer property from the event
 long getLongProperty(String name, long defaultValue)
          Gets a long property from the event
 Object getPayload()
           
 byte[] getPayloadAsBytes()
          Converts the message implementation into a byte array representation
 String getPayloadAsString()
          Converts the message implementation into a String representation.
 String getPayloadAsString(String encoding)
          Converts the message implementation into a String representation
 Object getProperty(String key)
          Gets a property of the message implementation
 Object getProperty(String name, Object defaultValue)
          Gets a property from the event
 Set getPropertyNames()
           
 Object getReplyTo()
          Returns a replyTo address for this message.
 String getStringProperty(String name, String defaultValue)
          Gets a String property from the event
 String getUniqueId()
          gets the unique identifier for the message.
 void removeAttachment(String name)
           
 Object removeProperty(String key)
          Removes a property on this message
 void setBooleanProperty(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(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(String name, double value)
          Sets a double property on the event
 void setEncoding(String encoding)
          Sets the encoding for this message
 void setExceptionPayload(UMOExceptionPayload payload)
          If an error occurs while processing this message, a ErrorPayload is attached which contains the root exception and Mule error code, plus any other releated info
 void setIntProperty(String name, int value)
          Sets a integerproperty on the event
 void setLongProperty(String name, long value)
          Sets a long property on the event
 void setProperty(String key, Object value)
          Set a property on the message
 void setReplyTo(Object replyTo)
          Sets a replyTo address for this message.
 void setStringProperty(String name, String value)
          Sets a String property on the event
 

Method Detail

addProperties

public void addProperties(Map properties)
Adds a map of properties to be associated with this message

Parameters:
properties - the properties add to this message

clearProperties

public void clearProperties()
Removes all properties on this message


getProperty

public Object getProperty(String key)
Gets a property of the message implementation

Parameters:
key - the key on which to lookup the property value
Returns:
the property value or null if the property does not exist

setProperty

public void setProperty(String key,
                        Object value)
Set a property on the message

Parameters:
key - the key on which to associate the value
value - the property value

removeProperty

public Object removeProperty(String key)
Removes a property on this message

Parameters:
key - the property key to remove
Returns:
the removed property value or null if the property did not exist

getPayloadAsString

public String getPayloadAsString(String encoding)
                          throws Exception
Converts the message implementation into a String representation

Parameters:
encoding - The encoding to use when transforming the message (if necessary). The parameter is used when converting from a byte array
Returns:
String representation of the message payload
Throws:
Exception - Implementation may throw an endpoint specific exception

getPayloadAsString

public String getPayloadAsString()
                          throws Exception
Converts the message implementation into a String representation. If encoding is required it will use the encoding set on the message

Returns:
String representation of the message payload
Throws:
Exception - Implementation may throw an endpoint specific exception

getPropertyNames

public Set getPropertyNames()
Returns:
all property keys on this message

getPayloadAsBytes

public byte[] getPayloadAsBytes()
                         throws Exception
Converts the message implementation into a byte array representation

Returns:
byte array of the message
Throws:
Exception - Implemetation may throw an endpoint specific exception

getPayload

public Object getPayload()
Returns:
the current message

getUniqueId

public String getUniqueId()
gets the unique identifier for the message. It's up to the implementation to ensure a unique id

Returns:
a unique message id. The Id should never be null. If the underlying transport does not have the notion of a message Id, one shuold be generated. The generated Id should be a UUID.

getProperty

public Object getProperty(String name,
                          Object defaultValue)
Gets a property from the event

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(String name,
                          int defaultValue)
Gets an integer property from the event

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(String name,
                            long defaultValue)
Gets a long property from the event

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

getDoubleProperty

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

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(String name,
                                  boolean defaultValue)
Gets a boolean property from the event

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(String name,
                               boolean value)
Sets a boolean property on the event

Parameters:
name - the property name or key
value - the property value

setIntProperty

public void setIntProperty(String name,
                           int value)
Sets a integerproperty on the event

Parameters:
name - the property name or key
value - the property value

setLongProperty

public void setLongProperty(String name,
                            long value)
Sets a long property on the event

Parameters:
name - the property name or key
value - the property value

setDoubleProperty

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

Parameters:
name - the property name or key
value - the property value

getStringProperty

public String getStringProperty(String name,
                                String defaultValue)
Gets a String property from the event

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

setStringProperty

public void setStringProperty(String name,
                              String value)
Sets a String property on the event

Parameters:
name - the property name or key
value - the property value

setCorrelationId

public void setCorrelationId(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.

Parameters:
id - the Id reference for this relationship

getCorrelationId

public 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.

Returns:
the correlationId for this message or null if one hasn't 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)

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)

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

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

Parameters:
size - the total messages in this group or -1 if the size is not known

setReplyTo

public void setReplyTo(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.

Parameters:
replyTo - the endpointUri url to reply to

getReplyTo

public Object getReplyTo()
Returns 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.

Returns:
the endpointUri url to reply to or null if one has not been set

getExceptionPayload

public 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 other releated info

Returns:
The exception payload (if any) attached to this message

setExceptionPayload

public void setExceptionPayload(UMOExceptionPayload payload)
If an error occurs while processing this message, a ErrorPayload is attached which contains the root exception and Mule error code, plus any other releated info

Parameters:
payload - The exception payloaad to attach to this message

addAttachment

public void addAttachment(String name,
                          DataHandler dataHandler)
                   throws Exception
Throws:
Exception

removeAttachment

public void removeAttachment(String name)
                      throws Exception
Throws:
Exception

getAttachment

public DataHandler getAttachment(String name)

getAttachmentNames

public Set getAttachmentNames()

getEncoding

public String getEncoding()
Gets the encoding for the current message. For potocols that send encoding information with the message, this method should be overriden to expose the transport encoding, otherwise the default encoding in the Mule configuration will be used.

Returns:
the encoding for this message. This method must never return null

setEncoding

public void setEncoding(String encoding)
Sets the encoding for this message

Parameters:
encoding - the encoding to use


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.