org.mule
Class DefaultMessageCollection
java.lang.Object
org.mule.DefaultMuleMessage
org.mule.DefaultMessageCollection
- All Implemented Interfaces:
- Serializable, MuleMessage, MuleMessageCollection, ThreadSafeAccess, MessageAdapter
public class DefaultMessageCollection
- extends DefaultMuleMessage
- implements MuleMessageCollection
A MuleMessage
type that manages a collection of MuleMessage Objects.
Typically this type of message is only used when users explicitly want to work with aggregated or re-sequenced
collections of messages.
Note that the DefaultMuleMessage.getPayload()
for this message will return a List
of payload objects for
each of the Mule messages stored in this collection.
Calling getPayload(Class)
will attempt to transform all payloads and return a List
.
The methods DefaultMuleMessage.getPayloadAsString()
and getPayloadAsBytes()
are unsupported, instead users should
call getPayload(Class)
and pass in the return type byte[].class
or String.class
.
- See Also:
- Serialized Form
Methods inherited from class org.mule.DefaultMuleMessage |
addAttachment, addProperties, addProperties, applyAllTransformers, applyTransformers, applyTransformers, assertAccess, clearProperties, getAdapter, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getOrginalPayload, getOriginalAdapter, getPayload, getPayload, getPayloadAsString, getProperty, getProperty, getProperty, getPropertyNames, getPropertyNames, getReplyTo, getStringProperty, getUniqueId, isConsumable, isPayloadConsumed, release, removeAttachment, removeProperty, resetAccessControl, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setPayload, setProperty, setProperty, setReplyTo, setStringProperty, toString |
Methods inherited from interface org.mule.api.transport.MessageAdapter |
addAttachment, addProperties, addProperties, clearProperties, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getPayload, getProperty, getProperty, getProperty, getPropertyNames, getPropertyNames, getReplyTo, getStringProperty, getUniqueId, release, removeAttachment, removeProperty, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setProperty, setProperty, setReplyTo, setStringProperty |
DefaultMessageCollection
public DefaultMessageCollection()
DefaultMessageCollection
public DefaultMessageCollection(DefaultMessageCollection msg)
- Performs a shallow copy
- Parameters:
msg
-
addMessage
public void addMessage(MuleMessage message)
- Specified by:
addMessage
in interface MuleMessageCollection
getMessagesAsArray
public MuleMessage[] getMessagesAsArray()
- Specified by:
getMessagesAsArray
in interface MuleMessageCollection
getPayloadsAsArray
public Object[] getPayloadsAsArray()
- Specified by:
getPayloadsAsArray
in interface MuleMessageCollection
removedMessage
public void removedMessage(MuleMessage message)
- Specified by:
removedMessage
in interface MuleMessageCollection
addMessage
public void addMessage(MuleMessage message,
int index)
- Specified by:
addMessage
in interface MuleMessageCollection
addMessages
public void addMessages(MuleEvent[] events)
- Specified by:
addMessages
in interface MuleMessageCollection
addMessages
public void addMessages(List messages)
- Specified by:
addMessages
in interface MuleMessageCollection
addMessages
public void addMessages(MuleMessage[] messages)
- Specified by:
addMessages
in interface MuleMessageCollection
getMessage
public MuleMessage getMessage(int index)
- Specified by:
getMessage
in interface MuleMessageCollection
getMessageList
protected List getMessageList()
getPayloadList
protected List getPayloadList()
getPayload
public Object getPayload(Class outputType)
throws TransformerException
- Applies the
getPayload(Class)
call to every message in the collection and returns a
List
of results.
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 transfromers added to the reqgistry will be checked for compatability
- Specified by:
getPayload
in interface MuleMessage
- Overrides:
getPayload
in class DefaultMuleMessage
- 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
size
public int size()
- Specified by:
size
in interface MuleMessageCollection
getPayloadAsBytes
public byte[] getPayloadAsBytes()
throws Exception
- Converts the message implementation into a byte array representation
- Specified by:
getPayloadAsBytes
in interface MuleMessage
- Overrides:
getPayloadAsBytes
in class DefaultMuleMessage
- 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
- Overrides:
getPayloadAsString
in class DefaultMuleMessage
- 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
newThreadCopy
public ThreadSafeAccess newThreadCopy()
- We need to overload this if we find we want to make this class available to users, but the copy will be expensive;
- Specified by:
newThreadCopy
in interface ThreadSafeAccess
- Overrides:
newThreadCopy
in class DefaultMuleMessage
- Returns:
Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.