@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); } } return result; }
@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); } } try { SimpAttributesContextHolder.setAttributesFromMessage(message); super.handleMatch(mapping, handlerMethod, lookupDestination, message); } finally { SimpAttributesContextHolder.resetAttributes(); } }
@Test public void prependNonEmptyPatternsOnly() { DestinationPatternsMessageCondition c = condition(""); assertEquals("", c.getPatterns().iterator().next()); }
@Test public void prependSlash() { DestinationPatternsMessageCondition c = condition("foo"); assertEquals("/foo", c.getPatterns().iterator().next()); }
@Test public void prependSlashWithCustomPathSeparator() { DestinationPatternsMessageCondition c = new DestinationPatternsMessageCondition(new String[] {"foo"}, new AntPathMatcher(".")); assertEquals("Pre-pending should be disabled when not using '/' as path separator", "foo", c.getPatterns().iterator().next()); }
@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); } } return result; }
@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); } } try { SimpAttributesContextHolder.setAttributesFromMessage(message); super.handleMatch(mapping, handlerMethod, lookupDestination, message); } finally { SimpAttributesContextHolder.resetAttributes(); } }
@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); } } return result; }
@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); } } return result; }
@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); } } try { SimpAttributesContextHolder.setAttributesFromMessage(message); super.handleMatch(mapping, handlerMethod, lookupDestination, message); } finally { SimpAttributesContextHolder.resetAttributes(); } }
@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); } } try { SimpAttributesContextHolder.setAttributesFromMessage(message); super.handleMatch(mapping, handlerMethod, lookupDestination, message); } finally { SimpAttributesContextHolder.resetAttributes(); } }