Spring Integration

org.springframework.integration.support
Class MessageBuilder<T>

java.lang.Object
  extended by org.springframework.integration.support.MessageBuilder<T>

public final class MessageBuilder<T>
extends java.lang.Object

Author:
Arjen Poutsma, Mark Fisher, Oleg Zhurakousky, Dave Syer

Method Summary
 Message<T> build()
           
 MessageBuilder<T> copyHeaders(java.util.Map<java.lang.String,?> headersToCopy)
          Copy the name-value pairs from the provided Map.
 MessageBuilder<T> copyHeadersIfAbsent(java.util.Map<java.lang.String,?> headersToCopy)
          Copy the name-value pairs from the provided Map.
static
<T> MessageBuilder<T>
fromMessage(Message<T> message)
          Create a builder for a new Message instance pre-populated with all of the headers copied from the provided message.
 MessageBuilder<T> popSequenceDetails()
           
 MessageBuilder<T> pushSequenceDetails(java.lang.Object correlationId, int sequenceNumber, int sequenceSize)
           
 MessageBuilder<T> removeHeader(java.lang.String headerName)
          Remove the value for the given header name.
 MessageBuilder<T> removeHeaders(java.lang.String... headerPatterns)
          Removes all headers provided via array of 'headerPatterns'.
 MessageBuilder<T> setCorrelationId(java.lang.Object correlationId)
           
 MessageBuilder<T> setErrorChannel(MessageChannel errorChannel)
           
 MessageBuilder<T> setErrorChannelName(java.lang.String errorChannelName)
           
 MessageBuilder<T> setExpirationDate(java.util.Date expirationDate)
           
 MessageBuilder<T> setExpirationDate(java.lang.Long expirationDate)
           
 MessageBuilder<T> setHeader(java.lang.String headerName, java.lang.Object headerValue)
          Set the value for the given header name.
 MessageBuilder<T> setHeaderIfAbsent(java.lang.String headerName, java.lang.Object headerValue)
          Set the value for the given header name only if the header name is not already associated with a value.
 MessageBuilder<T> setPriority(java.lang.Integer priority)
           
 MessageBuilder<T> setReplyChannel(MessageChannel replyChannel)
           
 MessageBuilder<T> setReplyChannelName(java.lang.String replyChannelName)
           
 MessageBuilder<T> setSequenceNumber(java.lang.Integer sequenceNumber)
           
 MessageBuilder<T> setSequenceSize(java.lang.Integer sequenceSize)
           
static
<T> MessageBuilder<T>
withPayload(T payload)
          Create a builder for a new Message instance with the provided payload.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fromMessage

public static <T> MessageBuilder<T> fromMessage(Message<T> message)
Create a builder for a new Message instance pre-populated with all of the headers copied from the provided message. The payload of the provided Message will also be used as the payload for the new message.

Parameters:
message - the Message from which the payload and all headers will be copied

withPayload

public static <T> MessageBuilder<T> withPayload(T payload)
Create a builder for a new Message instance with the provided payload.

Parameters:
payload - the payload for the new message

setHeader

public MessageBuilder<T> setHeader(java.lang.String headerName,
                                   java.lang.Object headerValue)
Set the value for the given header name. If the provided value is null, the header will be removed.


setHeaderIfAbsent

public MessageBuilder<T> setHeaderIfAbsent(java.lang.String headerName,
                                           java.lang.Object headerValue)
Set the value for the given header name only if the header name is not already associated with a value.


removeHeaders

public MessageBuilder<T> removeHeaders(java.lang.String... headerPatterns)
Removes all headers provided via array of 'headerPatterns'. As the name suggests the array may contain simple matching patterns for header names. Supported pattern styles are: "xxx*", "*xxx", "*xxx*" and "xxx*yyy".

Parameters:
headerPatterns -

removeHeader

public MessageBuilder<T> removeHeader(java.lang.String headerName)
Remove the value for the given header name.


copyHeaders

public MessageBuilder<T> copyHeaders(java.util.Map<java.lang.String,?> headersToCopy)
Copy the name-value pairs from the provided Map. This operation will overwrite any existing values. Use { copyHeadersIfAbsent(Map) to avoid overwriting values. Note that the 'id' and 'timestamp' header values will never be overwritten.

See Also:
MessageHeaders.ID, MessageHeaders.TIMESTAMP

copyHeadersIfAbsent

public MessageBuilder<T> copyHeadersIfAbsent(java.util.Map<java.lang.String,?> headersToCopy)
Copy the name-value pairs from the provided Map. This operation will not overwrite any existing values.


setExpirationDate

public MessageBuilder<T> setExpirationDate(java.lang.Long expirationDate)

setExpirationDate

public MessageBuilder<T> setExpirationDate(java.util.Date expirationDate)

setCorrelationId

public MessageBuilder<T> setCorrelationId(java.lang.Object correlationId)

pushSequenceDetails

public MessageBuilder<T> pushSequenceDetails(java.lang.Object correlationId,
                                             int sequenceNumber,
                                             int sequenceSize)

popSequenceDetails

public MessageBuilder<T> popSequenceDetails()

setReplyChannel

public MessageBuilder<T> setReplyChannel(MessageChannel replyChannel)

setReplyChannelName

public MessageBuilder<T> setReplyChannelName(java.lang.String replyChannelName)

setErrorChannel

public MessageBuilder<T> setErrorChannel(MessageChannel errorChannel)

setErrorChannelName

public MessageBuilder<T> setErrorChannelName(java.lang.String errorChannelName)

setSequenceNumber

public MessageBuilder<T> setSequenceNumber(java.lang.Integer sequenceNumber)

setSequenceSize

public MessageBuilder<T> setSequenceSize(java.lang.Integer sequenceSize)

setPriority

public MessageBuilder<T> setPriority(java.lang.Integer priority)

build

public Message<T> build()

Spring Integration