Example usage for org.springframework.messaging.simp SimpMessageMappingInfo getDestinationConditions

List of usage examples for org.springframework.messaging.simp SimpMessageMappingInfo getDestinationConditions

Introduction

In this page you can find the example usage for org.springframework.messaging.simp SimpMessageMappingInfo getDestinationConditions.

Prototype

public DestinationPatternsMessageCondition getDestinationConditions() 

Source Link

Usage

From source file:org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler.java

@Override
protected Set<String> getDirectLookupDestinations(SimpMessageMappingInfo mapping) {
    Set<String> result = new LinkedHashSet<>();
    for (String pattern : mapping.getDestinationConditions().getPatterns()) {
        if (!this.pathMatcher.isPattern(pattern)) {
            result.add(pattern);//from   w w w.j  a v  a2 s  . c  om
        }
    }
    return result;
}

From source file:org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler.java

@Override
protected void handleMatch(SimpMessageMappingInfo mapping, HandlerMethod handlerMethod,
        String lookupDestination, Message<?> message) {

    Set<String> patterns = mapping.getDestinationConditions().getPatterns();
    if (!CollectionUtils.isEmpty(patterns)) {
        String pattern = patterns.iterator().next();
        Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(pattern, lookupDestination);
        if (!CollectionUtils.isEmpty(vars)) {
            MessageHeaderAccessor mha = MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class);
            Assert.state(mha != null && mha.isMutable(), "Mutable MessageHeaderAccessor required");
            mha.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER,
                    vars);// w w  w.j  av  a 2s . c o  m
        }
    }

    try {
        SimpAttributesContextHolder.setAttributesFromMessage(message);
        super.handleMatch(mapping, handlerMethod, lookupDestination, message);
    } finally {
        SimpAttributesContextHolder.resetAttributes();
    }
}