Example usage for org.springframework.messaging MessageHeaders entrySet

List of usage examples for org.springframework.messaging MessageHeaders entrySet

Introduction

In this page you can find the example usage for org.springframework.messaging MessageHeaders entrySet.

Prototype

public Set<Map.Entry<String, Object>> entrySet() 

Source Link

Usage

From source file:org.springframework.cloud.iot.integration.coap.support.DefaultCoapHeaderMapper.java

@Override
public void fromHeaders(MessageHeaders headers, CoapHeaders coapHeaders) {
    if (logger.isDebugEnabled()) {
        logger.debug(MessageFormat.format("outboundHeaderNames={0}",
                CollectionUtils.arrayToList(this.outboundHeaderNames)));
    }/* w  w  w .  j  a  v  a  2s.  co  m*/

    for (Entry<String, Object> entry : headers.entrySet()) {
        String name = entry.getKey();
        String lowerName = name.toLowerCase();
    }

    String gatewayService = headers.get("iotGatewayServiceRoute", String.class);
    if (StringUtils.hasText(gatewayService)) {
        coapHeaders.add(9999, gatewayService.getBytes());
    }
}

From source file:org.springframework.cloud.stream.app.http.source.DefaultMixedCaseContentTypeHttpHeaderMapper.java

/**
 * Map from the integration MessageHeaders to an HttpHeaders instance.
 * Depending on which type of adapter is using this mapper, the HttpHeaders might be
 * for an HTTP request (outbound adapter) or for an HTTP response (inbound adapter).
 *//* w w w  .  ja  v  a  2 s. c o m*/
@Override
public void fromHeaders(MessageHeaders headers, HttpHeaders target) {
    if (logger.isDebugEnabled()) {
        logger.debug(MessageFormat.format("outboundHeaderNames={0}",
                CollectionUtils.arrayToList(this.outboundHeaderNames)));
    }
    for (Entry<String, Object> entry : headers.entrySet()) {
        String name = entry.getKey();
        String lowerName = name.toLowerCase();
        if (this.shouldMapOutboundHeader(lowerName)) {
            Object value = entry.getValue();
            if (value != null) {
                if (!HTTP_REQUEST_HEADER_NAMES_LOWER.contains(lowerName)
                        && !HTTP_RESPONSE_HEADER_NAMES_LOWER.contains(lowerName)
                        && !MessageHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) {
                    // prefix the user-defined header names if not already prefixed

                    name = StringUtils.startsWithIgnoreCase(name, this.userDefinedHeaderPrefix) ? name
                            : this.userDefinedHeaderPrefix + name;
                }
                if (logger.isDebugEnabled()) {
                    logger.debug(MessageFormat.format("setting headerName=[{0}], value={1}", name, value));
                }
                this.setHttpHeader(target, name, value);
            }
        }
    }
}

From source file:org.springframework.integration.stomp.support.StompHeaderMapper.java

@Override
@SuppressWarnings("unchecked")
public void fromHeaders(MessageHeaders headers, StompHeaders target) {
    for (Map.Entry<String, Object> entry : headers.entrySet()) {
        String name = entry.getKey();
        if (shouldMapHeader(name, this.outboundHeaderNames)) {
            Object value = entry.getValue();
            if (value != null) {
                setStompHeader(target, name, value);
            }//from ww  w .  ja  va 2s  . c om
        } else if (StompHeaderAccessor.NATIVE_HEADERS.equals(name)) {
            MultiValueMap<String, String> multiValueMap = headers.get(StompHeaderAccessor.NATIVE_HEADERS,
                    MultiValueMap.class);
            for (Map.Entry<String, List<String>> entry1 : multiValueMap.entrySet()) {
                name = entry1.getKey();
                if (shouldMapHeader(name, this.outboundHeaderNames)) {
                    String value = entry1.getValue().get(0);
                    if (StringUtils.hasText(value)) {
                        setStompHeader(target, name, value);
                    }
                }
            }
        }
    }
}

From source file:org.springframework.integration.support.json.EmbeddedJsonHeadersMessageMapper.java

private Map<String, Object> pruneHeaders(MessageHeaders messageHeaders) {
    return messageHeaders.entrySet().stream().filter(e -> matchHeader(e.getKey()))
            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}