Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
e188b442
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
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,体验更适合开发者的 AI 搜索 >>
提交
e188b442
编写于
9月 25, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
94753b5e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
23 deletion
+23
-23
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompClientSupport.java
...ingframework/messaging/simp/stomp/StompClientSupport.java
+17
-17
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java
...rg/springframework/messaging/simp/stomp/StompDecoder.java
+0
-1
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompEncoder.java
...rg/springframework/messaging/simp/stomp/StompEncoder.java
+6
-5
未找到文件。
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompClientSupport.java
浏览文件 @
e188b442
/*
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -26,15 +26,14 @@ import org.springframework.util.Assert;
...
@@ -26,15 +26,14 @@ import org.springframework.util.Assert;
/**
/**
* Base class for STOMP client implementations.
* Base class for STOMP client implementations.
*
*
* <p>Subclasses can connect over WebSocket or TCP using any library.
* <p>Subclasses can connect over WebSocket or TCP using any library. When creating
* When creating a new connection a sub-class can create an instance of
* a new connection, a subclass can create an instance of @link DefaultStompSession}
* {@link DefaultStompSession} which extends
* which extends {@link org.springframework.messaging.tcp.TcpConnectionHandler}
* {@link org.springframework.messaging.tcp.TcpConnectionHandler
* whose lifecycle methods the subclass must then invoke.
* TcpConnectionHandler} whose lifecycle methods the sub-class must then invoke.
*
*
* <p>In effect {@code TcpConnectionHandler} and {@code TcpConnection} are the
* <p>In effect
,
{@code TcpConnectionHandler} and {@code TcpConnection} are the
* contracts
any sub-class must adapt to while using {@link StompEncoder} and
* contracts
that any subclass must adapt to while using {@link StompEncoder}
* {@link StompDecoder} to encode and decode STOMP messages.
*
and
{@link StompDecoder} to encode and decode STOMP messages.
*
*
* @author Rossen Stoyanchev
* @author Rossen Stoyanchev
* @since 4.2
* @since 4.2
...
@@ -58,7 +57,7 @@ public abstract class StompClientSupport {
...
@@ -58,7 +57,7 @@ public abstract class StompClientSupport {
* @param messageConverter the message converter to use
* @param messageConverter the message converter to use
*/
*/
public
void
setMessageConverter
(
MessageConverter
messageConverter
)
{
public
void
setMessageConverter
(
MessageConverter
messageConverter
)
{
Assert
.
notNull
(
messageConverter
,
"
'messageConverter'
must not be null"
);
Assert
.
notNull
(
messageConverter
,
"
MessageConverter
must not be null"
);
this
.
messageConverter
=
messageConverter
;
this
.
messageConverter
=
messageConverter
;
}
}
...
@@ -92,7 +91,7 @@ public abstract class StompClientSupport {
...
@@ -92,7 +91,7 @@ public abstract class StompClientSupport {
* CONNECT frame. The first number represents how often the client will write
* CONNECT frame. The first number represents how often the client will write
* or send a heart-beat. The second is how often the server should write.
* or send a heart-beat. The second is how often the server should write.
* A value of 0 means no heart-beats.
* A value of 0 means no heart-beats.
* <p>By default this is set to "10000,10000" but sub
-
classes may override
* <p>By default this is set to "10000,10000" but subclasses may override
* that default and for example set it to "0,0" if they require a
* that default and for example set it to "0,0" if they require a
* TaskScheduler to be configured first.
* TaskScheduler to be configured first.
* @param heartbeat the value for the CONNECT "heart-beat" header
* @param heartbeat the value for the CONNECT "heart-beat" header
...
@@ -100,22 +99,23 @@ public abstract class StompClientSupport {
...
@@ -100,22 +99,23 @@ public abstract class StompClientSupport {
* http://stomp.github.io/stomp-specification-1.2.html#Heart-beating</a>
* http://stomp.github.io/stomp-specification-1.2.html#Heart-beating</a>
*/
*/
public
void
setDefaultHeartbeat
(
long
[]
heartbeat
)
{
public
void
setDefaultHeartbeat
(
long
[]
heartbeat
)
{
Assert
.
notNull
(
heartbeat
);
if
(
heartbeat
==
null
||
heartbeat
.
length
!=
2
||
heartbeat
[
0
]
<
0
||
heartbeat
[
1
]
<
0
)
{
Assert
.
isTrue
(
heartbeat
[
0
]
>=
0
&&
heartbeat
[
1
]
>=
0
,
"Invalid heart-beat: "
+
Arrays
.
toString
(
heartbeat
));
throw
new
IllegalArgumentException
(
"Invalid heart-beat: "
+
Arrays
.
toString
(
heartbeat
));
}
this
.
defaultHeartbeat
=
heartbeat
;
this
.
defaultHeartbeat
=
heartbeat
;
}
}
/**
/**
* Return the configured default heart-beat value
, never {@code null}
.
* Return the configured default heart-beat value
(never {@code null})
.
*/
*/
public
long
[]
getDefaultHeartbeat
()
{
public
long
[]
getDefaultHeartbeat
()
{
return
this
.
defaultHeartbeat
;
return
this
.
defaultHeartbeat
;
}
}
/**
/**
*
Whether heartbeats are enabled. Returns {@code false} if
*
Determine whether heartbeats are enabled.
*
{@link #setDefaultHeartbeat defaultHeartbeat} is set to "0,0", and
*
<p>Returns {@code false} if {@link #setDefaultHeartbeat defaultHeartbeat}
* {@code true} otherwise.
*
is set to "0,0", and
{@code true} otherwise.
*/
*/
public
boolean
isDefaultHeartbeatEnabled
()
{
public
boolean
isDefaultHeartbeatEnabled
()
{
return
(
getDefaultHeartbeat
()
!=
null
&&
getDefaultHeartbeat
()[
0
]
!=
0
&&
getDefaultHeartbeat
()[
1
]
!=
0
);
return
(
getDefaultHeartbeat
()
!=
null
&&
getDefaultHeartbeat
()[
0
]
!=
0
&&
getDefaultHeartbeat
()[
1
]
!=
0
);
...
...
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java
浏览文件 @
e188b442
...
@@ -18,7 +18,6 @@ package org.springframework.messaging.simp.stomp;
...
@@ -18,7 +18,6 @@ package org.springframework.messaging.simp.stomp;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
...
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompEncoder.java
浏览文件 @
e188b442
...
@@ -20,7 +20,7 @@ import java.io.ByteArrayOutputStream;
...
@@ -20,7 +20,7 @@ import java.io.ByteArrayOutputStream;
import
java.io.DataOutputStream
;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.
Array
s
;
import
java.util.
Collection
s
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
...
@@ -47,7 +47,7 @@ public final class StompEncoder {
...
@@ -47,7 +47,7 @@ public final class StompEncoder {
private
static
final
byte
COLON
=
':'
;
private
static
final
byte
COLON
=
':'
;
private
final
Log
logger
=
LogFactory
.
getLog
(
StompEncoder
.
class
);
private
static
final
Log
logger
=
LogFactory
.
getLog
(
StompEncoder
.
class
);
/**
/**
...
@@ -79,6 +79,7 @@ public final class StompEncoder {
...
@@ -79,6 +79,7 @@ public final class StompEncoder {
}
}
output
.
write
(
StompDecoder
.
HEARTBEAT_PAYLOAD
);
output
.
write
(
StompDecoder
.
HEARTBEAT_PAYLOAD
);
}
}
else
{
else
{
StompCommand
command
=
StompHeaderAccessor
.
getCommand
(
headers
);
StompCommand
command
=
StompHeaderAccessor
.
getCommand
(
headers
);
if
(
command
==
null
)
{
if
(
command
==
null
)
{
...
@@ -100,8 +101,8 @@ public final class StompEncoder {
...
@@ -100,8 +101,8 @@ public final class StompEncoder {
}
}
}
}
private
void
writeHeaders
(
StompCommand
command
,
Map
<
String
,
Object
>
headers
,
byte
[]
payload
,
DataOutputStream
output
)
private
void
writeHeaders
(
StompCommand
command
,
Map
<
String
,
Object
>
headers
,
byte
[]
payload
,
throws
IOException
{
DataOutputStream
output
)
throws
IOException
{
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
List
<
String
>>
nativeHeaders
=
Map
<
String
,
List
<
String
>>
nativeHeaders
=
...
@@ -125,7 +126,7 @@ public final class StompEncoder {
...
@@ -125,7 +126,7 @@ public final class StompEncoder {
List
<
String
>
values
=
entry
.
getValue
();
List
<
String
>
values
=
entry
.
getValue
();
if
(
StompCommand
.
CONNECT
.
equals
(
command
)
&&
if
(
StompCommand
.
CONNECT
.
equals
(
command
)
&&
StompHeaderAccessor
.
STOMP_PASSCODE_HEADER
.
equals
(
entry
.
getKey
()))
{
StompHeaderAccessor
.
STOMP_PASSCODE_HEADER
.
equals
(
entry
.
getKey
()))
{
values
=
Arrays
.
as
List
(
StompHeaderAccessor
.
getPasscode
(
headers
));
values
=
Collections
.
singleton
List
(
StompHeaderAccessor
.
getPasscode
(
headers
));
}
}
byte
[]
encodedKey
=
encodeHeaderString
(
entry
.
getKey
(),
shouldEscape
);
byte
[]
encodedKey
=
encodeHeaderString
(
entry
.
getKey
(),
shouldEscape
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录