Class BaseMessageBuilder<T, B extends BaseMessageBuilder<T,B>> 
java.lang.Object
org.springframework.integration.support.AbstractIntegrationMessageBuilder<T>
org.springframework.integration.support.BaseMessageBuilder<T,B> 
- Type Parameters:
- T- the payload type.
- B- the target builder class type.
- Direct Known Subclasses:
- MessageBuilder
public abstract class BaseMessageBuilder<T, B extends BaseMessageBuilder<T,B>> 
extends AbstractIntegrationMessageBuilder<T>
The 
AbstractIntegrationMessageBuilder extension for the default logic to build message.
 The MessageBuilder is fully based on this class.
 This abstract class can be used for creating custom Message instances.
 For that purpose its build() method has to be overridden.
 The custom Message type could be used, for example, to hide sensitive information
 from payload and headers when message is logged.
 For this goal there would be enough to override GenericMessage.toString()
 and filter out (or mask) those headers which container such sensitive information.- Since:
- 6.4
- Author:
- Artem Bilan
- See Also:
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedBaseMessageBuilder(T payload, Message<T> originalMessage) 
- 
Method SummaryModifier and TypeMethodDescriptionbuild()Return an original message instance if it is not modified and does not have read-only headers.copyHeaders(Map<String, ?> headersToCopy) Copy the name-value pairs from the provided Map.copyHeadersIfAbsent(Map<String, ?> headersToCopy) Copy the name-value pairs from the provided Map.protected Object<V> Vprotected Objectprotected ObjectpushSequenceDetails(Object correlationId, int sequenceNumber, int sequenceSize) readOnlyHeaders(String... readOnlyHeaders) Specify a list of headers which should be considered as read only and prohibited from being populated in the message.removeHeader(String headerName) Remove the value for the given header name.removeHeaders(String... headerPatterns) Removes all headers provided via array of 'headerPatterns'.setCorrelationId(Object correlationId) setErrorChannel(MessageChannel errorChannel) setErrorChannelName(String errorChannelName) setExpirationDate(Long expirationDate) setExpirationDate(Date expirationDate) Set the value for the given header name.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.setPriority(Integer priority) setReplyChannel(MessageChannel replyChannel) setReplyChannelName(String replyChannelName) setSequenceNumber(Integer sequenceNumber) setSequenceSize(Integer sequenceSize) Methods inherited from class org.springframework.integration.support.AbstractIntegrationMessageBuildercloneMessageHistoryIfAny, filterAndCopyHeadersIfAbsent
- 
Constructor Details- 
BaseMessageBuilder
 
- 
- 
Method Details- 
getPayload- Specified by:
- getPayloadin class- AbstractIntegrationMessageBuilder<T>
 
- 
getHeaders- Specified by:
- getHeadersin class- AbstractIntegrationMessageBuilder<T>
 
- 
getHeader
- 
setHeaderSet the value for the given header name. If the provided value isnull, the header will be removed.- Specified by:
- setHeaderin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headerName- The header name.
- headerValue- The header value.
- Returns:
- this MessageBuilder.
 
- 
setHeaderIfAbsentSet the value for the given header name only if the header name is not already associated with a value.- Specified by:
- setHeaderIfAbsentin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headerName- The header name.
- headerValue- The header value.
- Returns:
- this MessageBuilder.
 
- 
removeHeadersRemoves 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*andxxx*yyy.- Specified by:
- removeHeadersin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headerPatterns- The header patterns.
- Returns:
- this MessageBuilder.
 
- 
removeHeaderRemove the value for the given header name.- Specified by:
- removeHeaderin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headerName- The header name.
- Returns:
- this MessageBuilder.
 
- 
copyHeadersCopy the name-value pairs from the provided Map. This operation will overwrite any existing values. UsecopyHeadersIfAbsent(Map)to avoid overwriting values. Note that the 'id' and 'timestamp' header values will never be overwritten.- Specified by:
- copyHeadersin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headersToCopy- The headers to copy.
- Returns:
- this MessageBuilder.
- See Also:
 
- 
copyHeadersIfAbsentCopy the name-value pairs from the provided Map. This operation will not override any existing values.- Specified by:
- copyHeadersIfAbsentin class- AbstractIntegrationMessageBuilder<T>
- Parameters:
- headersToCopy- The headers to copy.
- Returns:
- this MessageBuilder.
 
- 
getSequenceDetails- Specified by:
- getSequenceDetailsin class- AbstractIntegrationMessageBuilder<T>
 
- 
getCorrelationId- Specified by:
- getCorrelationIdin class- AbstractIntegrationMessageBuilder<T>
 
- 
getSequenceNumber- Specified by:
- getSequenceNumberin class- AbstractIntegrationMessageBuilder<T>
 
- 
getSequenceSize- Specified by:
- getSequenceSizein class- AbstractIntegrationMessageBuilder<T>
 
- 
pushSequenceDetails- Overrides:
- pushSequenceDetailsin class- AbstractIntegrationMessageBuilder<T>
 
- 
popSequenceDetails- Overrides:
- popSequenceDetailsin class- AbstractIntegrationMessageBuilder<T>
 
- 
setExpirationDate- Overrides:
- setExpirationDatein class- AbstractIntegrationMessageBuilder<T>
 
- 
setExpirationDate- Overrides:
- setExpirationDatein class- AbstractIntegrationMessageBuilder<T>
 
- 
setCorrelationId- Overrides:
- setCorrelationIdin class- AbstractIntegrationMessageBuilder<T>
 
- 
setReplyChannel- Overrides:
- setReplyChannelin class- AbstractIntegrationMessageBuilder<T>
 
- 
setReplyChannelName- Overrides:
- setReplyChannelNamein class- AbstractIntegrationMessageBuilder<T>
 
- 
setErrorChannel- Overrides:
- setErrorChannelin class- AbstractIntegrationMessageBuilder<T>
 
- 
setErrorChannelName- Overrides:
- setErrorChannelNamein class- AbstractIntegrationMessageBuilder<T>
 
- 
setSequenceNumber- Overrides:
- setSequenceNumberin class- AbstractIntegrationMessageBuilder<T>
 
- 
setSequenceSize- Overrides:
- setSequenceSizein class- AbstractIntegrationMessageBuilder<T>
 
- 
setPriority- Overrides:
- setPriorityin class- AbstractIntegrationMessageBuilder<T>
 
- 
readOnlyHeadersSpecify a list of headers which should be considered as read only and prohibited from being populated in the message.- Parameters:
- readOnlyHeaders- the list of headers for- readOnlymode. Defaults to- MessageHeaders.IDand- MessageHeaders.TIMESTAMP.
- Returns:
- the current BaseMessageBuilder
- See Also:
 
- 
buildReturn an original message instance if it is not modified and does not have read-only headers. If payload is an instance ofThrowable, then anErrorMessageis built. Otherwise, a new instance ofGenericMessageis produced. This method can be overridden to provide any custom message implementations.- Specified by:
- buildin class- AbstractIntegrationMessageBuilder<T>
- Returns:
- the message instance
- See Also:
 
 
-