Spring Integration

org.springframework.integration.mapping
Class AbstractHeaderMapper<T>

java.lang.Object
  extended by org.springframework.integration.mapping.AbstractHeaderMapper<T>
All Implemented Interfaces:
RequestReplyHeaderMapper<T>
Direct Known Subclasses:
DefaultAmqpHeaderMapper, DefaultSoapHeaderMapper, DefaultXmppHeaderMapper

public abstract class AbstractHeaderMapper<T>
extends java.lang.Object
implements RequestReplyHeaderMapper<T>

Abstract base class for HeaderMapper implementations.

Since:
2.1
Author:
Mark Fisher, Oleg Zhurakousky

Field Summary
protected  org.apache.commons.logging.Log logger
           
static java.lang.String STANDARD_REPLY_HEADER_NAME_PATTERN
           
static java.lang.String STANDARD_REQUEST_HEADER_NAME_PATTERN
           
 
Constructor Summary
protected AbstractHeaderMapper()
           
 
Method Summary
protected abstract  java.util.Map<java.lang.String,java.lang.Object> extractStandardHeaders(T source)
           
protected abstract  java.util.Map<java.lang.String,java.lang.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(java.util.Map<java.lang.String,java.lang.Object> headers, java.lang.String name, java.lang.Class<V> type)
           
protected abstract  java.lang.String getStandardHeaderPrefix()
          Returns the list of standard REPLY headers.
protected  java.util.List<java.lang.String> getStandardReplyHeaderNames()
          Returns the list of standard REQUEST headers.
protected  java.util.List<java.lang.String> getStandardRequestHeaderNames()
          Returns the PREFIX used by standard headers (if any)
protected abstract  void populateStandardHeaders(java.util.Map<java.lang.String,java.lang.Object> headers, T target)
           
protected abstract  void populateUserDefinedHeader(java.lang.String headerName, java.lang.Object headerValue, T target)
           
 void setReplyHeaderNames(java.lang.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(java.lang.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(java.lang.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.
 java.util.Map<java.lang.String,java.lang.Object> toHeadersFromReply(T source)
          Maps headers/properties of the target object to Map of MessageHeaders matching on the set of REPLY headers
 java.util.Map<java.lang.String,java.lang.Object> toHeadersFromRequest(T source)
          Maps headers/properties of the target object to Map of MessageHeaders matching on the set of REQUEST headers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD_REQUEST_HEADER_NAME_PATTERN

public static final java.lang.String STANDARD_REQUEST_HEADER_NAME_PATTERN
See Also:
Constant Field Values

STANDARD_REPLY_HEADER_NAME_PATTERN

public static final java.lang.String STANDARD_REPLY_HEADER_NAME_PATTERN
See Also:
Constant Field Values

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

AbstractHeaderMapper

protected AbstractHeaderMapper()
Method Detail

setRequestHeaderNames

public void setRequestHeaderNames(java.lang.String[] requestHeaderNames)
Provide the header names that should be mapped from a request (for inbound/outbound adapters) TO a Spring Integration Message's headers. The values can also contain simple wildcard patterns (e.g. "foo*" or "*foo") to be matched.

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).


setReplyHeaderNames

public void setReplyHeaderNames(java.lang.String[] replyHeaderNames)
Provide the header names that should be mapped to a response (for inbound/outbound adapters) FROM a Spring Integration Message's headers. The values can also contain simple wildcard patterns (e.g. "foo*" or "*foo") to be matched.

Any non-standard headers will be prefixed with the value specified by setUserDefinedHeaderPrefix(String).


setUserDefinedHeaderPrefix

public void setUserDefinedHeaderPrefix(java.lang.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.

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).


fromHeadersToRequest

public 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).

Specified by:
fromHeadersToRequest in interface RequestReplyHeaderMapper<T>

fromHeadersToReply

public 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).

Specified by:
fromHeadersToReply in interface RequestReplyHeaderMapper<T>

toHeadersFromRequest

public java.util.Map<java.lang.String,java.lang.Object> toHeadersFromRequest(T source)
Maps headers/properties of the target object to Map of MessageHeaders matching on the set of REQUEST headers

Specified by:
toHeadersFromRequest in interface RequestReplyHeaderMapper<T>

toHeadersFromReply

public java.util.Map<java.lang.String,java.lang.Object> toHeadersFromReply(T source)
Maps headers/properties of the target object to Map of MessageHeaders matching on the set of REPLY headers

Specified by:
toHeadersFromReply in interface RequestReplyHeaderMapper<T>

getHeaderIfAvailable

protected <V> V getHeaderIfAvailable(java.util.Map<java.lang.String,java.lang.Object> headers,
                                     java.lang.String name,
                                     java.lang.Class<V> type)

getStandardReplyHeaderNames

protected java.util.List<java.lang.String> getStandardReplyHeaderNames()
Returns the list of standard REQUEST headers. Implementation provided by a subclass


getStandardRequestHeaderNames

protected java.util.List<java.lang.String> getStandardRequestHeaderNames()
Returns the PREFIX used by standard headers (if any)


getStandardHeaderPrefix

protected abstract java.lang.String getStandardHeaderPrefix()
Returns the list of standard REPLY headers. Implementation provided by a subclass


extractStandardHeaders

protected abstract java.util.Map<java.lang.String,java.lang.Object> extractStandardHeaders(T source)

extractUserDefinedHeaders

protected abstract java.util.Map<java.lang.String,java.lang.Object> extractUserDefinedHeaders(T source)

populateStandardHeaders

protected abstract void populateStandardHeaders(java.util.Map<java.lang.String,java.lang.Object> headers,
                                                T target)

populateUserDefinedHeader

protected abstract void populateUserDefinedHeader(java.lang.String headerName,
                                                  java.lang.Object headerValue,
                                                  T target)

Spring Integration