org.mule
Class DefaultMessageCollection

java.lang.Object
  extended by org.mule.DefaultMuleMessage
      extended by org.mule.DefaultMessageCollection
All Implemented Interfaces:
Serializable, MuleMessage, MuleMessageCollection, ThreadSafeAccess, DeserializationPostInitialisable

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

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mule.DefaultMuleMessage
DefaultMuleMessage.SerializedDataHandler
 
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
 
Fields inherited from class org.mule.DefaultMuleMessage
muleContext, NOT_SET
 
Fields inherited from interface org.mule.api.ThreadSafeAccess
READ, WRITE
 
Constructor Summary
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)
           
 
Method Summary
 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()
           
 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.
 int size()
           
 
Methods inherited from class org.mule.DefaultMuleMessage
addAttachment, addInboundAttachment, addInboundProperties, addOutboundAttachment, addOutboundAttachment, addProperties, addProperties, applyAllTransformers, applyTransformers, applyTransformers, applyTransformers, assertAccess, clearProperties, clearProperties, copyMessageProperties, copyToInbound, 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, getOutboundAttachment, getOutboundAttachmentNames, getOutboundProperty, getOutboundProperty, getOutboundPropertyNames, getPayload, getPayload, getPayload, getPayloadAsString, getProperty, getProperty, getProperty, getProperty, getPropertyNames, getPropertyNames, getReplyTo, getSessionProperty, getSessionProperty, getSessionPropertyNames, getStringProperty, getUniqueId, initAfterDeserialisation, isConsumable, isDisabled, isPayloadConsumed, newException, propagateRootId, release, removeAttachment, removeOutboundAttachment, removeProperty, removeProperty, resetAccessControl, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDataType, setDoubleProperty, setEncoding, setExceptionPayload, setInboundProperty, setIntProperty, setInvocationProperty, setLongProperty, setMessageRootId, setMimeType, setMuleContext, setOutboundProperty, setProperty, setProperty, setReplyTo, setSessionProperty, setStringProperty, setUniqueId, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.api.MuleMessage
addAttachment, addOutboundAttachment, addOutboundAttachment, addProperties, addProperties, applyTransformers, applyTransformers, applyTransformers, 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, getPropertyNames, getPropertyNames, getReplyTo, getSessionProperty, getSessionProperty, getSessionPropertyNames, getStringProperty, getUniqueId, propagateRootId, release, removeAttachment, removeOutboundAttachment, removeProperty, removeProperty, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setInvocationProperty, setLongProperty, setMessageRootId, setOutboundProperty, setProperty, setProperty, setReplyTo, setSessionProperty, setStringProperty
 

Constructor Detail

DefaultMessageCollection

public DefaultMessageCollection(MuleContext muleContext)

DefaultMessageCollection

public DefaultMessageCollection(DefaultMessageCollection msg,
                                MuleContext muleContext)
Performs a shallow copy

Parameters:
msg -
muleContext -

DefaultMessageCollection

public DefaultMessageCollection(DefaultMessageCollection msg,
                                MuleContext muleContext,
                                boolean deepMessageCopy)
Performs a shallow or deep copy of the messages

Parameters:
msg -
muleContext -
deepMessageCopy -
Method Detail

checkValidPayload

protected void checkValidPayload()

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<MuleMessage> 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<MuleMessage> getMessageList()

getPayloadList

protected List<Object> getPayloadList()

setPayload

public void setPayload(Object payload)
Description copied from class: DefaultMuleMessage
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
Overrides:
setPayload in class DefaultMuleMessage
Parameters:
payload - the object to assign as the message payload

getPayload

public Object getPayload(Class outputType)
                  throws TransformerException
Applies the 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 compatibility

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

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
Overrides:
getPayloadForLogging in class DefaultMuleMessage
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
Overrides:
getPayloadForLogging in class DefaultMuleMessage
Returns:
message payload as object

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:
A new instance of the implementing class, unbound to any thread and mutable.

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
Overrides:
createInboundMessage in class DefaultMuleMessage
Returns:
the inbound message
Throws:
Exception

isInvalidatedPayload

public boolean isInvalidatedPayload()


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