public abstract class AbstractHeaderMapper<T> extends Object implements RequestReplyHeaderMapper<T>
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
static String |
STANDARD_REPLY_HEADER_NAME_PATTERN |
static String |
STANDARD_REQUEST_HEADER_NAME_PATTERN |
Modifier | Constructor and Description |
---|---|
protected |
AbstractHeaderMapper() |
Modifier and Type | Method and Description |
---|---|
protected abstract Map<String,Object> |
extractStandardHeaders(T source) |
protected abstract Map<String,Object> |
extractUserDefinedHeaders(T source) |
void |
fromHeadersToReply(MessageHeaders headers,
T target)
Maps headers from a Spring Integration MessageHeaders instance to the target instance
matching on the set of REPLY headers (if different).
|
void |
fromHeadersToRequest(MessageHeaders headers,
T target)
Maps headers from a Spring Integration MessageHeaders instance to the target instance
matching on the set of REQUEST headers (if different).
|
protected <V> V |
getHeaderIfAvailable(Map<String,Object> headers,
String name,
Class<V> type) |
protected abstract String |
getStandardHeaderPrefix() |
protected List<String> |
getStandardReplyHeaderNames() |
protected List<String> |
getStandardRequestHeaderNames() |
protected abstract void |
populateStandardHeaders(Map<String,Object> headers,
T target) |
protected abstract void |
populateUserDefinedHeader(String headerName,
Object headerValue,
T target) |
void |
setReplyHeaderNames(String[] replyHeaderNames)
Provide the header names that should be mapped to a response (for inbound/outbound adapters)
FROM a Spring Integration Message's headers.
|
void |
setRequestHeaderNames(String[] requestHeaderNames)
Provide the header names that should be mapped from a request (for inbound/outbound adapters)
TO a Spring Integration Message's headers.
|
void |
setUserDefinedHeaderPrefix(String userDefinedHeaderPrefix)
Specify a prefix to be prepended to the header name for any integration
message header that is being mapped to or from a user-defined value.
|
Map<String,Object> |
toHeadersFromReply(T source)
Maps headers/properties of the target object to Map of MessageHeaders
matching on the set of REPLY headers
|
Map<String,Object> |
toHeadersFromRequest(T source)
Maps headers/properties of the target object to Map of MessageHeaders
matching on the set of REQUEST headers
|
public static final String STANDARD_REQUEST_HEADER_NAME_PATTERN
public static final String STANDARD_REPLY_HEADER_NAME_PATTERN
protected final org.apache.commons.logging.Log logger
public void setRequestHeaderNames(String[] requestHeaderNames)
This will match the header name directly or, for non-standard headers, it will match
the header name prefixed with the value, if specified, by setUserDefinedHeaderPrefix(String)
.
requestHeaderNames
- The request header names.public void setReplyHeaderNames(String[] replyHeaderNames)
Any non-standard headers will be prefixed with the value specified by setUserDefinedHeaderPrefix(String)
.
replyHeaderNames
- The reply header names.public void setUserDefinedHeaderPrefix(String userDefinedHeaderPrefix)
This does not affect the standard properties for the particular protocol, such as contentType for AMQP, etc. The header names used for mapping such properties are defined in a corresponding Headers class as constants (e.g. AmqpHeaders).
userDefinedHeaderPrefix
- The user defined header prefix.public void fromHeadersToRequest(MessageHeaders headers, T target)
fromHeadersToRequest
in interface RequestReplyHeaderMapper<T>
headers
- The headers.target
- The target.public void fromHeadersToReply(MessageHeaders headers, T target)
fromHeadersToReply
in interface RequestReplyHeaderMapper<T>
headers
- The headers.target
- The target.public Map<String,Object> toHeadersFromRequest(T source)
toHeadersFromRequest
in interface RequestReplyHeaderMapper<T>
source
- The source.public Map<String,Object> toHeadersFromReply(T source)
toHeadersFromReply
in interface RequestReplyHeaderMapper<T>
source
- The source.protected <V> V getHeaderIfAvailable(Map<String,Object> headers, String name, Class<V> type)
protected List<String> getStandardReplyHeaderNames()
protected List<String> getStandardRequestHeaderNames()
protected abstract String getStandardHeaderPrefix()
protected abstract void populateStandardHeaders(Map<String,Object> headers, T target)