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 <websocket:sockjs client-library-url="/js/sockjs.js" /> ``` 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
This commit is contained in:
@@ -137,6 +137,10 @@ class WebSocketNamespaceUtils {
|
|||||||
if (!attrValue.isEmpty()) {
|
if (!attrValue.isEmpty()) {
|
||||||
sockJsServiceDef.getPropertyValues().add("heartbeatTime", Long.valueOf(attrValue));
|
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");
|
attrValue = sockJsElement.getAttribute("message-codec");
|
||||||
if (!attrValue.isEmpty()) {
|
if (!attrValue.isEmpty()) {
|
||||||
sockJsServiceDef.getPropertyValues().add("messageCodec", new RuntimeBeanReference(attrValue));
|
sockJsServiceDef.getPropertyValues().add("messageCodec", new RuntimeBeanReference(attrValue));
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ public class HandlersBeanDefinitionParserTests {
|
|||||||
assertEquals(256, transportService.getDisconnectDelay());
|
assertEquals(256, transportService.getDisconnectDelay());
|
||||||
assertEquals(1024, transportService.getHttpMessageCacheSize());
|
assertEquals(1024, transportService.getHttpMessageCacheSize());
|
||||||
assertEquals(20, transportService.getHeartbeatTime());
|
assertEquals(20, transportService.getHeartbeatTime());
|
||||||
|
assertEquals("/js/sockjs.min.js", transportService.getSockJsClientLibraryUrl());
|
||||||
assertEquals(TestMessageCodec.class, transportService.getMessageCodec().getClass());
|
assertEquals(TestMessageCodec.class, transportService.getMessageCodec().getClass());
|
||||||
|
|
||||||
List<HandshakeInterceptor> interceptors = transportService.getHandshakeInterceptors();
|
List<HandshakeInterceptor> interceptors = transportService.getHandshakeInterceptors();
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
<websocket:mapping path="/test" handler="testHandler"/>
|
<websocket:mapping path="/test" handler="testHandler"/>
|
||||||
<websocket:sockjs name="testSockJsService" scheduler="testTaskScheduler" websocket-enabled="false"
|
<websocket:sockjs name="testSockJsService" scheduler="testTaskScheduler" websocket-enabled="false"
|
||||||
session-cookie-needed="false" stream-bytes-limit="2048" disconnect-delay="256"
|
session-cookie-needed="false" stream-bytes-limit="2048" disconnect-delay="256"
|
||||||
message-cache-size="1024" heartbeat-time="20" message-codec="messageCodec" suppress-cors="true">
|
message-cache-size="1024" heartbeat-time="20" message-codec="messageCodec"
|
||||||
|
client-library-url="/js/sockjs.min.js" suppress-cors="true">
|
||||||
<websocket:transport-handlers register-defaults="false">
|
<websocket:transport-handlers register-defaults="false">
|
||||||
<bean class="org.springframework.web.socket.sockjs.transport.handler.XhrPollingTransportHandler"/>
|
<bean class="org.springframework.web.socket.sockjs.transport.handler.XhrPollingTransportHandler"/>
|
||||||
<ref bean="xhrStreamingTransportHandler"/>
|
<ref bean="xhrStreamingTransportHandler"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user