Trim tokenized strings in websocket namespace

Issue: SPR-11307
This commit is contained in:
Rossen Stoyanchev
2014-01-14 12:44:46 -05:00
parent 2dfd69bbb3
commit ea0825c0a6
5 changed files with 22 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ package org.springframework.web.socket.config;
import java.util.Arrays;
import java.util.List;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -131,7 +132,8 @@ class HandlersBeanDefinitionParser implements BeanDefinitionParser {
ManagedMap<String, Object> urlMap = new ManagedMap<String, Object>();
Object source = parserContext.extractSource(mappingElement);
List<String> mappings = Arrays.asList(mappingElement.getAttribute("path").split(","));
String path = mappingElement.getAttribute("path");
List<String> mappings = Arrays.asList(StringUtils.tokenizeToStringArray(path, ","));
RuntimeBeanReference webSocketHandlerReference = new RuntimeBeanReference(mappingElement.getAttribute("handler"));
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
@@ -168,7 +170,8 @@ class HandlersBeanDefinitionParser implements BeanDefinitionParser {
ManagedMap<String, Object> urlMap = new ManagedMap<String, Object>();
Object source = parserContext.extractSource(mappingElement);
List<String> mappings = Arrays.asList(mappingElement.getAttribute("path").split(","));
String pathValue = mappingElement.getAttribute("path");
List<String> mappings = Arrays.asList(StringUtils.tokenizeToStringArray(pathValue, ","));
RuntimeBeanReference webSocketHandlerReference = new RuntimeBeanReference(mappingElement.getAttribute("handler"));
ConstructorArgumentValues cavs = new ConstructorArgumentValues();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -135,7 +135,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
String pathAttribute = stompEndpointElem.getAttribute("path");
Assert.state(StringUtils.hasText(pathAttribute), "Invalid <stomp-endpoint> (no path mapping)");
List<String> paths = Arrays.asList(pathAttribute.split(","));
List<String> paths = Arrays.asList(StringUtils.tokenizeToStringArray(pathAttribute, ","));
for(String path : paths) {
path = path.trim();
Assert.state(StringUtils.hasText(path), "Invalid <stomp-endpoint> path attribute: " + pathAttribute);
@@ -286,14 +286,14 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
if (simpleBrokerElem != null) {
String prefix = simpleBrokerElem.getAttribute("prefix");
cavs.addIndexedArgumentValue(3, Arrays.asList(prefix.split(",")));
cavs.addIndexedArgumentValue(3, Arrays.asList(StringUtils.tokenizeToStringArray(prefix, ",")));
RootBeanDefinition brokerDef = new RootBeanDefinition(SimpleBrokerMessageHandler.class, cavs, null);
registerBeanDef(brokerDef, parserCxt, source);
}
else if (brokerRelayElem != null) {
String prefix = brokerRelayElem.getAttribute("prefix");
cavs.addIndexedArgumentValue(3, Arrays.asList(prefix.split(",")));
cavs.addIndexedArgumentValue(3, Arrays.asList(StringUtils.tokenizeToStringArray(prefix, ",")));
MutablePropertyValues mpvs = new MutablePropertyValues();
String relayHost = brokerRelayElem.getAttribute("relay-host");
@@ -397,7 +397,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
RuntimeBeanReference brokerMessageConverterRef, RuntimeBeanReference brokerMessagingTemplateRef,
ParserContext parserCxt, Object source) {
String applicationDestinationPrefix = messageBrokerElement.getAttribute("application-destination-prefix");
String appDestPrefix = messageBrokerElement.getAttribute("application-destination-prefix");
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
cavs.addIndexedArgumentValue(0, clientInChannelDef);
@@ -405,7 +405,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
cavs.addIndexedArgumentValue(2, brokerMessagingTemplateRef);
MutablePropertyValues mpvs = new MutablePropertyValues();
mpvs.add("destinationPrefixes",Arrays.asList(applicationDestinationPrefix.split(",")));
mpvs.add("destinationPrefixes",Arrays.asList(StringUtils.tokenizeToStringArray(appDestPrefix, ",")));
mpvs.add("messageConverter", brokerMessageConverterRef);
RootBeanDefinition annotationMethodMessageHandlerDef =