Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
de1139e6
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 搜索 >>
提交
de1139e6
编写于
9月 29, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
e978f90a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
34 deletion
+34
-34
spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
...rk/context/event/AbstractApplicationEventMulticaster.java
+9
-11
spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java
...rg/springframework/core/env/StandardEnvironmentTests.java
+25
-23
未找到文件。
spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
浏览文件 @
de1139e6
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -16,9 +16,10 @@
package
org.springframework.context.event
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.LinkedHashSet
;
import
java.util.Li
nkedLi
st
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -210,7 +211,7 @@ public abstract class AbstractApplicationEventMulticaster
private
Collection
<
ApplicationListener
<?>>
retrieveApplicationListeners
(
ResolvableType
eventType
,
Class
<?>
sourceType
,
ListenerRetriever
retriever
)
{
Li
nkedList
<
ApplicationListener
<?>>
allListeners
=
new
Linked
List
<
ApplicationListener
<?>>();
Li
st
<
ApplicationListener
<?>>
allListeners
=
new
Array
List
<
ApplicationListener
<?>>();
Set
<
ApplicationListener
<?>>
listeners
;
Set
<
String
>
listenerBeans
;
synchronized
(
this
.
retrievalMutex
)
{
...
...
@@ -345,23 +346,20 @@ public abstract class AbstractApplicationEventMulticaster
*/
private
class
ListenerRetriever
{
public
final
Set
<
ApplicationListener
<?>>
applicationListeners
;
public
final
Set
<
ApplicationListener
<?>>
applicationListeners
=
new
LinkedHashSet
<
ApplicationListener
<?>>()
;
public
final
Set
<
String
>
applicationListenerBeans
;
public
final
Set
<
String
>
applicationListenerBeans
=
new
LinkedHashSet
<
String
>()
;
private
final
boolean
preFiltered
;
public
ListenerRetriever
(
boolean
preFiltered
)
{
this
.
applicationListeners
=
new
LinkedHashSet
<
ApplicationListener
<?>>();
this
.
applicationListenerBeans
=
new
LinkedHashSet
<
String
>();
this
.
preFiltered
=
preFiltered
;
}
public
Collection
<
ApplicationListener
<?>>
getApplicationListeners
()
{
LinkedList
<
ApplicationListener
<?>>
allListeners
=
new
LinkedList
<
ApplicationListener
<?>>();
for
(
ApplicationListener
<?>
listener
:
this
.
applicationListeners
)
{
allListeners
.
add
(
listener
);
}
List
<
ApplicationListener
<?>>
allListeners
=
new
ArrayList
<
ApplicationListener
<?>>(
this
.
applicationListeners
.
size
()
+
this
.
applicationListenerBeans
.
size
());
allListeners
.
addAll
(
this
.
applicationListeners
);
if
(!
this
.
applicationListenerBeans
.
isEmpty
())
{
BeanFactory
beanFactory
=
getBeanFactory
();
for
(
String
listenerBeanName
:
this
.
applicationListenerBeans
)
{
...
...
spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java
浏览文件 @
de1139e6
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
8
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.
...
...
@@ -38,6 +38,7 @@ import static org.springframework.core.env.AbstractEnvironment.*;
* @author Chris Beams
* @author Juergen Hoeller
*/
@SuppressWarnings
(
"deprecation"
)
public
class
StandardEnvironmentTests
{
private
static
final
String
ALLOWED_PROPERTY_NAME
=
"theanswer"
;
...
...
@@ -51,7 +52,8 @@ public class StandardEnvironmentTests {
private
static
final
Object
NON_STRING_PROPERTY_NAME
=
new
Object
();
private
static
final
Object
NON_STRING_PROPERTY_VALUE
=
new
Object
();
private
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
private
final
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
@Test
public
void
merge
()
{
...
...
@@ -129,42 +131,42 @@ public class StandardEnvironmentTests {
assertThat
(
activeProfiles
.
length
,
is
(
2
));
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
setActiveProfiles_withNullProfileArray
()
{
environment
.
setActiveProfiles
((
String
[])
null
);
environment
.
setActiveProfiles
((
String
[])
null
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
setActiveProfiles_withNullProfile
()
{
environment
.
setActiveProfiles
((
String
)
null
);
environment
.
setActiveProfiles
((
String
)
null
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
setActiveProfiles_withEmptyProfile
()
{
environment
.
setActiveProfiles
(
""
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
setActiveProfiles_withNotOperator
()
{
environment
.
setActiveProfiles
(
"p1"
,
"!p2"
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
setDefaultProfiles_withNullProfileArray
()
{
environment
.
setDefaultProfiles
((
String
[])
null
);
environment
.
setDefaultProfiles
((
String
[])
null
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
setDefaultProfiles_withNullProfile
()
{
environment
.
setDefaultProfiles
((
String
)
null
);
environment
.
setDefaultProfiles
((
String
)
null
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
setDefaultProfiles_withEmptyProfile
()
{
environment
.
setDefaultProfiles
(
""
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
setDefaultProfiles_withNotOperator
()
{
environment
.
setDefaultProfiles
(
"d1"
,
"!d2"
);
}
...
...
@@ -204,7 +206,7 @@ public class StandardEnvironmentTests {
System
.
getProperties
().
remove
(
DEFAULT_PROFILES_PROPERTY_NAME
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
defaultProfileWithCircularPlaceholder
()
{
System
.
setProperty
(
DEFAULT_PROFILES_PROPERTY_NAME
,
"${spring.profiles.default}"
);
try
{
...
...
@@ -263,27 +265,26 @@ public class StandardEnvironmentTests {
assertThat
(
Arrays
.
asList
(
environment
.
getDefaultProfiles
()),
hasItems
(
"pd2"
,
"pd3"
));
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
acceptsProfiles_withEmptyArgumentList
()
{
environment
.
acceptsProfiles
();
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
acceptsProfiles_withNullArgumentList
()
{
environment
.
acceptsProfiles
((
String
[])
null
);
environment
.
acceptsProfiles
((
String
[])
null
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
acceptsProfiles_withNullArgument
()
{
environment
.
acceptsProfiles
((
String
)
null
);
environment
.
acceptsProfiles
((
String
)
null
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
acceptsProfiles_withEmptyArgument
()
{
environment
.
acceptsProfiles
(
""
);
}
@Test
public
void
acceptsProfiles_activeProfileSetProgrammatically
()
{
assertThat
(
environment
.
acceptsProfiles
(
"p1"
,
"p2"
),
is
(
false
));
...
...
@@ -321,7 +322,7 @@ public class StandardEnvironmentTests {
assertThat
(
environment
.
acceptsProfiles
(
"!p1"
),
is
(
false
));
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
acceptsProfiles_withInvalidNotOperator
()
{
environment
.
acceptsProfiles
(
"p1"
,
"!"
);
}
...
...
@@ -488,6 +489,7 @@ public class StandardEnvironmentTests {
getModifiableSystemEnvironment
().
remove
(
DISALLOWED_PROPERTY_NAME
);
}
@SuppressWarnings
(
"unchecked"
)
public
static
Map
<
String
,
String
>
getModifiableSystemEnvironment
()
{
// for os x / linux
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录