org.mule.providers
Class DefaultMessageAdapter

java.lang.Object
  extended by org.mule.providers.AbstractMessageAdapter
      extended by org.mule.providers.DefaultMessageAdapter
All Implemented Interfaces:
Serializable, ThreadSafeAccess, UMOMessageAdapter

public class DefaultMessageAdapter
extends AbstractMessageAdapter

DefaultMessageAdapter can be used to wrap an arbitary object where no special 'apapting' is needed. The adapter allows for a set of properties to be associated with an object.

See Also:
Serialized Form

Field Summary
protected  Object message
          The message object wrapped by this adapter
 
Fields inherited from class org.mule.providers.AbstractMessageAdapter
attachments, DEFAULT_FAILFAST, encoding, exceptionPayload, id, logger, properties, READ, WRITE
 
Constructor Summary
DefaultMessageAdapter(Object message)
          Creates a default message adapter with properties and attachments
DefaultMessageAdapter(Object message, Map properties, Map attachments)
          Creates a default message adapter with properties and attachments
DefaultMessageAdapter(Object message, UMOMessageAdapter previous)
           
 
Method Summary
 Object getPayload()
           
 byte[] getPayloadAsBytes()
          Converts the message implementation into a String representation
 String getPayloadAsString(String encoding)
          Converts the message implementation into a String representation
 String getUniqueId()
          gets the unique identifier for the message.
 ThreadSafeAccess newThreadCopy()
          By default we return "this".
 
Methods inherited from class org.mule.providers.AbstractMessageAdapter
addAttachment, addProperties, assertAccess, clearProperties, convertToBytes, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getPayloadAsString, getProperty, getProperty, getPropertyNames, getReplyTo, getStringProperty, isDisabled, newException, removeAttachment, removeProperty, resetAccessControl, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setProperty, setReplyTo, setStringProperty, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

message

protected Object message
The message object wrapped by this adapter

Constructor Detail

DefaultMessageAdapter

public DefaultMessageAdapter(Object message)
Creates a default message adapter with properties and attachments

Parameters:
message - the message to wrap. If this is null and NullPayload object will be used
See Also:
NullPayload

DefaultMessageAdapter

public DefaultMessageAdapter(Object message,
                             UMOMessageAdapter previous)

DefaultMessageAdapter

public DefaultMessageAdapter(Object message,
                             Map properties,
                             Map attachments)
Creates a default message adapter with properties and attachments

Parameters:
message - the message to wrap. If this is null and NullPayload object will be used
properties - a map properties to set on the adapter. Can be null.
attachments - a map attaches (DataHandler objects) to set on the adapter. Can be null.
See Also:
NullPayload, DataHandler
Method Detail

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

getPayloadAsBytes

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

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

getPayload

public Object getPayload()
Returns:
the current message

getUniqueId

public String getUniqueId()
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
Overrides:
getUniqueId in class AbstractMessageAdapter
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.

newThreadCopy

public ThreadSafeAccess newThreadCopy()
Description copied from class: AbstractMessageAdapter
By default we return "this". This allows older code to inter-operate but doesn't, of course, give the required safety. Subclasses should override this method. Re-writing the threading handling should remove this requirement....

Specified by:
newThreadCopy in interface ThreadSafeAccess
Overrides:
newThreadCopy in class AbstractMessageAdapter
Returns:
A new copy of this


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