Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
4ef428de
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 搜索 >>
提交
4ef428de
编写于
8月 30, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
03609c15
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
31 addition
and
20 deletion
+31
-20
spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java
...ork/context/event/AnnotationDrivenEventListenerTests.java
+8
-2
spring-context/src/test/java/org/springframework/context/event/test/EventCollector.java
...rg/springframework/context/event/test/EventCollector.java
+11
-3
spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java
...ava/org/springframework/core/env/AbstractEnvironment.java
+9
-10
spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointRegistration.java
...eb/socket/server/standard/ServerEndpointRegistration.java
+1
-2
spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java
.../socket/server/standard/TomcatRequestUpgradeStrategy.java
+2
-3
未找到文件。
spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java
浏览文件 @
4ef428de
...
...
@@ -77,7 +77,7 @@ public class AnnotationDrivenEventListenerTests {
private
EventCollector
eventCollector
;
private
CountDownLatch
countDownLatch
;
// 1 call by default
private
CountDownLatch
countDownLatch
;
// 1 call by default
@After
...
...
@@ -93,16 +93,23 @@ public class AnnotationDrivenEventListenerTests {
load
(
TestEventListener
.
class
);
TestEvent
event
=
new
TestEvent
(
this
,
"test"
);
TestEventListener
listener
=
this
.
context
.
getBean
(
TestEventListener
.
class
);
this
.
eventCollector
.
assertNoEventReceived
(
listener
);
this
.
context
.
publishEvent
(
event
);
this
.
eventCollector
.
assertEvent
(
listener
,
event
);
this
.
eventCollector
.
assertTotalEventsCount
(
1
);
this
.
eventCollector
.
clear
();
this
.
context
.
publishEvent
(
event
);
this
.
eventCollector
.
assertEvent
(
listener
,
event
);
this
.
eventCollector
.
assertTotalEventsCount
(
1
);
}
@Test
public
void
simpleEventXmlConfig
()
{
this
.
context
=
new
ClassPathXmlApplicationContext
(
"org/springframework/context/event/simple-event-configuration.xml"
);
TestEvent
event
=
new
TestEvent
(
this
,
"test"
);
TestEventListener
listener
=
this
.
context
.
getBean
(
TestEventListener
.
class
);
this
.
eventCollector
=
getEventCollector
(
this
.
context
);
...
...
@@ -116,7 +123,6 @@ public class AnnotationDrivenEventListenerTests {
@Test
public
void
metaAnnotationIsDiscovered
()
{
load
(
MetaAnnotationListenerTestBean
.
class
);
MetaAnnotationListenerTestBean
bean
=
this
.
context
.
getBean
(
MetaAnnotationListenerTestBean
.
class
);
this
.
eventCollector
.
assertNoEventReceived
(
bean
);
...
...
spring-context/src/test/java/org/springframework/context/event/test/EventCollector.java
浏览文件 @
4ef428de
...
...
@@ -30,6 +30,7 @@ import static org.junit.Assert.*;
* Test utility to collect and assert events.
*
* @author Stephane Nicoll
* @author Juergen Hoeller
*/
@Component
public
class
EventCollector
{
...
...
@@ -73,7 +74,7 @@ public class EventCollector {
*/
public
void
assertEvent
(
String
listenerId
,
Object
...
events
)
{
List
<
Object
>
actual
=
this
.
content
.
getOrDefault
(
listenerId
,
Collections
.
emptyList
());
assertEquals
(
"
w
rong number of events"
,
events
.
length
,
actual
.
size
());
assertEquals
(
"
W
rong number of events"
,
events
.
length
,
actual
.
size
());
for
(
int
i
=
0
;
i
<
events
.
length
;
i
++)
{
assertEquals
(
"Wrong event at index "
+
i
,
events
[
i
],
actual
.
get
(
i
));
}
...
...
@@ -97,8 +98,15 @@ public class EventCollector {
for
(
Map
.
Entry
<
String
,
List
<
Object
>>
entry
:
this
.
content
.
entrySet
())
{
actual
+=
entry
.
getValue
().
size
();
}
assertEquals
(
"Wrong number of total events ("
+
this
.
content
.
size
()
+
") "
+
"registered listener(s)"
,
number
,
actual
);
assertEquals
(
"Wrong number of total events ("
+
this
.
content
.
size
()
+
") registered listener(s)"
,
number
,
actual
);
}
/**
* Clear the collected events, allowing for reuse of the collector.
*/
public
void
clear
()
{
this
.
content
.
clear
();
}
}
spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java
浏览文件 @
4ef428de
...
...
@@ -31,9 +31,6 @@ import org.springframework.util.Assert;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
static
java
.
lang
.
String
.*;
import
static
org
.
springframework
.
util
.
StringUtils
.*;
/**
* Abstract base class for {@link Environment} implementations. Supports the notion of
* reserved default profile names and enables specifying active and default profiles
...
...
@@ -124,7 +121,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
public
AbstractEnvironment
()
{
customizePropertySources
(
this
.
propertySources
);
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
format
(
this
.
logger
.
debug
(
String
.
format
(
"Initialized %s with PropertySources %s"
,
getClass
().
getSimpleName
(),
this
.
propertySources
));
}
}
...
...
@@ -242,7 +239,8 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
if
(
this
.
activeProfiles
.
isEmpty
())
{
String
profiles
=
getProperty
(
ACTIVE_PROFILES_PROPERTY_NAME
);
if
(
StringUtils
.
hasText
(
profiles
))
{
setActiveProfiles
(
commaDelimitedListToStringArray
(
trimAllWhitespace
(
profiles
)));
setActiveProfiles
(
StringUtils
.
commaDelimitedListToStringArray
(
StringUtils
.
trimAllWhitespace
(
profiles
)));
}
}
return
this
.
activeProfiles
;
...
...
@@ -264,7 +262,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
@Override
public
void
addActiveProfile
(
String
profile
)
{
if
(
this
.
logger
.
isDebugEnabled
())
{
this
.
logger
.
debug
(
format
(
"Activating profile '%s'"
,
profile
));
this
.
logger
.
debug
(
String
.
format
(
"Activating profile '%s'"
,
profile
));
}
validateProfile
(
profile
);
doGetActiveProfiles
();
...
...
@@ -296,7 +294,8 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
if
(
this
.
defaultProfiles
.
equals
(
getReservedDefaultProfiles
()))
{
String
profiles
=
getProperty
(
DEFAULT_PROFILES_PROPERTY_NAME
);
if
(
StringUtils
.
hasText
(
profiles
))
{
setDefaultProfiles
(
commaDelimitedListToStringArray
(
trimAllWhitespace
(
profiles
)));
setDefaultProfiles
(
StringUtils
.
commaDelimitedListToStringArray
(
StringUtils
.
trimAllWhitespace
(
profiles
)));
}
}
return
this
.
defaultProfiles
;
...
...
@@ -393,7 +392,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
}
catch
(
AccessControlException
ex
)
{
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
format
(
"Caught AccessControlException when accessing system "
+
logger
.
info
(
String
.
format
(
"Caught AccessControlException when accessing system "
+
"environment variable [%s]; its value will be returned [null]. Reason: %s"
,
attributeName
,
ex
.
getMessage
()));
}
...
...
@@ -434,7 +433,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
}
catch
(
AccessControlException
ex
)
{
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
format
(
"Caught AccessControlException when accessing system "
+
logger
.
info
(
String
.
format
(
"Caught AccessControlException when accessing system "
+
"property [%s]; its value will be returned [null]. Reason: %s"
,
attributeName
,
ex
.
getMessage
()));
}
...
...
@@ -569,7 +568,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
@Override
public
String
toString
()
{
return
format
(
"%s {activeProfiles=%s, defaultProfiles=%s, propertySources=%s}"
,
return
String
.
format
(
"%s {activeProfiles=%s, defaultProfiles=%s, propertySources=%s}"
,
getClass
().
getSimpleName
(),
this
.
activeProfiles
,
this
.
defaultProfiles
,
this
.
propertySources
);
}
...
...
spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointRegistration.java
浏览文件 @
4ef428de
...
...
@@ -107,8 +107,7 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato
@Override
public
Class
<?
extends
Endpoint
>
getEndpointClass
()
{
return
(
this
.
endpoint
!=
null
)
?
this
.
endpoint
.
getClass
()
:
((
Class
<?
extends
Endpoint
>)
this
.
endpointProvider
.
getHandlerType
());
return
(
this
.
endpoint
!=
null
?
this
.
endpoint
.
getClass
()
:
this
.
endpointProvider
.
getHandlerType
());
}
public
Endpoint
getEndpoint
()
{
...
...
spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java
浏览文件 @
4ef428de
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -17,7 +17,6 @@
package
org.springframework.web.socket.server.standard
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -65,7 +64,7 @@ public class TomcatRequestUpgradeStrategy extends AbstractStandardUpgradeStrateg
Map
<
String
,
String
>
pathParams
=
Collections
.<
String
,
String
>
emptyMap
();
ServerEndpointRegistration
endpointConfig
=
new
ServerEndpointRegistration
(
path
,
endpoint
);
endpointConfig
.
setSubprotocols
(
Arrays
.
as
List
(
selectedProtocol
));
endpointConfig
.
setSubprotocols
(
Collections
.
singleton
List
(
selectedProtocol
));
endpointConfig
.
setExtensions
(
selectedExtensions
);
try
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录