|
|
|
@ -82,7 +82,7 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sub-classes can use this method to access the "native" headers sub-map. |
|
|
|
* Subclasses can use this method to access the "native" headers sub-map. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
@ -139,6 +139,7 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Whether the native header map contains the give header name. |
|
|
|
* Whether the native header map contains the give header name. |
|
|
|
|
|
|
|
* @param headerName the name of the header |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean containsNativeHeader(String headerName) { |
|
|
|
public boolean containsNativeHeader(String headerName) { |
|
|
|
Map<String, List<String>> map = getNativeHeaders(); |
|
|
|
Map<String, List<String>> map = getNativeHeaders(); |
|
|
|
@ -146,7 +147,9 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the values for the specified native header, if present. |
|
|
|
* Return all values for the specified native header, if present. |
|
|
|
|
|
|
|
* @param headerName the name of the header |
|
|
|
|
|
|
|
* @return the associated values, or {@code null} if none |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
public List<String> getNativeHeader(String headerName) { |
|
|
|
public List<String> getNativeHeader(String headerName) { |
|
|
|
@ -156,13 +159,15 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the first value for the specified native header, if present. |
|
|
|
* Return the first value for the specified native header, if present. |
|
|
|
|
|
|
|
* @param headerName the name of the header |
|
|
|
|
|
|
|
* @return the associated value, or {@code null} if none |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
public String getFirstNativeHeader(String headerName) { |
|
|
|
public String getFirstNativeHeader(String headerName) { |
|
|
|
Map<String, List<String>> map = getNativeHeaders(); |
|
|
|
Map<String, List<String>> map = getNativeHeaders(); |
|
|
|
if (map != null) { |
|
|
|
if (map != null) { |
|
|
|
List<String> values = map.get(headerName); |
|
|
|
List<String> values = map.get(headerName); |
|
|
|
if (values != null) { |
|
|
|
if (!CollectionUtils.isEmpty(values)) { |
|
|
|
return values.get(0); |
|
|
|
return values.get(0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -200,6 +205,8 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { |
|
|
|
* Add the specified native header value to existing values. |
|
|
|
* Add the specified native header value to existing values. |
|
|
|
* <p>In order for this to work, the accessor must be {@link #isMutable() |
|
|
|
* <p>In order for this to work, the accessor must be {@link #isMutable() |
|
|
|
* mutable}. See {@link MessageHeaderAccessor} for details. |
|
|
|
* mutable}. See {@link MessageHeaderAccessor} for details. |
|
|
|
|
|
|
|
* @param name the name of the header |
|
|
|
|
|
|
|
* @param value the header value to set |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void addNativeHeader(String name, @Nullable String value) { |
|
|
|
public void addNativeHeader(String name, @Nullable String value) { |
|
|
|
Assert.state(isMutable(), "Already immutable"); |
|
|
|
Assert.state(isMutable(), "Already immutable"); |
|
|
|
@ -216,6 +223,10 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { |
|
|
|
setModified(true); |
|
|
|
setModified(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Add the specified native headers to existing values. |
|
|
|
|
|
|
|
* @param headers the headers to set |
|
|
|
|
|
|
|
*/ |
|
|
|
public void addNativeHeaders(@Nullable MultiValueMap<String, String> headers) { |
|
|
|
public void addNativeHeaders(@Nullable MultiValueMap<String, String> headers) { |
|
|
|
if (headers == null) { |
|
|
|
if (headers == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
@ -227,24 +238,34 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { |
|
|
|
* Remove the specified native header value replacing existing values. |
|
|
|
* Remove the specified native header value replacing existing values. |
|
|
|
* <p>In order for this to work, the accessor must be {@link #isMutable() |
|
|
|
* <p>In order for this to work, the accessor must be {@link #isMutable() |
|
|
|
* mutable}. See {@link MessageHeaderAccessor} for details. |
|
|
|
* mutable}. See {@link MessageHeaderAccessor} for details. |
|
|
|
|
|
|
|
* @param headerName the name of the header |
|
|
|
|
|
|
|
* @return the associated values, or {@code null} if the header was not present |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
public List<String> removeNativeHeader(String name) { |
|
|
|
public List<String> removeNativeHeader(String headerName) { |
|
|
|
Assert.state(isMutable(), "Already immutable"); |
|
|
|
Assert.state(isMutable(), "Already immutable"); |
|
|
|
Map<String, List<String>> nativeHeaders = getNativeHeaders(); |
|
|
|
Map<String, List<String>> nativeHeaders = getNativeHeaders(); |
|
|
|
if (nativeHeaders == null) { |
|
|
|
if (CollectionUtils.isEmpty(nativeHeaders)) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return nativeHeaders.remove(name); |
|
|
|
return nativeHeaders.remove(headerName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return the first value for the specified native header, |
|
|
|
|
|
|
|
* or {@code null} if none. |
|
|
|
|
|
|
|
* @param headerName the name of the header |
|
|
|
|
|
|
|
* @param headers the headers map to introspect |
|
|
|
|
|
|
|
* @return the associated value, or {@code null} if none |
|
|
|
|
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
public static String getFirstNativeHeader(String headerName, Map<String, Object> headers) { |
|
|
|
public static String getFirstNativeHeader(String headerName, Map<String, Object> headers) { |
|
|
|
Map<String, List<String>> map = (Map<String, List<String>>) headers.get(NATIVE_HEADERS); |
|
|
|
Map<String, List<String>> map = (Map<String, List<String>>) headers.get(NATIVE_HEADERS); |
|
|
|
if (map != null) { |
|
|
|
if (map != null) { |
|
|
|
List<String> values = map.get(headerName); |
|
|
|
List<String> values = map.get(headerName); |
|
|
|
if (values != null) { |
|
|
|
if (!CollectionUtils.isEmpty(values)) { |
|
|
|
return values.get(0); |
|
|
|
return values.get(0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|