Spring Integration

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

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

public final class MessageBuilder<T>
extends Object

Author:
Arjen Poutsma, Mark Fisher, Oleg Zhurakousky

Method Summary
 Message<T> build()
           
 MessageBuilder<T> copyHeaders(Map<String,?> headersToCopy)
          Copy the name-value pairs from the provided Map.
 MessageBuilder<T> copyHeadersIfAbsent(Map<String,Object> 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> removeHeader(String headerName)
          Remove the value for the given header name.
 MessageBuilder<T> setCorrelationId(Object correlationId)
           
 MessageBuilder<T> setErrorChannel(MessageChannel errorChannel)
           
 MessageBuilder<T> setErrorChannelName(String errorChannelName)
           
 MessageBuilder<T> setExpirationDate(Date expirationDate)
           
 MessageBuilder<T> setExpirationDate(Long expirationDate)
           
 MessageBuilder<T> setHeader(String headerName, Object headerValue)
          Set the value for the given header name.
 MessageBuilder<T> setHeaderIfAbsent(String headerName, 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(Integer priority)
           
 MessageBuilder<T> setReplyChannel(MessageChannel replyChannel)
           
 MessageBuilder<T> setReplyChannelName(String replyChannelName)
           
 MessageBuilder<T> setSequenceNumber(Integer sequenceNumber)
           
 MessageBuilder<T> setSequenceSize(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(String headerName,
                                   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(String headerName,
                                           Object headerValue)
Set the value for the given header name only if the header name is not already associated with a value.


removeHeader

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


copyHeaders

public MessageBuilder<T> copyHeaders(Map<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(Map<String,Object> headersToCopy)
Copy the name-value pairs from the provided Map. This operation will not overwrite any existing values.


setExpirationDate

public MessageBuilder<T> setExpirationDate(Long expirationDate)

setExpirationDate

public MessageBuilder<T> setExpirationDate(Date expirationDate)

setCorrelationId

public MessageBuilder<T> setCorrelationId(Object correlationId)

setReplyChannel

public MessageBuilder<T> setReplyChannel(MessageChannel replyChannel)

setReplyChannelName

public MessageBuilder<T> setReplyChannelName(String replyChannelName)

setErrorChannel

public MessageBuilder<T> setErrorChannel(MessageChannel errorChannel)

setErrorChannelName

public MessageBuilder<T> setErrorChannelName(String errorChannelName)

setSequenceNumber

public MessageBuilder<T> setSequenceNumber(Integer sequenceNumber)

setSequenceSize

public MessageBuilder<T> setSequenceSize(Integer sequenceSize)

setPriority

public MessageBuilder<T> setPriority(Integer priority)

build

public Message<T> build()

Spring Integration

Copyright © 2010. All Rights Reserved.