org.mule.providers
Class AbstractMessageAdapter

java.lang.Object
  extended byorg.mule.providers.AbstractMessageAdapter
All Implemented Interfaces:
java.io.Serializable, UMOMessageAdapter
Direct Known Subclasses:
AxisMessageAdapter, BaseMessage, DefaultMessageAdapter, FileContentsMessageAdapter, FileMessageAdapter, GlueMessageAdapter, HttpMessageAdapter, JdbcMessageAdapter, JmsMessageAdapter, MailMessageAdapter, StreamMessageAdapter, TcpMessageAdapter, UdpMessageAdapter, VMMessageAdapter, WriterMessageAdapter, XmppMessageAdapter

public abstract class AbstractMessageAdapter
extends java.lang.Object
implements UMOMessageAdapter

AbstractMessageAdapter provides a base implementation for simple message types that maybe don't normally allow for meta information, such as File or tcp.

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

Field Summary
protected  java.util.Map properties
           
 
Constructor Summary
AbstractMessageAdapter()
           
 
Method Summary
 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
 int getErrorCode()
          If an error occurred during the processing of this message this will return a value greater than zero
 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 getProperty(java.lang.Object key)
          Gets a property of the message 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 an associated property from the 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 correlationId)
          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 setErrorCode(int code)
          If an error occurs while processing this message, this error code should be set to a value greater than zero and the palyoad of the this message should contain the error details
 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)
          Set a property on the message
 void setReplyTo(java.lang.Object replyTo)
          Sets a replyTo address for this message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.umo.provider.UMOMessageAdapter
getPayload, getPayloadAsBytes, getPayloadAsString
 

Field Detail

properties

protected java.util.Map properties
Constructor Detail

AbstractMessageAdapter

public AbstractMessageAdapter()
Method Detail

removeProperty

public java.lang.Object removeProperty(java.lang.Object key)
Removes an associated property from the message

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

getProperty

public java.lang.Object getProperty(java.lang.Object key)
Description copied from interface: UMOMessageAdapter
Gets a property of the message 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

getPropertyNames

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

setProperty

public void setProperty(java.lang.Object key,
                        java.lang.Object value)
Description copied from interface: UMOMessageAdapter
Set a property on the message

Specified by:
setProperty in interface UMOMessageAdapter
Parameters:
key - the key on which to associate the value
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

getDoubleProperty

public double getDoubleProperty(java.lang.String name,
                                double defaultValue)
Description copied from interface: UMOMessageAdapter
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

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

setDoubleProperty

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

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

getReplyTo

public java.lang.Object getReplyTo()
Description copied from interface: UMOMessageAdapter
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

setReplyTo

public void setReplyTo(java.lang.Object replyTo)
Description copied from interface: UMOMessageAdapter
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

getCorrelationId

public java.lang.String getCorrelationId()
Description copied from interface: UMOMessageAdapter
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

setCorrelationId

public void setCorrelationId(java.lang.String correlationId)
Description copied from interface: UMOMessageAdapter
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:
correlationId - the Id reference for this relationship

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

getErrorCode

public int getErrorCode()
If an error occurred during the processing of this message this will return a value greater than zero

Specified by:
getErrorCode in interface UMOMessageAdapter
Returns:

setErrorCode

public void setErrorCode(int code)
If an error occurs while processing this message, this error code should be set to a value greater than zero and the palyoad of the this message should contain the error details

Specified by:
setErrorCode in interface UMOMessageAdapter
Parameters:
code -


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