From 100d75da26355aec8a76c3652527efb09ff41385 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 1 Apr 2015 14:44:12 +0200 Subject: [PATCH] Fix client-library-url ignored in MVC namespace Prior to this commit, the `client-library-url` XML attribute was not effective in the MVC namespace, leaving the default value configured: ```xml ``` This commit fixes the sockjs namespace handler and makes sure that this attribute is configured on the `SockJsService` Bean to be created. Issue: SPR-12874 --- .../web/socket/config/WebSocketNamespaceUtils.java | 4 ++++ .../web/socket/config/HandlersBeanDefinitionParserTests.java | 1 + .../config/websocket-config-handlers-sockjs-attributes.xml | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java index d8867b07d1..ed93ccaa2a 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java @@ -137,6 +137,10 @@ class WebSocketNamespaceUtils { if (!attrValue.isEmpty()) { sockJsServiceDef.getPropertyValues().add("heartbeatTime", Long.valueOf(attrValue)); } + attrValue = sockJsElement.getAttribute("client-library-url"); + if (!attrValue.isEmpty()) { + sockJsServiceDef.getPropertyValues().add("sockJsClientLibraryUrl", attrValue); + } attrValue = sockJsElement.getAttribute("message-codec"); if (!attrValue.isEmpty()) { sockJsServiceDef.getPropertyValues().add("messageCodec", new RuntimeBeanReference(attrValue)); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java index 811cb21a93..32fa2f9ff0 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java @@ -230,6 +230,7 @@ public class HandlersBeanDefinitionParserTests { assertEquals(256, transportService.getDisconnectDelay()); assertEquals(1024, transportService.getHttpMessageCacheSize()); assertEquals(20, transportService.getHeartbeatTime()); + assertEquals("/js/sockjs.min.js", transportService.getSockJsClientLibraryUrl()); assertEquals(TestMessageCodec.class, transportService.getMessageCodec().getClass()); List interceptors = transportService.getHandshakeInterceptors(); diff --git a/spring-websocket/src/test/resources/org/springframework/web/socket/config/websocket-config-handlers-sockjs-attributes.xml b/spring-websocket/src/test/resources/org/springframework/web/socket/config/websocket-config-handlers-sockjs-attributes.xml index f319e7be0d..0e592760bf 100644 --- a/spring-websocket/src/test/resources/org/springframework/web/socket/config/websocket-config-handlers-sockjs-attributes.xml +++ b/spring-websocket/src/test/resources/org/springframework/web/socket/config/websocket-config-handlers-sockjs-attributes.xml @@ -9,7 +9,8 @@ + message-cache-size="1024" heartbeat-time="20" message-codec="messageCodec" + client-library-url="/js/sockjs.min.js" suppress-cors="true">