Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dk131072
spring-framework
提交
ea0825c0
S
spring-framework
项目概览
dk131072
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ea0825c0
编写于
1月 14, 2014
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Trim tokenized strings in websocket namespace
Issue: SPR-11307
上级
2dfd69bb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
13 deletion
+22
-13
spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java
...ework/web/socket/config/HandlersBeanDefinitionParser.java
+6
-3
spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java
.../web/socket/config/MessageBrokerBeanDefinitionParser.java
+6
-6
spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java
.../web/socket/config/HandlersBeanDefinitionParserTests.java
+1
-1
spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java
...socket/config/MessageBrokerBeanDefinitionParserTests.java
+8
-2
spring-websocket/src/test/resources/org/springframework/web/socket/config/websocket-config-broker-simple.xml
...work/web/socket/config/websocket-config-broker-simple.xml
+1
-1
未找到文件。
spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java
浏览文件 @
ea0825c0
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
4
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
();
...
...
spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java
浏览文件 @
ea0825c0
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
4
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
app
licationDestination
Prefix
=
messageBrokerElement
.
getAttribute
(
"application-destination-prefix"
);
String
app
Dest
Prefix
=
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
=
...
...
spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java
浏览文件 @
ea0825c0
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
4
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.
...
...
spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java
浏览文件 @
ea0825c0
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
4
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.
...
...
@@ -83,10 +83,12 @@ public class MessageBrokerBeanDefinitionParserTests {
HttpRequestHandler
httpRequestHandler
=
(
HttpRequestHandler
)
suhm
.
getUrlMap
().
get
(
"/foo"
);
assertNotNull
(
httpRequestHandler
);
assertThat
(
httpRequestHandler
,
Matchers
.
instanceOf
(
WebSocketHttpRequestHandler
.
class
));
WebSocketHttpRequestHandler
wsHttpRequestHandler
=
(
WebSocketHttpRequestHandler
)
httpRequestHandler
;
WebSocketHandler
wsHandler
=
unwrapWebSocketHandler
(
wsHttpRequestHandler
.
getWebSocketHandler
());
assertNotNull
(
wsHandler
);
assertThat
(
wsHandler
,
Matchers
.
instanceOf
(
SubProtocolWebSocketHandler
.
class
));
SubProtocolWebSocketHandler
subProtocolWsHandler
=
(
SubProtocolWebSocketHandler
)
wsHandler
;
assertEquals
(
Arrays
.
asList
(
"v10.stomp"
,
"v11.stomp"
,
"v12.stomp"
),
subProtocolWsHandler
.
getSubProtocols
());
...
...
@@ -97,6 +99,7 @@ public class MessageBrokerBeanDefinitionParserTests {
httpRequestHandler
=
(
HttpRequestHandler
)
suhm
.
getUrlMap
().
get
(
"/test/**"
);
assertNotNull
(
httpRequestHandler
);
assertThat
(
httpRequestHandler
,
Matchers
.
instanceOf
(
SockJsHttpRequestHandler
.
class
));
SockJsHttpRequestHandler
sockJsHttpRequestHandler
=
(
SockJsHttpRequestHandler
)
httpRequestHandler
;
wsHandler
=
unwrapWebSocketHandler
(
sockJsHttpRequestHandler
.
getWebSocketHandler
());
assertNotNull
(
wsHandler
);
...
...
@@ -111,12 +114,15 @@ public class MessageBrokerBeanDefinitionParserTests {
assertThat
(
userDestResolver
,
Matchers
.
instanceOf
(
DefaultUserDestinationResolver
.
class
));
DefaultUserDestinationResolver
defaultUserDestResolver
=
(
DefaultUserDestinationResolver
)
userDestResolver
;
assertEquals
(
"/personal/"
,
defaultUserDestResolver
.
getDestinationPrefix
());
assertSame
(
stompHandler
.
getUserSessionRegistry
(),
defaultUserDestResolver
.
getUserSessionRegistry
());
UserDestinationMessageHandler
userDestHandler
=
this
.
appContext
.
getBean
(
UserDestinationMessageHandler
.
class
);
assertNotNull
(
userDestHandler
);
SimpleBrokerMessageHandler
brokerMessageHandler
=
this
.
appContext
.
getBean
(
SimpleBrokerMessageHandler
.
class
);
assertNotNull
(
brokerMessageHandler
);
assertEquals
(
Arrays
.
asList
(
"/topic"
,
"/queue"
),
brokerMessageHandler
.
getDestinationPrefixes
());
List
<
Class
<?
extends
MessageHandler
>>
subscriberTypes
=
Arrays
.<
Class
<?
extends
MessageHandler
>>
asList
(
SimpAnnotationMethodMessageHandler
.
class
,
UserDestinationMessageHandler
.
class
,
SimpleBrokerMessageHandler
.
class
);
...
...
spring-websocket/src/test/resources/org/springframework/web/socket/config/websocket-config-broker-simple.xml
浏览文件 @
ea0825c0
...
...
@@ -12,7 +12,7 @@
<websocket:handshake-handler
ref=
"myHandler"
/>
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:simple-broker
prefix=
"/topic"
/>
<websocket:simple-broker
prefix=
"/topic
, /queue
"
/>
</websocket:message-broker>
<bean
id=
"myHandler"
class=
"org.springframework.web.socket.config.TestHandshakeHandler"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录