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 MuleMessage.getPayload(Class)
will attempt to transform all payloads and return a List
.
The methods MuleMessage.getPayloadAsString()
and MuleMessage.getPayloadAsBytes()
are unsupported, instead users should
call MuleMessage.getPayload(Class)
and pass in the return type byte[].class
or String.class
.DefaultMuleMessage.SerializedDataHandler
ThreadSafeAccess.AccessControl
DeserializationPostInitialisable.Implementation
muleContext, NOT_SET
READ, WRITE
Constructor and Description |
---|
DefaultMessageCollection(DefaultMessageCollection msg,
MuleContext muleContext)
Performs a shallow copy
|
DefaultMessageCollection(DefaultMessageCollection msg,
MuleContext muleContext,
boolean deepMessageCopy)
Performs a shallow or deep copy of the messages
|
DefaultMessageCollection(MuleContext muleContext) |
Modifier and Type | Method and Description |
---|---|
void |
addMessage(MuleMessage message) |
void |
addMessage(MuleMessage message,
int index) |
void |
addMessages(List<MuleMessage> messages) |
void |
addMessages(MuleEvent[] events) |
void |
addMessages(MuleMessage[] messages) |
protected void |
checkValidPayload() |
MuleMessage |
createInboundMessage()
Copy an inbound message to an outbound one, moving all message properties and attachments
|
MuleMessage |
getMessage(int index) |
protected List<MuleMessage> |
getMessageList() |
MuleMessage[] |
getMessagesAsArray() |
Object |
getPayload(Class outputType)
Applies the
MuleMessage.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
|
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.
|
protected List<Object> |
getPayloadList() |
Object[] |
getPayloadsAsArray() |
void |
initAfterDeserialisation(MuleContext context)
Invoked after deserialization.
|
boolean |
isInvalidatedPayload() |
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) |
void |
setPayload(Object payload)
Update the message payload.
|
void |
setPayload(Object payload,
DataType dataType)
Updates the message payload.
|
int |
size() |
addAttachment, addInboundAttachment, addInboundProperties, addOutboundAttachment, addOutboundAttachment, addProperties, addProperties, applyAllTransformers, applyTransformers, applyTransformers, applyTransformers, assertAccess, clearAttachments, clearProperties, clearProperties, copyMessageProperties, copyToInbound, equals, findPropertyInAnyScope, findPropertyInSpecifiedScopes, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDataType, getDoubleProperty, getEncoding, getExceptionPayload, getInboundAttachment, getInboundAttachmentNames, getInboundProperty, getInboundProperty, getInboundPropertyNames, getIntProperty, getInvocationProperty, getInvocationProperty, getInvocationPropertyNames, getLongProperty, getMessageRootId, getMuleContext, getOriginalPayload, getOrphanFlowVariables, getOutboundAttachment, getOutboundAttachmentNames, getOutboundProperty, getOutboundProperty, getOutboundPropertyNames, getPayload, getPayload, getPayload, getPayloadAsString, getProperty, getProperty, getProperty, getProperty, getPropertyDataType, getPropertyNames, getPropertyNames, getReplyTo, getSessionProperty, getSessionProperty, getSessionPropertyNames, getStringProperty, getUniqueId, hashCode, isConsumable, isDisabled, isPayloadConsumed, newException, propagateRootId, release, removeAttachment, removeOutboundAttachment, removeProperty, removeProperty, resetAccessControl, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDataType, setDoubleProperty, setEncoding, setExceptionPayload, setInboundProperty, setInboundProperty, setIntProperty, setInvocationProperty, setInvocationProperty, setLongProperty, setMessageRootId, setMimeType, setMuleContext, setOutboundProperty, setOutboundProperty, setProperty, setProperty, setProperty, setReplyTo, setSessionProperty, setStringProperty, setUniqueId, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAttachment, addOutboundAttachment, addOutboundAttachment, addProperties, addProperties, applyTransformers, applyTransformers, applyTransformers, clearAttachments, clearProperties, clearProperties, findPropertyInAnyScope, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDataType, getDoubleProperty, getEncoding, getExceptionPayload, getInboundAttachment, getInboundAttachmentNames, getInboundProperty, getInboundProperty, getInboundPropertyNames, getIntProperty, getInvocationProperty, getInvocationProperty, getInvocationPropertyNames, getLongProperty, getMessageRootId, getMuleContext, getOriginalPayload, getOutboundAttachment, getOutboundAttachmentNames, getOutboundProperty, getOutboundProperty, getOutboundPropertyNames, getPayload, getPayload, getPayloadAsString, getProperty, getProperty, getProperty, getProperty, getPropertyDataType, getPropertyNames, getPropertyNames, getReplyTo, getSessionProperty, getSessionProperty, getSessionPropertyNames, getStringProperty, getUniqueId, propagateRootId, release, removeAttachment, removeOutboundAttachment, removeProperty, removeProperty, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setInvocationProperty, setInvocationProperty, setLongProperty, setMessageRootId, setOutboundProperty, setOutboundProperty, setProperty, setProperty, setProperty, setReplyTo, setSessionProperty, setStringProperty
public DefaultMessageCollection(MuleContext muleContext)
public DefaultMessageCollection(DefaultMessageCollection msg, MuleContext muleContext)
msg
- muleContext
- public DefaultMessageCollection(DefaultMessageCollection msg, MuleContext muleContext, boolean deepMessageCopy)
msg
- muleContext
- deepMessageCopy
- protected void checkValidPayload()
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<MuleMessage> 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<MuleMessage> getMessageList()
public void setPayload(Object payload)
DefaultMuleMessage
setPayload
in interface MuleMessage
setPayload
in class DefaultMuleMessage
payload
- the object to assign as the message payloadpublic void setPayload(Object payload, DataType dataType)
MuleMessage
setPayload
in interface MuleMessage
setPayload
in class DefaultMuleMessage
payload
- the object to assign as the message payloaddataType
- payload's dataType. Not null.public Object getPayload(Class outputType) throws TransformerException
MuleMessage.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 transformers added to the registry will be checked for compatibilitygetPayload
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 String getPayloadForLogging(String encoding)
getPayloadForLogging
in interface MuleMessage
getPayloadForLogging
in class DefaultMuleMessage
public String getPayloadForLogging()
getPayloadForLogging
in interface MuleMessage
getPayloadForLogging
in class DefaultMuleMessage
public ThreadSafeAccess newThreadCopy()
newThreadCopy
in interface ThreadSafeAccess
newThreadCopy
in class DefaultMuleMessage
public void initAfterDeserialisation(MuleContext context) throws MuleException
DefaultMuleMessage
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.initAfterDeserialisation
in class DefaultMuleMessage
context
- the current muleContext instanceMuleException
- if there is an error initializingpublic MuleMessage createInboundMessage() throws Exception
createInboundMessage
in interface MuleMessage
createInboundMessage
in class DefaultMuleMessage
Exception
public boolean isInvalidatedPayload()
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.