MessageHeaderAccessor subclass that supports storage and access of
headers from an external source such as a message broker. Headers from the
external source are kept separate from other headers, in a sub-map under the
key NATIVE_HEADERS. This allows separating processing headers from
headers that need to be sent to or received from the external source.
This class is likely to be used indirectly through a protocol-specific subclass that also provides factory methods to translate message headers to and from an external messaging source.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | NATIVE_HEADERS
The header name used to store native headers. |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | NativeMessageHeaderAccessor(Map<String, List<String>>
native headers to create the message with (may be nativeHeaders)null)Protected constructor to create an instance with the given native headers. |
| protected | NativeMessageHeaderAccessor(Message<?> message)
Protected constructor that copies headers from another message. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addNativeHeader(String
the name of the header name, String the header value to set value)Add the specified native header value to existing values. |
| public void | addNativeHeaders(MultiValueMap<String, String>
the headers to set headers)Add the specified native headers to existing values. |
| public boolean | containsNativeHeader(String
the name of the header headerName)Whether the native header map contains the give header name. |
| public void | copyHeaders(Map<String, ?> headersToCopy)
Overrides org. |
| public void | copyHeadersIfAbsent(Map<String, ?> headersToCopy)
Overrides org. |
| public String | Returns: the associated value, ornull if nonethe name of the header headerName)Return the first value for the specified native header, if present. |
| public static String | Returns: the associated value, ornull if nonethe name of the header headerName, Map<String, Object> the headers map to introspect headers)Return the first value for the specified native header,
or |
| public List | Returns: the associated values, ornull if nonethe name of the header headerName)Return all values for the specified native header, if present. |
| protected Map | |
| public List | Returns: the associated values, ornull if the header was not presentthe name of the header headerName)Remove the specified native header value replacing existing values. |
| public void | setImmutable()
Overrides org. getMessageHeaders() is called, "this"
MessageHeaderAccessor instance can no longer be used to modify the
underlying message headers.
|
| public void | setNativeHeader(String name, String value)
Set the specified native header value replacing existing values. |
| public void | setNativeHeaderValues(String name, List<String> values)
Variant of |
| public Map |
| NATIVE_HEADERS | back to summary |
|---|---|
| public static final String NATIVE_HEADERS The header name used to store native headers. | |
| NativeMessageHeaderAccessor | back to summary |
|---|---|
| protected NativeMessageHeaderAccessor() Protected constructor to create a new instance. | |
| NativeMessageHeaderAccessor | back to summary |
|---|---|
| protected NativeMessageHeaderAccessor(Map<String, List<String>> nativeHeaders) Protected constructor to create an instance with the given native headers. | |
| NativeMessageHeaderAccessor | back to summary |
|---|---|
| protected NativeMessageHeaderAccessor(Message<?> message) Protected constructor that copies headers from another message. | |
| addNativeHeader | back to summary |
|---|---|
| public void addNativeHeader(String name, String value) Add the specified native header value to existing values. In order for this to work, the accessor must be | |
| addNativeHeaders | back to summary |
|---|---|
| public void addNativeHeaders(MultiValueMap<String, String> headers) Add the specified native headers to existing values.
| |
| containsNativeHeader | back to summary |
|---|---|
| public boolean containsNativeHeader(String headerName) Whether the native header map contains the give header name.
| |
| copyHeaders | back to summary |
|---|---|
| public void copyHeaders(Map<String, ?> headersToCopy) Overrides org. Doc from org. Copy the name-value pairs from the provided Map. This operation will overwrite any existing values. Use
| |
| copyHeadersIfAbsent | back to summary |
|---|---|
| public void copyHeadersIfAbsent(Map<String, ?> headersToCopy) Overrides org. Doc from org. Copy the name-value pairs from the provided Map. This operation will not overwrite any existing values.
| |
| getFirstNativeHeader | back to summary |
|---|---|
| public String getFirstNativeHeader(String headerName) Return the first value for the specified native header, if present. | |
| getFirstNativeHeader | back to summary |
|---|---|
| public static String getFirstNativeHeader(String headerName, Map<String, Object> headers) Return the first value for the specified native header,
or | |
| getNativeHeader | back to summary |
|---|---|
| public List Return all values for the specified native header, if present. | |
| getNativeHeaders | back to summary |
|---|---|
| protected Map Subclasses can use this method to access the "native" headers sub-map.
| |
| removeNativeHeader | back to summary |
|---|---|
| public List Remove the specified native header value replacing existing values. In order for this to work, the accessor must be | |
| setImmutable | back to summary |
|---|---|
| public void setImmutable() Overrides org. Doc from org. By default, when
| |
| setNativeHeader | back to summary |
|---|---|
| public void setNativeHeader(String name, String value) Set the specified native header value replacing existing values. In order for this to work, the accessor must be | |
| setNativeHeaderValues | back to summary |
|---|---|
| public void setNativeHeaderValues(String name, List<String> values) Variant of
| |
| toNativeHeaderMap | back to summary |
|---|---|
| public Map Return a copy of the native headers sub-map, or an empty map. | |