public class DefaultMessageCollection extends DefaultMuleMessage implements MuleMessageCollection
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
.ThreadSafeAccess.AccessControl
READ, WRITE
Constructor and Description |
---|
DefaultMessageCollection() |
DefaultMessageCollection(DefaultMessageCollection msg)
Performs a shallow copy
|
Modifier and Type | Method and Description |
---|---|
void |
addMessage(MuleMessage message) |
void |
addMessage(MuleMessage message,
int index) |
void |
addMessages(List messages) |
void |
addMessages(MuleEvent[] events) |
void |
addMessages(MuleMessage[] messages) |
MuleMessage |
getMessage(int index) |
protected List |
getMessageList() |
MuleMessage[] |
getMessagesAsArray() |
Object |
getPayload(Class outputType)
Applies the
getPayload(Class) call to every message in the collection and returns a
List of results. |
byte[] |
getPayloadAsBytes()
Converts the message implementation into a byte array representation
|
String |
getPayloadAsString(String encoding)
Converts the message implementation into a String representation
|
protected List |
getPayloadList() |
Object[] |
getPayloadsAsArray() |
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;
|
void |
removedMessage(MuleMessage message) |
int |
size() |
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, getPropertyNames, getReplyTo, getStringProperty, getUniqueId, isPayloadConsumed, release, removeAttachment, removeProperty, resetAccessControl, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setPayload, setProperty, setProperty, setReplyTo, setStringProperty, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
applyTransformers, applyTransformers, getAdapter, getOrginalPayload, getOriginalAdapter, getPayloadAsString, setPayload
addAttachment, addProperties, addProperties, clearProperties, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getPayload, getProperty, getProperty, getPropertyNames, getReplyTo, getStringProperty, getUniqueId, release, removeAttachment, removeProperty, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setProperty, setProperty, setReplyTo, setStringProperty
public DefaultMessageCollection()
public DefaultMessageCollection(DefaultMessageCollection msg)
msg
- public void addMessage(MuleMessage message)
addMessage
in interface MuleMessageCollection
public MuleMessage[] getMessagesAsArray()
getMessagesAsArray
in interface MuleMessageCollection
public Object[] getPayloadsAsArray()
getPayloadsAsArray
in interface MuleMessageCollection
public void removedMessage(MuleMessage message)
removedMessage
in interface MuleMessageCollection
public void addMessage(MuleMessage message, int index)
addMessage
in interface MuleMessageCollection
public void addMessages(MuleEvent[] events)
addMessages
in interface MuleMessageCollection
public void addMessages(List messages)
addMessages
in interface MuleMessageCollection
public void addMessages(MuleMessage[] messages)
addMessages
in interface MuleMessageCollection
public MuleMessage getMessage(int index)
getMessage
in interface MuleMessageCollection
protected List getMessageList()
protected List getPayloadList()
public Object getPayload(Class outputType) throws TransformerException
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 trnsformr 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 compatabilitygetPayload
in interface MuleMessage
getPayload
in class DefaultMuleMessage
outputType
- the desired return typeTransformerException
- if a transformer cannot be found or there is an error during transformation of the
payloadpublic int size()
size
in interface MuleMessageCollection
public byte[] getPayloadAsBytes() throws Exception
getPayloadAsBytes
in interface MuleMessage
getPayloadAsBytes
in class DefaultMuleMessage
Exception
- Implemetation may throw an endpoint specific exceptionpublic String getPayloadAsString(String encoding) throws Exception
getPayloadAsString
in interface MuleMessage
getPayloadAsString
in class DefaultMuleMessage
encoding
- The encoding to use when transforming the message (if
necessary). The parameter is used when converting from a byte arrayException
- Implementation may throw an endpoint specific exceptionpublic ThreadSafeAccess newThreadCopy()
newThreadCopy
in interface ThreadSafeAccess
newThreadCopy
in class DefaultMuleMessage
Copyright © 2003–2013 MuleSource, Inc.. All rights reserved.