Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule
Class DefaultMuleMessage

    java.lang.Object
      org.mule.DefaultMuleMessage

All Implemented Interfaces:
  Serializable, MuleMessage, ThreadSafeAccess, DeserializationPostInitialisable

Direct Known Subclasses:
  DefaultMessageCollection

    public class DefaultMuleMessage

extends Object
implements MuleMessage, ThreadSafeAccess, DeserializationPostInitialisable

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

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface org.mule.api.ThreadSafeAccess
`ThreadSafeAccess.AccessControl`

Nested classes/interfaces inherited from interface org.mule.util.store.DeserializationPostInitialisable
`DeserializationPostInitialisable.Implementation`

Field Summary
`protected MuleContext` | `muleContext`
`protected static String` | `NOT_SET`

Fields inherited from interface org.mule.api.ThreadSafeAccess
`READ, WRITE`

Constructor Summary
`DefaultMuleMessage(MuleMessage message)`
`DefaultMuleMessage(Object message, Map<String,Object> outboundProperties, Map<String,DataHandler> attachments, MuleContext muleContext)`
`DefaultMuleMessage(Object message, Map<String,Object> inboundProperties, Map<String,Object> outboundProperties, Map<String,DataHandler> attachments, MuleContext muleContext)`
`DefaultMuleMessage(Object message, Map<String,Object> outboundProperties, MuleContext muleContext)`
`DefaultMuleMessage(Object message, MuleContext muleContext)`
`DefaultMuleMessage(Object message, MuleMessage previous, MuleContext muleContext)`

Method Summary
`void` | `addAttachment(String name, DataHandler dataHandler)` Deprecated.
`void` | `addInboundAttachment(String name, DataHandler dataHandler)`
`void` | `addInboundProperties(Map<String,Object> props)`
`void` | `addOutboundAttachment(String name, DataHandler dataHandler)` Allows for arbitrary data attachments to be associated with the Message.
`void` | `addOutboundAttachment(String name, Object object, String contentType)` Adds an outgoing attachment to the message
`void` | `addProperties(Map<String,Object> props)` Adds a map of properties to be associated with this message
`void` | `addProperties(Map<String,Object> props, PropertyScope scope)` Adds a map of properties to be associated with this message
`protected void` | `applyAllTransformers(MuleEvent event, List<? extends Transformer> transformers)`
`void` | `applyTransformers(MuleEvent event, List<? extends Transformer> transformers)` Will apply a list of transformers to the payload of the message.
`void` | `applyTransformers(MuleEvent event, List<? extends Transformer> transformers, Class<?> outputType)` Will apply a list of transformers to the payload of the message.
`void` | `applyTransformers(MuleEvent event, Transformer... transformers)` Will apply a list of transformers to the payload of the message.
`void` | `assertAccess(boolean write)` This method may be called before data in the object are accessed.
`void` | `clearProperties()` Removes all properties on this message in the `PropertyScope.INVOCATION` and `PropertyScope.OUTBOUND`.
`void` | `clearProperties(PropertyScope scope)` Removes all properties on this message in the given scope.
`protected void` | `copyToInbound(DefaultMuleMessage newMessage)`
`MuleMessage` | `createInboundMessage()` Copy an inbound message to an outbound one, moving all message properties and attachments
`
`<T> T`
` | `findPropertyInAnyScope(String name, T defaultValue)` This method was added with the introduction of Property scopes.
`
`<T> T`
` | `findPropertyInSpecifiedScopes(String name, PropertyScope... scopesToSearch)` Find property in one of the specified scopes, in order
`DataHandler` | `getAttachment(String name)` Deprecated.
`Set<String>` | `getAttachmentNames()` Deprecated.
`boolean` | `getBooleanProperty(String name, boolean defaultValue)` Deprecated.
`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)
`DataType<?>` | `getDataType()` Returns the data type (if any) associated with the message's payload.
`double` | `getDoubleProperty(String name, double defaultValue)` Deprecated.
`String` | `getEncoding()` Gets the encoding for the current message.
`ExceptionPayload` | `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
`DataHandler` | `getInboundAttachment(String name)` Retrieve an attachment with the given name.
`Set<String>` | `getInboundAttachmentNames()`
`
`<T> T`
` | `getInboundProperty(String name)`
`
`<T> T`
` | `getInboundProperty(String name, T defaultValue)`
`Set<String>` | `getInboundPropertyNames()`
`int` | `getIntProperty(String name, int defaultValue)` Deprecated.
`
`<T> T`
` | `getInvocationProperty(String name)`
`
`<T> T`
` | `getInvocationProperty(String name, T defaultValue)`
`Set<String>` | `getInvocationPropertyNames()`
`long` | `getLongProperty(String name, long defaultValue)` Deprecated.
`MuleContext` | `getMuleContext()`
`Object` | `getOriginalPayload()` Returns the original payload used to create this message.
`DataHandler` | `getOutboundAttachment(String name)` Retrieve an attachment with the given name.
`Set<String>` | `getOutboundAttachmentNames()`
`
`<T> T`
` | `getOutboundProperty(String name)`
`
`<T> T`
` | `getOutboundProperty(String name, T defaultValue)`
`Set<String>` | `getOutboundPropertyNames()`
`Object` | `getPayload()`
`
`<T> T`
` | `getPayload(Class<T> outputType)` Will attempt to obtain the payload of this message with the desired Class type.
`
`<T> T`
` | `getPayload(DataType<T> outputType)` Will attempt to obtain the payload of this message with the desired Class type.
`protected
`<T> T`
` | `getPayload(DataType<T> resultType, String encoding)` Will attempt to obtain the payload of this message with the desired Class type.
`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
`String` | `getPayloadForLogging()` Get the message payload for logging without throwing exception Converts the message implementation into a String representation.
`String` | `getPayloadForLogging(String encoding)` Get the message payload for logging without throwing exception Converts the message implementation into a String representation.
`Object` | `getProperty(String key)` Deprecated.
`Object` | `getProperty(String name, Object defaultValue)` Gets a property from the message
`
`<T> T`
` | `getProperty(String name, PropertyScope scope)` Gets a property from the message with a given scope.
`
`<T> T`
` | `getProperty(String name, PropertyScope scope, T defaultValue)` Gets a property from the message with a given scope and provides a default value if the property is not present on the message in the scope specified.
`Set<String>` | `getPropertyNames()` Deprecated. use `getPropertyNames(org.mule.api.transport.PropertyScope)`
`Set<String>` | `getPropertyNames(PropertyScope scope)` Gets all property names in a given scope.
`Object` | `getReplyTo()` Returns a replyTo address for this message.
`
`<T> T`
` | `getSessionProperty(String name)`
`
`<T> T`
` | `getSessionProperty(String name, T defaultValue)`
`Set<String>` | `getSessionPropertyNames()`
`String` | `getStringProperty(String name, String defaultValue)` Deprecated.
`String` | `getUniqueId()` gets the unique identifier for the message.
`void` | `initAfterDeserialisation(MuleContext muleContext)` Invoked after deserialization.
`boolean` | `isConsumable()` Determines if the payload of this message is consumable i.e.
`protected boolean` | `isDisabled()`
`protected boolean` | `isPayloadConsumed(Class<?> inputCls)` Checks if the payload has been consumed for this message.
`protected IllegalStateException` | `newException(String message)`
`ThreadSafeAccess` | `newThreadCopy()`
`void` | `release()` Perform any clean up operations on the message resource.
`void` | `removeAttachment(String name)` Deprecated.
`void` | `removeOutboundAttachment(String name)` Remove an attachment form this message with the specified name
`Object` | `removeProperty(String key)` Removes a property on this message.
`Object` | `removeProperty(String key, PropertyScope scope)` Removes a property on this message from the specified scope only.
`void` | `resetAccessControl()` This method should ONLY be used in the construction of composite ThreadSafeAccess instances.
`void` | `setBooleanProperty(String name, boolean value)` Deprecated.
`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)
`protected void` | `setDataType(DataType<?> dt)`
`void` | `setDoubleProperty(String name, double value)` Deprecated.
`void` | `setEncoding(String encoding)` Sets the encoding for this message
`void` | `setExceptionPayload(ExceptionPayload exceptionPayload)` 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` | `setInboundProperty(String key, Object value)`
`void` | `setIntProperty(String name, int value)` Deprecated.
`void` | `setInvocationProperty(String key, Object value)`
`void` | `setLongProperty(String name, long value)` Deprecated.
`void` | `setMimeType(String mimeType)`
`void` | `setOutboundProperty(String key, Object value)`
`void` | `setPayload(Object payload)` Update the message payload.
`void` | `setProperty(String key, Object value)` Deprecated. use `setProperty(String, Object, org.mule.api.transport.PropertyScope)` or preferrably any of the scope-specific set methods.
`void` | `setProperty(String key, Object value, PropertyScope scope)` Set a property on the message.
`void` | `setReplyTo(Object replyTo)` Sets a replyTo address for this message.
`void` | `setSessionProperty(String key, Object value)`
`void` | `setStringProperty(String name, String value)` Deprecated.
`void` | `setUniqueId(String uid)`
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### NOT_SET

    protected static final String NOT_SET

See Also:
  Constant Field Values

### muleContext

    protected transient MuleContext muleContext

Constructor Detail

### DefaultMuleMessage

    public DefaultMuleMessage(Object message,
                              MuleContext muleContext)

### DefaultMuleMessage

    public DefaultMuleMessage(Object message,
                              Map<String,Object> outboundProperties,
                              MuleContext muleContext)

### DefaultMuleMessage

    public DefaultMuleMessage(Object message,
                              Map<String,Object> outboundProperties,
                              Map<String,DataHandler> attachments,
                              MuleContext muleContext)

### DefaultMuleMessage

    public DefaultMuleMessage(Object message,
                              Map<String,Object> inboundProperties,
                              Map<String,Object> outboundProperties,
                              Map<String,DataHandler> attachments,
                              MuleContext muleContext)

### DefaultMuleMessage

    public DefaultMuleMessage(Object message,
                              MuleMessage previous,
                              MuleContext muleContext)

### DefaultMuleMessage

    public DefaultMuleMessage(MuleMessage message)

Method Detail

### getPayload

    public <T> T getPayload(Class<T> outputType)
                 throws TransformerException

  Will attempt to obtain the payload of this message with the desired Class type. This will try and resolve a transformer that can do this transformation. If a transformer cannot be found an exception is thrown. Any transformers added to the registry will be checked for compatibility

  Specified by:
    `getPayload` in interface `MuleMessage`
  Parameters:
    `outputType` - the desired return type
  Returns:
    The converted payload of this message. Note that this method will not alter the payload of this message *unless* the payload is an InputStream in which case the stream will be read and the payload will become the fully read stream.
  Throws:
    `TransformerException` - if a transformer cannot be found or there is an error during transformation of the payload

### getPayload

    public <T> T getPayload(DataType<T> outputType)
                 throws TransformerException

  Will attempt to obtain the payload of this message with the desired Class type. This will try and resolve a transformer that can do this transformation. If a transformer cannot be found an exception is thrown. Any transformers added to the registry will be checked for compatability

  Specified by:
    `getPayload` in interface `MuleMessage`
  Parameters:
    `outputType` - the desired return type
  Returns:
    The converted payload of this message. Note that this method will not alter the payload of this message *unless* the payload is an InputStream in which case the stream will be read and the payload will become the fully read stream.
  Throws:
    `TransformerException` - if a transformer cannot be found or there is an error during transformation of the payload

### getMuleContext

    public MuleContext getMuleContext()

  Specified by:
    `getMuleContext` in interface `MuleMessage`

### getPayload

    protected <T> T getPayload(DataType<T> resultType,
                               String encoding)
                    throws TransformerException

  Will attempt to obtain the payload of this message with the desired Class type. This will try and resolve a transformer that can do this transformation. If a transformer cannot be found an exception is thrown. Any transformers added to the registry will be checked for compatability.

  Parameters:
    `resultType` - the desired return type
    `encoding` - the encoding to use if required
  Returns:
    The converted payload of this message. Note that this method will not alter the payload of this message unless the payload is an `InputStream` in which case the stream will be read and the payload will become the fully read stream.
  Throws:
    `TransformerException` - if a transformer cannot be found or there is an error during transformation of the payload.
  Since:
    3.0

### isPayloadConsumed

    protected boolean isPayloadConsumed(Class<?> inputCls)

  Checks if the payload has been consumed for this message. This only applies to Streaming payload types since once the stream has been read, the payload of the message should be updated to represent the data read from the stream

  Parameters:
    `inputCls` - the input type of the message payload
  Returns:
    true if the payload message type was stream-based, false otherwise

### getOriginalPayload

    public Object getOriginalPayload()

  Returns the original payload used to create this message. The payload of the message can change if `MuleMessage.applyTransformers(MuleEvent,java.util.List)` or `MuleMessage.applyTransformers(MuleEvent, java.util.List, Class)` is called.

  Specified by:
    `getOriginalPayload` in interface `MuleMessage`
  Returns:
    the original payload used to create this message

### setInboundProperty

    public void setInboundProperty(String key,
                                   Object value)

### setInvocationProperty

    public void setInvocationProperty(String key,
                                      Object value)

  Specified by:
    `setInvocationProperty` in interface `MuleMessage`
  See Also:
    `MuleMessage.setProperty(String, Object, org.mule.api.transport.PropertyScope)`

### setOutboundProperty

    public void setOutboundProperty(String key,
                                    Object value)

  Specified by:
    `setOutboundProperty` in interface `MuleMessage`
  See Also:
    `MuleMessage.setProperty(String, Object, org.mule.api.transport.PropertyScope)`

### setSessionProperty

    public void setSessionProperty(String key,
                                   Object value)

  Specified by:
    `setSessionProperty` in interface `MuleMessage`

### setProperty

    public void setProperty(String key,
                            Object value,
                            PropertyScope scope)

  Set a property on the message. End-users should prefer more scope-specific methods for readability. This one is more intended for programmatic scope manipulation and Mule internal use.

  Specified by:
    `setProperty` in interface `MuleMessage`
  Parameters:
    `key` - the key on which to associate the value
    `value` - the property value
    `scope` - The scope at which to set the property at
  See Also:
    `PropertyScope`, `MuleMessage.setInvocationProperty(String, Object)`, `MuleMessage.setOutboundProperty(String, Object)`, `MuleMessage.setSessionProperty(String, Object)`

### getProperty

    @Deprecated
    public Object getProperty(String key)

  Deprecated.

  /**

  Specified by:
    `getProperty` in interface `MuleMessage`
  See Also:
    `MuleMessage.getInboundProperty(String)`, `MuleMessage.getOutboundProperty(String)`, `MuleMessage.getInvocationProperty(String)`, `MuleMessage.getSessionProperty(String)`

### removeProperty

    public Object removeProperty(String key)

  Removes a property on this message.

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

### removeProperty

    public Object removeProperty(String key,
                                 PropertyScope scope)

  Removes a property on this message from the specified scope only.

  Specified by:
    `removeProperty` in interface `MuleMessage`
  Parameters:
    `key` - the property key to remove
    `scope` - The scope at which to set the property at
  Returns:
    the removed property value or null if the property did not exist

### setProperty

    @Deprecated
    public void setProperty(String key,
                                       Object value)

  Deprecated. use `setProperty(String, Object, org.mule.api.transport.PropertyScope)` or preferrably any of the scope-specific set methods.

  Set a property on the message. This method will now set a value on the outbound scope only.

  Specified by:
    `setProperty` in interface `MuleMessage`
  Parameters:
    `key` - the key on which to associate the value
    `value` - the property value
  See Also:
    `setInboundProperty(String, Object)`, `setInvocationProperty(String, Object)`, `setOutboundProperty(String, Object)`, `setSessionProperty(String, Object)`

### getPayloadAsString

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

  Specified by:
    `getPayloadAsString` in interface `MuleMessage`
  Returns:
    String representation of the message payload
  Throws:
    `Exception` - Implementation may throw an endpoint specific exception

### getPayloadForLogging

    public String getPayloadForLogging(String encoding)

  Get the message payload for logging without throwing exception Converts the message implementation into a String representation. If encoding is required it will use the encoding set on the message

  Specified by:
    `getPayloadForLogging` in interface `MuleMessage`
  Returns:
    message payload as object

### getPayloadForLogging

    public String getPayloadForLogging()

  Get the message payload for logging without throwing exception Converts the message implementation into a String representation.

  Specified by:
    `getPayloadForLogging` in interface `MuleMessage`
  Returns:
    message payload as object

### getPayloadAsBytes

    public byte[] getPayloadAsBytes()
                             throws Exception

  Converts the message implementation into a byte array representation

  Specified by:
    `getPayloadAsBytes` in interface `MuleMessage`
  Returns:
    byte array of the message
  Throws:
    `Exception` - Implemetation may throw an endpoint specific exception

### getPayloadAsString

    public String getPayloadAsString(String encoding)
                              throws Exception

  Converts the message implementation into a String representation

  Specified by:
    `getPayloadAsString` in interface `MuleMessage`
  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

### getPropertyNames

    @Deprecated
    public Set<String> getPropertyNames()

  Deprecated. use `getPropertyNames(org.mule.api.transport.PropertyScope)`

  Specified by:
    `getPropertyNames` in interface `MuleMessage`
  Returns:
    all property keys on this message.

### getPropertyNames

    public Set<String> getPropertyNames(PropertyScope scope)

  Gets all property names in a given scope. Prefer using one of the convenience scope-aware methods instead, this one is meant for internal access mostly.

  Specified by:
    `getPropertyNames` in interface `MuleMessage`
  Parameters:
    `scope` - the scope of property names
  Returns:
    all property keys on this message in the given scope
  See Also:
    `MuleMessage.getInvocationPropertyNames()`, `MuleMessage.getInboundPropertyNames()`, `MuleMessage.getOutboundPropertyNames()`, `MuleMessage.getSessionPropertyNames()`

### getInvocationPropertyNames

    public Set<String> getInvocationPropertyNames()

  Specified by:
    `getInvocationPropertyNames` in interface `MuleMessage`

### getInboundPropertyNames

    public Set<String> getInboundPropertyNames()

  Specified by:
    `getInboundPropertyNames` in interface `MuleMessage`

### getOutboundPropertyNames

    public Set<String> getOutboundPropertyNames()

  Specified by:
    `getOutboundPropertyNames` in interface `MuleMessage`

### getSessionPropertyNames

    public Set<String> getSessionPropertyNames()

  Specified by:
    `getSessionPropertyNames` in interface `MuleMessage`

### getUniqueId

    public String getUniqueId()

  gets the unique identifier for the message. It's up to the implementation to ensure a unique id

  Specified by:
    `getUniqueId` in interface `MuleMessage`
  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 should be generated. The generated Id should be a UUID.

### setUniqueId

    public void setUniqueId(String uid)

### getProperty

    public Object getProperty(String name,
                              Object defaultValue)

  Gets a property from the message

  Specified by:
    `getProperty` in interface `MuleMessage`
  Parameters:
    `name` - the name or key of the property. This must be non-null.
    `defaultValue` - a default value if the property doesn't exist in the event. This can be null.
  Returns:
    the property value or the defaultValue if the property does not exist
  See Also:
    `MuleMessage.getInboundProperty(String)`, `MuleMessage.getOutboundProperty(String)`, `MuleMessage.getInvocationProperty(String)`, `MuleMessage.getSessionProperty(String)`

### getProperty

    public <T> T getProperty(String name,
                             PropertyScope scope)

  Gets a property from the message with a given scope. End-users should prefer more scope-specific methods for readability. This one is more intended for programmatic scope manipulation and Mule internal use.

  Specified by:
    `getProperty` in interface `MuleMessage`
  Parameters:
    `name` - the name or key of the property. This must be non-null.
    `scope` - The scope of the property to retrieve. This must be non-null.
  Returns:
    the property value or null if the property does not exist in the specified scope
  See Also:
    `MuleMessage.getInboundProperty(String)`, `MuleMessage.getOutboundProperty(String)`, `MuleMessage.getInvocationProperty(String)`, `MuleMessage.getSessionProperty(String)`

### getInboundProperty

    public <T> T getInboundProperty(String name,
                                    T defaultValue)

  Specified by:
    `getInboundProperty` in interface `MuleMessage`
  See Also:
    `MuleMessage.getProperty(String, org.mule.api.transport.PropertyScope, Object)`

### getInboundProperty

    public <T> T getInboundProperty(String name)

  Specified by:
    `getInboundProperty` in interface `MuleMessage`
  See Also:
    `MuleMessage.getProperty(String, org.mule.api.transport.PropertyScope, Object)`

### getInvocationProperty

    public <T> T getInvocationProperty(String name,
                                       T defaultValue)

  Specified by:
    `getInvocationProperty` in interface `MuleMessage`
  See Also:
    `MuleMessage.getProperty(String, org.mule.api.transport.PropertyScope, Object)`

### getInvocationProperty

    public <T> T getInvocationProperty(String name)

  Specified by:
    `getInvocationProperty` in interface `MuleMessage`
  See Also:
    `MuleMessage.getProperty(String, org.mule.api.transport.PropertyScope, Object)`

### getOutboundProperty

    public <T> T getOutboundProperty(String name,
                                     T defaultValue)

  Specified by:
    `getOutboundProperty` in interface `MuleMessage`
  See Also:
    `MuleMessage.getProperty(String, org.mule.api.transport.PropertyScope, Object)`

### getOutboundProperty

    public <T> T getOutboundProperty(String name)

  Specified by:
    `getOutboundProperty` in interface `MuleMessage`
  See Also:
    `MuleMessage.getProperty(String, org.mule.api.transport.PropertyScope, Object)`

### getSessionProperty

    public <T> T getSessionProperty(String name,
                                    T defaultValue)

  Specified by:
    `getSessionProperty` in interface `MuleMessage`

### getSessionProperty

    public <T> T getSessionProperty(String name)

  Specified by:
    `getSessionProperty` in interface `MuleMessage`

### getProperty

    public <T> T getProperty(String name,
                             PropertyScope scope,
                             T defaultValue)

  Gets a property from the message with a given scope and provides a default value if the property is not present on the message in the scope specified. The method will also type check against the default value to ensure that the value is of the correct type. If null is used for the default value no type checking is done.

  Specified by:
    `getProperty` in interface `MuleMessage`
  Type Parameters:
    `T` - the defaultValue type ,this is used to validate the property value type
  Parameters:
    `name` - the name or key of the property. This must be non-null.
    `scope` - The scope of the property to retrieve. This must be non-null.
    `defaultValue` - the value to return if the property is not in the scope provided. Can be null
  Returns:
    the property value or the defaultValue if the property does not exist in the specified scope

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

  Specified by:
    `setCorrelationId` in interface `MuleMessage`
  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.

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

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

  Specified by:
    `setReplyTo` in interface `MuleMessage`
  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.

  Specified by:
    `getReplyTo` in interface `MuleMessage`
  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 `MuleMessage`
  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 `MuleMessage`
  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 `MuleMessage`
  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 `MuleMessage`
  Parameters:
    `size` - the total messages in this group or -1 if the size is not known

### getExceptionPayload

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

  Specified by:
    `getExceptionPayload` in interface `MuleMessage`
  Returns:
    The exception payload (if any) attached to this message

### setExceptionPayload

    public void setExceptionPayload(ExceptionPayload exceptionPayload)

  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.

  Specified by:
    `setExceptionPayload` in interface `MuleMessage`
  Parameters:
    `exceptionPayload` - The exception payload to attach to this message

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### addAttachment

    @Deprecated
    public void addAttachment(String name,
                                         DataHandler dataHandler)
                       throws Exception

  Deprecated.

  Allows for arbitrary data attachments to be associated with the Message. These attachments work in the same way that email attachments work. Attachments can be binary or text

  Specified by:
    `addAttachment` in interface `MuleMessage`
  Parameters:
    `name` - the name to associate with the attachment
    `dataHandler` - The attachment datahandler to use. This will be used to interact with the attachment data
  Throws:
    `Exception` - if the attachment cannot be added for any reason
  See Also:
    `DataHandler`

### removeAttachment

    @Deprecated
    public void removeAttachment(String name)
                          throws Exception

  Deprecated.

  Remove an attachment form this message with the specified name

  Specified by:
    `removeAttachment` in interface `MuleMessage`
  Parameters:
    `name` - the name of the attachment to remove. If the attachment does not exist, the request may be ignored
  Throws:
    `Exception` - different messaging systems handle attachments differently, as such some will throw an exception if an attachment does dot exist.

### getAttachment

    @Deprecated
    public DataHandler getAttachment(String name)

  Deprecated.

  Retrieve an attachment with the given name. If the attachment does not exist, null will be returned

  Specified by:
    `getAttachment` in interface `MuleMessage`
  Parameters:
    `name` - the name of the attachment to retrieve
  Returns:
    the attachment with the given name or null if the attachment does not exist
  See Also:
    `DataHandler`

### getAttachmentNames

    @Deprecated
    public Set<String> getAttachmentNames()

  Deprecated.

  Specified by:
    `getAttachmentNames` in interface `MuleMessage`
  Returns:
    a set of the names of the attachments on this message. If there are no attachments an empty set will be returned.

### addOutboundAttachment

    public void addOutboundAttachment(String name,
                                      DataHandler dataHandler)
                               throws Exception

  Description copied from interface: `MuleMessage`
  Allows for arbitrary data attachments to be associated with the Message. These attachments work in the same way that email attachments work. Attachments can be binary or text

  Specified by:
    `addOutboundAttachment` in interface `MuleMessage`
  Parameters:
    `name` - the name to associate with the attachment
    `dataHandler` - The attachment `DataHandler` to use. This will be used to interact with the attachment data
  Throws:
    `Exception` - if the attachment cannot be added for any reason
  See Also:
    `DataHandler`

### addInboundAttachment

    public void addInboundAttachment(String name,
                                     DataHandler dataHandler)
                              throws Exception

  Throws:
    `Exception`

### addOutboundAttachment

    public void addOutboundAttachment(String name,
                                      Object object,
                                      String contentType)
                               throws Exception

  Description copied from interface: `MuleMessage`
  Adds an outgoing attachment to the message

  Specified by:
    `addOutboundAttachment` in interface `MuleMessage`
  Parameters:
    `name` - the name to associate with the attachments
    `object` - the input stream to the contents of the attachment. This object can either be a `URL`, which will construct a URL data source, or a `File`, which will construct a file data source. Any other object will be used as the raw contents of the attachment
    `contentType` - the content type of the attachment. Note that the charset attribute can be specifed too i.e. text/plain;charset=UTF-8
  Throws:
    `Exception` - if the attachment cannot be read or created

### removeOutboundAttachment

    public void removeOutboundAttachment(String name)
                                  throws Exception

  Description copied from interface: `MuleMessage`
  Remove an attachment form this message with the specified name

  Specified by:
    `removeOutboundAttachment` in interface `MuleMessage`
  Parameters:
    `name` - the name of the attachment to remove. If the attachment does not exist, the request may be ignored
  Throws:
    `Exception` - different messaging systems handle attachments differently, as such some will throw an exception if an attachment does dot exist.

### getInboundAttachment

    public DataHandler getInboundAttachment(String name)

  Description copied from interface: `MuleMessage`
  Retrieve an attachment with the given name. If the attachment does not exist, null will be returned

  Specified by:
    `getInboundAttachment` in interface `MuleMessage`
  Parameters:
    `name` - the name of the attachment to retrieve
  Returns:
    the attachment with the given name or null if the attachment does not exist
  See Also:
    `DataHandler`

### getOutboundAttachment

    public DataHandler getOutboundAttachment(String name)

  Description copied from interface: `MuleMessage`
  Retrieve an attachment with the given name. If the attachment does not exist, null will be returned

  Specified by:
    `getOutboundAttachment` in interface `MuleMessage`
  Parameters:
    `name` - the name of the attachment to retrieve
  Returns:
    the attachment with the given name or null if the attachment does not exist
  See Also:
    `DataHandler`

### getInboundAttachmentNames

    public Set<String> getInboundAttachmentNames()

  Specified by:
    `getInboundAttachmentNames` in interface `MuleMessage`
  Returns:
    a set of the names of the attachments on this message. If there are no attachments an empty set will be returned.

### getOutboundAttachmentNames

    public Set<String> getOutboundAttachmentNames()

  Specified by:
    `getOutboundAttachmentNames` in interface `MuleMessage`
  Returns:
    a set of the names of the attachments on this message. If there are no attachments an empty set will be returned.

### findPropertyInAnyScope

    public <T> T findPropertyInAnyScope(String name,
                                        T defaultValue)

  Description copied from interface: `MuleMessage`
  This method was added with the introduction of Property scopes. However, this method should rarely be used. Instead, the scoped accessors should be used. Mule does not use this method internally and may be deprecated in future versions The Scopes will be checked in the following order, with the first match being returned -
  - Outbound
  - Invocation
  - Session
  - Inbound

  Specified by:
    `findPropertyInAnyScope` in interface `MuleMessage`
  Type Parameters:
    `T` - The Type of the property value that will be returned
  Parameters:
    `name` - the name of the property to look for
    `defaultValue` - the default value that will be returned if the property is not found
  Returns:
    TThe property value from the first scope that had the property set, or the 'defaultValue' if the property was not found in any scope

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

  Specified by:
    `getEncoding` in interface `MuleMessage`
  Returns:
    the encoding for this message. This method must never return null

### setEncoding

    public void setEncoding(String encoding)

  Sets the encoding for this message

  Specified by:
    `setEncoding` in interface `MuleMessage`
  Parameters:
    `encoding` - the encoding to use

### setMimeType

    public void setMimeType(String mimeType)

  Parameters:
    `mimeType` -
  Since:
    3.0

### addProperties

    public void addProperties(Map<String,Object> props)

  Adds a map of properties to be associated with this message

  Specified by:
    `addProperties` in interface `MuleMessage`
  Parameters:
    `props` - the properties add to this message

### addProperties

    public void addProperties(Map<String,Object> props,
                              PropertyScope scope)

  Adds a map of properties to be associated with this message

  Specified by:
    `addProperties` in interface `MuleMessage`
  Parameters:
    `props` - the properties add to this message
    `scope` - the scope in which the properties should be added

### addInboundProperties

    public void addInboundProperties(Map<String,Object> props)

### clearProperties

    public void clearProperties()

  Removes all properties on this message in the `PropertyScope.INVOCATION` and `PropertyScope.OUTBOUND`.

  Specified by:
    `clearProperties` in interface `MuleMessage`

### clearProperties

    public void clearProperties(PropertyScope scope)

  Removes all properties on this message in the given scope. Note that the INBOUND scope is read-only, so attempting to clear this scopee will result in an UnsupportedOperationException.

  Specified by:
    `clearProperties` in interface `MuleMessage`
  Parameters:
    `scope` - the property scope to clear

### getPayload

    public Object getPayload()

  Specified by:
    `getPayload` in interface `MuleMessage`
  Returns:
    the current message

### setPayload

    public void setPayload(Object payload)

  Update the message payload. This is typically only called if the payload was originally an InputStream. In which case, if the InputStream is consumed, it needs to be replaced for future access.

  Specified by:
    `setPayload` in interface `MuleMessage`
  Parameters:
    `payload` - the object to assign as the message payload

### release

    public void release()

  Perform any clean up operations on the message resource. Typically this is used to esure that a message stream is closed

  Specified by:
    `release` in interface `MuleMessage`

### applyTransformers

    public void applyTransformers(MuleEvent event,
                                  List<? extends Transformer> transformers)
                           throws MuleException

  Will apply a list of transformers to the payload of the message. This *Will* change the payload of the message. This method provides the only way to alter the paylaod of this message without recreating a copy of the message

  Specified by:
    `applyTransformers` in interface `MuleMessage`
  Parameters:
    `event` - the event being processed
    `transformers` - the transformers to apply to the message payload
  Throws:
    `TransformerException` - if a transformation error occurs or one or more of the transformers passed in a are incompatible with the message payload
    `MuleException`

### applyTransformers

    public void applyTransformers(MuleEvent event,
                                  Transformer... transformers)
                           throws MuleException

  Will apply a list of transformers to the payload of the message. This *Will* change the payload of the message. This method provides the only way to alter the paylaod of this message without recreating a copy of the message

  Specified by:
    `applyTransformers` in interface `MuleMessage`
  Parameters:
    `event` - the event being processed
    `transformers` - the transformers to apply to the message payload
  Throws:
    `TransformerException` - if a transformation error occurs or one or more of the transformers passed in a are incompatible with the message payload
    `MuleException`

### applyTransformers

    public void applyTransformers(MuleEvent event,
                                  List<? extends Transformer> transformers,
                                  Class<?> outputType)
                           throws MuleException

  Description copied from interface: `MuleMessage`
  Will apply a list of transformers to the payload of the message. This *Will* change the payload of the message. This method provides the only way to alter the paylaod of this message without recreating a copy of the message

  Specified by:
    `applyTransformers` in interface `MuleMessage`
  Parameters:
    `event` - the event being processed
    `transformers` - the transformers to apply to the message payload
    `outputType` - the required output type for this transformation. by adding this parameter some additional transformations will occur on the message payload to ensure that the final payload is of the specified type. If no transformers can be found in the registry that can transform from the return type of the transformation list to the outputType and exception will be thrown
  Throws:
    `TransformerException` - if a transformation error occurs or one or more of the transformers passed in a are incompatible with the message payload
    `MuleException`

### applyAllTransformers

    protected void applyAllTransformers(MuleEvent event,
                                        List<? extends Transformer> transformers)
                                 throws MuleException

  Throws:
    `MuleException`

### setDataType

    protected void setDataType(DataType<?> dt)

### newThreadCopy

    public ThreadSafeAccess newThreadCopy()

  Specified by:
    `newThreadCopy` in interface `ThreadSafeAccess`
  Returns:
    A new instance of the implementing class, unbound to any thread and mutable.

### resetAccessControl

    public void resetAccessControl()

  This method should ONLY be used in the construction of composite ThreadSafeAccess instances. For example, a ThreadSafeAccess MuleEvent contains a ThreadSafeAccess MuleMessage. During the construction of the event, the message may be bound to the contructing thread. Calling this method releases that binding so that the event as a whole can be passed to a new thread unbound.

  Specified by:
    `resetAccessControl` in interface `ThreadSafeAccess`

### assertAccess

    public void assertAccess(boolean write)

  This method may be called before data in the object are accessed. It should verify that the access policy is followed correctly (if not, a runtime exception may be thrown).

  Specified by:
    `assertAccess` in interface `ThreadSafeAccess`
  Parameters:
    `write` - True if the access will mutate values.

### isDisabled

    protected boolean isDisabled()

### newException

    protected IllegalStateException newException(String message)

### isConsumable

    public boolean isConsumable()

  Determines if the payload of this message is consumable i.e. it can't be read more than once. This is here temporarily without adding to MuleMessage interface until MULE-4256 is implemented.

### initAfterDeserialisation

    public void initAfterDeserialisation(MuleContext muleContext)
                                  throws MuleException

  Invoked after deserialization. This is called when the marker interface `DeserializationPostInitialisable` is used. This will get invoked after the object has been deserialized passing in the current mulecontext when using either `SerializationWireFormat`, `SerializedMuleMessageWireFormat` or the `ByteArrayToSerializable` transformer.

  Parameters:
    `muleContext` - the current muleContext instance
  Throws:
    `MuleException` - if there is an error initializing

### getDataType

    public DataType<?> getDataType()

  Description copied from interface: `MuleMessage`
  Returns the data type (if any) associated with the message's payload.

  Specified by:
    `getDataType` in interface `MuleMessage`

### getIntProperty

    @Deprecated
    public int getIntProperty(String name,
                                         int defaultValue)

  Deprecated.

  Gets an integer property from the message

  Specified by:
    `getIntProperty` in interface `MuleMessage`
  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

    @Deprecated
    public long getLongProperty(String name,
                                           long defaultValue)

  Deprecated.

  Gets a long property from the message

  Specified by:
    `getLongProperty` in interface `MuleMessage`
  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

    @Deprecated
    public double getDoubleProperty(String name,
                                               double defaultValue)

  Deprecated.

  Gets a double property from the message

  Specified by:
    `getDoubleProperty` in interface `MuleMessage`
  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

    @Deprecated
    public boolean getBooleanProperty(String name,
                                                 boolean defaultValue)

  Deprecated.

  Gets a boolean property from the message

  Specified by:
    `getBooleanProperty` in interface `MuleMessage`
  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

    @Deprecated
    public void setBooleanProperty(String name,
                                              boolean value)

  Deprecated.

  Sets a boolean property on the message

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

### setIntProperty

    @Deprecated
    public void setIntProperty(String name,
                                          int value)

  Deprecated.

  Sets a integer property on the message

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

### setLongProperty

    @Deprecated
    public void setLongProperty(String name,
                                           long value)

  Deprecated.

  Sets a long property on the message

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

### setDoubleProperty

    @Deprecated
    public void setDoubleProperty(String name,
                                             double value)

  Deprecated.

  Sets a double property on the message

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

### getStringProperty

    @Deprecated
    public String getStringProperty(String name,
                                               String defaultValue)

  Deprecated.

  Gets a String property from the message

  Specified by:
    `getStringProperty` in interface `MuleMessage`
  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

    @Deprecated
    public void setStringProperty(String name,
                                             String value)

  Deprecated.

  Sets a String property on the message

  Specified by:
    `setStringProperty` in interface `MuleMessage`
  Parameters:
    `name` - the property name or key
    `value` - the property value

### findPropertyInSpecifiedScopes

    public <T> T findPropertyInSpecifiedScopes(String name,
                                               PropertyScope... scopesToSearch)

  Find property in one of the specified scopes, in order

### createInboundMessage

    public MuleMessage createInboundMessage()
                                     throws Exception

  Copy an inbound message to an outbound one, moving all message properties and attachments

  Specified by:
    `createInboundMessage` in interface `MuleMessage`
  Returns:
    the inbound message
  Throws:
    `Exception`

### copyToInbound

    protected void copyToInbound(DefaultMuleMessage newMessage)
                          throws Exception

  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.