Class AbstractHeaderMapper<T>
java.lang.Object
org.springframework.integration.mapping.AbstractHeaderMapper<T>
- Type Parameters:
- T- the target headers container type.
- All Implemented Interfaces:
- Aware,- BeanClassLoaderAware,- RequestReplyHeaderMapper<T>
- Direct Known Subclasses:
- DefaultAmqpHeaderMapper,- DefaultSoapHeaderMapper,- DefaultXmppHeaderMapper
public abstract class AbstractHeaderMapper<T>
extends Object
implements RequestReplyHeaderMapper<T>, BeanClassLoaderAware
Abstract base class for 
RequestReplyHeaderMapper implementations.- Since:
- 2.1
- Author:
- Mark Fisher, Oleg Zhurakousky, Stephane Nicoll, Gary Russell, Artem Bilan, Glenn Renfro
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classA compositeAbstractHeaderMapper.HeaderMatcherthat matches if one of providedAbstractHeaderMapper.HeaderMatchers matches to theheaderName.protected static classA content-basedAbstractHeaderMapper.HeaderMatcherthat matches if the specified header is contained within a list of candidates.static interfaceStrategy interface to determine if a given header name matches.protected static classA pattern-basedAbstractHeaderMapper.HeaderMatcherthat matches if the specified header matches one of the specified simple patterns.protected static classA prefix-basedAbstractHeaderMapper.HeaderMatcherthat matches if the specified header starts with a configurable prefix.protected static classA pattern-basedAbstractHeaderMapper.HeaderMatcherthat matches if the specified header matches the specified simple pattern.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final Logstatic final StringA special pattern that matches any header that is not a standard header (i.e.static final StringA special pattern that only matches standard reply headers.static final StringA special pattern that only matches standard request headers.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractHeaderMapper(String standardHeaderPrefix, Collection<String> requestHeaderNames, Collection<String> replyHeaderNames) Create a new instance.
- 
Method SummaryModifier and TypeMethodDescriptionprotected AbstractHeaderMapper.HeaderMatchercreateDefaultHeaderMatcher(String standardHeaderPrefix, Collection<String> headerNames) Create the initialAbstractHeaderMapper.HeaderMatcherbased on the specified headers and standard header prefix.protected AbstractHeaderMapper.HeaderMatchercreateHeaderMatcher(Collection<String> patterns) Create aAbstractHeaderMapper.HeaderMatcherthat match if any of the specifiedpatternsmatch.protected StringcreateTargetPropertyName(String propertyName, boolean fromMessageHeaders) Alter the specifiedpropertyNameif necessary.extractStandardHeaders(T source) Extract the standard headers from the specified source.extractUserDefinedHeaders(T source) Extract the user-defined headers from the specified source.voidfromHeadersToReply(MessageHeaders headers, T target) Map from the givenMessageHeadersto the specified reply target.voidfromHeadersToRequest(MessageHeaders headers, T target) Map from the givenMessageHeadersto the specified request target.protected @Nullable ClassLoaderprotected <V> @Nullable Vprotected Collection<String> Return the transient header names.protected voidpopulateStandardHeaders(@Nullable Map<String, Object> allHeaders, Map<String, Object> subset, T target) Populate the specified standard headers to the specified source.protected abstract voidpopulateStandardHeaders(Map<String, Object> headers, T target) Populate the specified standard headers to the specified source.protected abstract voidpopulateUserDefinedHeader(String headerName, Object headerValue, T target) Populate the specified user-defined headers to the specified source.voidsetBeanClassLoader(ClassLoader classLoader) voidsetReplyHeaderNames(String... replyHeaderNames) Provide the header names that should be mapped to a response from aMessageHeaders.voidsetRequestHeaderNames(String... requestHeaderNames) Provide the header names that should be mapped from a request to aMessageHeaders.toHeadersFromReply(T source) Map from the given reply object to abstractedMessageHeaders.toHeadersFromRequest(T source) Map from the given request object to abstractedMessageHeaders.
- 
Field Details- 
STANDARD_REQUEST_HEADER_NAME_PATTERNA special pattern that only matches standard request headers.- See Also:
 
- 
STANDARD_REPLY_HEADER_NAME_PATTERNA special pattern that only matches standard reply headers.- See Also:
 
- 
NON_STANDARD_HEADER_NAME_PATTERNA special pattern that matches any header that is not a standard header (i.e. any header that does not start with the configured standard header prefix)- See Also:
 
- 
logger
 
- 
- 
Constructor Details- 
AbstractHeaderMapperprotected AbstractHeaderMapper(String standardHeaderPrefix, Collection<String> requestHeaderNames, Collection<String> replyHeaderNames) Create a new instance.- Parameters:
- standardHeaderPrefix- the header prefix that identifies standard header. Such prefix helps to differentiate user-defined headers from standard headers. If set, user-defined headers are also mapped by default
- requestHeaderNames- the header names that should be mapped from a request to- MessageHeaders
- replyHeaderNames- the header names that should be mapped to a response from- MessageHeaders
 
 
- 
- 
Method Details- 
setBeanClassLoader- Specified by:
- setBeanClassLoaderin interface- BeanClassLoaderAware
 
- 
getClassLoader
- 
setRequestHeaderNamesProvide the header names that should be mapped from a request to aMessageHeaders.The values can also contain simple wildcard patterns (e.g. "foo*" or "*foo") to be matched. - Parameters:
- requestHeaderNames- The request header names.
 
- 
setReplyHeaderNamesProvide the header names that should be mapped to a response from aMessageHeaders.The values can also contain simple wildcard patterns (e.g. "foo*" or "*foo") to be matched. - Parameters:
- replyHeaderNames- The reply header names.
 
- 
createDefaultHeaderMatcherprotected AbstractHeaderMapper.HeaderMatcher createDefaultHeaderMatcher(String standardHeaderPrefix, Collection<String> headerNames) Create the initialAbstractHeaderMapper.HeaderMatcherbased on the specified headers and standard header prefix.- Parameters:
- standardHeaderPrefix- the prefix for standard headers.
- headerNames- the collection of header names to map.
- Returns:
- the default AbstractHeaderMapper.HeaderMatcherinstance.
 
- 
createHeaderMatcherCreate aAbstractHeaderMapper.HeaderMatcherthat match if any of the specifiedpatternsmatch. The pattern can be a header name, a wildcard pattern such asfoo*,*foo, orwithin*foo.Special patterns are also recognized: STANDARD_REQUEST_HEADER_NAME_PATTERN,STANDARD_REQUEST_HEADER_NAME_PATTERNandNON_STANDARD_HEADER_NAME_PATTERN.- Parameters:
- patterns- the patterns to apply
- Returns:
- a header mapper that match if any of the specified patters match
 
- 
fromHeadersToRequestDescription copied from interface:RequestReplyHeaderMapperMap from the givenMessageHeadersto the specified request target.- Specified by:
- fromHeadersToRequestin interface- RequestReplyHeaderMapper<T>
- Parameters:
- headers- the abstracted MessageHeaders
- target- the native target request
 
- 
fromHeadersToReplyDescription copied from interface:RequestReplyHeaderMapperMap from the givenMessageHeadersto the specified reply target.- Specified by:
- fromHeadersToReplyin interface- RequestReplyHeaderMapper<T>
- Parameters:
- headers- the abstracted MessageHeaders
- target- the native target reply
 
- 
toHeadersFromRequestDescription copied from interface:RequestReplyHeaderMapperMap from the given request object to abstractedMessageHeaders.- Specified by:
- toHeadersFromRequestin interface- RequestReplyHeaderMapper<T>
- Parameters:
- source- the native target request
- Returns:
- the abstracted MessageHeaders
 
- 
toHeadersFromReplyDescription copied from interface:RequestReplyHeaderMapperMap from the given reply object to abstractedMessageHeaders.- Specified by:
- toHeadersFromReplyin interface- RequestReplyHeaderMapper<T>
- Parameters:
- source- the native target reply
- Returns:
- the abstracted MessageHeaders
 
- 
getHeaderIfAvailable
- 
createTargetPropertyNameAlter the specifiedpropertyNameif necessary. By default, the originalpropertyNameis returned.- Parameters:
- propertyName- the original name of the property.
- fromMessageHeaders- specify if the property originates from a- MessageHeadersinstance (true) or from the type managed by this mapper (false).
- Returns:
- the property name for mapping.
 
- 
getTransientHeaderNamesReturn the transient header names. Transient headers are never mapped.- Returns:
- the names of headers to be skipped from mapping.
 
- 
extractStandardHeaders
- 
extractUserDefinedHeaders
- 
populateStandardHeaders
- 
populateStandardHeadersprotected void populateStandardHeaders(@Nullable Map<String, Object> allHeaders, Map<String, Object> subset, T target) Populate the specified standard headers to the specified source. If not implemented, callspopulateStandardHeaders(Map, Object).- Parameters:
- allHeaders- all headers including transient.
- subset- the map of standard headers to be populated.
- target- the target object to populate headers.
- Since:
- 5.1
 
- 
populateUserDefinedHeaderPopulate the specified user-defined headers to the specified source.- Parameters:
- headerName- the user defined header name to be populated.
- headerValue- the user defined header value to be populated.
- target- the target object to populate headers.
 
 
-