Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sesemomo
spring-framework
提交
2f9ed591
S
spring-framework
项目概览
sesemomo
/
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,发现更多精彩内容 >>
提交
2f9ed591
编写于
10月 28, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
dc080cb1
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
47 addition
and
70 deletion
+47
-70
spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java
...va/org/springframework/context/support/LiveBeansView.java
+2
-2
spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java
...eans/factory/xml/support/CustomNamespaceHandlerTests.java
+11
-13
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
.../org/springframework/core/annotation/AnnotationUtils.java
+2
-1
spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java
.../org/springframework/core/io/support/EncodedResource.java
+3
-2
spring-core/src/test/java/org/springframework/tests/TestResourceUtils.java
...est/java/org/springframework/tests/TestResourceUtils.java
+4
-11
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java
...ramework/jdbc/datasource/init/DatabasePopulatorUtils.java
+4
-5
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java
...ework/jdbc/datasource/init/ResourceDatabasePopulator.java
+13
-28
spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulatorTests.java
.../jdbc/datasource/init/ResourceDatabasePopulatorTests.java
+8
-8
未找到文件。
spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java
浏览文件 @
2f9ed591
...
...
@@ -71,7 +71,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
server
.
registerMBean
(
new
LiveBeansView
(),
new
ObjectName
(
mbeanDomain
,
MBEAN_APPLICATION_KEY
,
applicationName
));
}
catch
(
Exception
ex
)
{
catch
(
Throwable
ex
)
{
throw
new
ApplicationContextException
(
"Failed to register LiveBeansView MBean"
,
ex
);
}
}
...
...
@@ -88,7 +88,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
String
mbeanDomain
=
applicationContext
.
getEnvironment
().
getProperty
(
MBEAN_DOMAIN_PROPERTY_NAME
);
server
.
unregisterMBean
(
new
ObjectName
(
mbeanDomain
,
MBEAN_APPLICATION_KEY
,
applicationName
));
}
catch
(
Exception
ex
)
{
catch
(
Throwable
ex
)
{
throw
new
ApplicationContextException
(
"Failed to unregister LiveBeansView MBean"
,
ex
);
}
finally
{
applicationName
=
null
;
...
...
spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java
浏览文件 @
2f9ed591
...
...
@@ -82,6 +82,7 @@ public class CustomNamespaceHandlerTests {
private
GenericApplicationContext
beanFactory
;
@Before
public
void
setUp
()
throws
Exception
{
NamespaceHandlerResolver
resolver
=
new
DefaultNamespaceHandlerResolver
(
CLASS
.
getClassLoader
(),
NS_PROPS
);
...
...
@@ -148,30 +149,21 @@ public class CustomNamespaceHandlerTests {
assertEquals
(
"foo"
,
beanDefinition
.
getAttribute
(
"objectName"
));
}
/**
* http://opensource.atlassian.com/projects/spring/browse/SPR-2728
*/
@Test
@Test
// SPR-2728
public
void
testCustomElementNestedWithinUtilList
()
throws
Exception
{
List
<?>
things
=
(
List
<?>)
this
.
beanFactory
.
getBean
(
"list.of.things"
);
assertNotNull
(
things
);
assertEquals
(
2
,
things
.
size
());
}
/**
* http://opensource.atlassian.com/projects/spring/browse/SPR-2728
*/
@Test
@Test
// SPR-2728
public
void
testCustomElementNestedWithinUtilSet
()
throws
Exception
{
Set
<?>
things
=
(
Set
<?>)
this
.
beanFactory
.
getBean
(
"set.of.things"
);
assertNotNull
(
things
);
assertEquals
(
2
,
things
.
size
());
}
/**
* http://opensource.atlassian.com/projects/spring/browse/SPR-2728
*/
@Test
@Test
// SPR-2728
public
void
testCustomElementNestedWithinUtilMap
()
throws
Exception
{
Map
<?,
?>
things
=
(
Map
<?,
?>)
this
.
beanFactory
.
getBean
(
"map.of.things"
);
assertNotNull
(
things
);
...
...
@@ -229,6 +221,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
registerBeanDefinitionDecoratorForAttribute
(
"object-name"
,
new
ObjectNameBeanDefinitionDecorator
());
}
private
static
class
TestBeanDefinitionParser
implements
BeanDefinitionParser
{
@Override
...
...
@@ -247,6 +240,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
}
}
private
static
final
class
PersonDefinitionParser
extends
AbstractSingleBeanDefinitionParser
{
@Override
...
...
@@ -261,6 +255,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
}
}
private
static
class
PropertyModifyingBeanDefinitionDecorator
implements
BeanDefinitionDecorator
{
@Override
...
...
@@ -277,6 +272,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
}
}
private
static
class
DebugBeanDefinitionDecorator
extends
AbstractInterceptorDrivenBeanDefinitionDecorator
{
@Override
...
...
@@ -285,6 +281,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
}
}
private
static
class
NopInterceptorBeanDefinitionDecorator
extends
AbstractInterceptorDrivenBeanDefinitionDecorator
{
@Override
...
...
@@ -293,6 +290,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
}
}
private
static
class
ObjectNameBeanDefinitionDecorator
implements
BeanDefinitionDecorator
{
@Override
...
...
@@ -302,5 +300,5 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
return
definition
;
}
}
}
}
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
浏览文件 @
2f9ed591
...
...
@@ -485,7 +485,8 @@ public abstract class AnnotationUtils {
* @since 4.2
*/
@SuppressWarnings
(
"unchecked"
)
private
static
<
A
extends
Annotation
>
A
findAnnotation
(
AnnotatedElement
annotatedElement
,
Class
<
A
>
annotationType
,
Set
<
Annotation
>
visited
)
{
private
static
<
A
extends
Annotation
>
A
findAnnotation
(
AnnotatedElement
annotatedElement
,
Class
<
A
>
annotationType
,
Set
<
Annotation
>
visited
)
{
try
{
Annotation
[]
anns
=
annotatedElement
.
getDeclaredAnnotations
();
for
(
Annotation
ann
:
anns
)
{
...
...
spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java
浏览文件 @
2f9ed591
...
...
@@ -37,6 +37,7 @@ import org.springframework.util.ObjectUtils;
* @author Juergen Hoeller
* @author Sam Brannen
* @since 1.2.6
* @see Resource#getInputStream()
* @see java.io.Reader
* @see java.nio.charset.Charset
*/
...
...
@@ -142,8 +143,8 @@ public class EncodedResource implements InputStreamSource {
}
/**
* Open a
{@code java.io.InputStream} for the specified resource, ignoring any
*
specified
{@link #getCharset() Charset} or {@linkplain #getEncoding() encoding}.
* Open a
n {@code InputStream} for the specified resource, ignoring any specified
* {@link #getCharset() Charset} or {@linkplain #getEncoding() encoding}.
* @throws IOException if opening the InputStream failed
* @see #requiresReader()
* @see #getReader()
...
...
spring-core/src/test/java/org/springframework/tests/TestResourceUtils.java
浏览文件 @
2f9ed591
/*
* Copyright 2002-201
3
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.
...
...
@@ -18,29 +18,22 @@ package org.springframework.tests;
import
org.springframework.core.io.ClassPathResource
;
import
static
java
.
lang
.
String
.*;
/**
* Convenience utilities for common operations with test resources.
*
* @author Chris Beams
*/
public
class
TestResourceUtils
{
public
abstract
class
TestResourceUtils
{
/**
* Load
s
a {@link ClassPathResource} qualified by the simple name of clazz,
* Load a {@link ClassPathResource} qualified by the simple name of clazz,
* and relative to the package for clazz.
*
* <p>Example: given a clazz 'com.foo.BarTests' and a resourceSuffix of 'context.xml',
* this method will return a ClassPathResource representing com/foo/BarTests-context.xml
*
* <p>Intended for use loading context configuration XML files within JUnit tests.
*
* @param clazz
* @param resourceSuffix
*/
public
static
ClassPathResource
qualifiedResource
(
Class
<?>
clazz
,
String
resourceSuffix
)
{
return
new
ClassPathResource
(
format
(
"%s-%s"
,
clazz
.
getSimpleName
(),
resourceSuffix
),
clazz
);
return
new
ClassPathResource
(
String
.
format
(
"%s-%s"
,
clazz
.
getSimpleName
(),
resourceSuffix
),
clazz
);
}
}
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java
浏览文件 @
2f9ed591
/*
* Copyright 2002-201
4
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.
...
...
@@ -40,8 +40,8 @@ public abstract class DatabasePopulatorUtils {
* @throws DataAccessException if an error occurs, specifically a {@link ScriptException}
*/
public
static
void
execute
(
DatabasePopulator
populator
,
DataSource
dataSource
)
throws
DataAccessException
{
Assert
.
notNull
(
populator
,
"DatabasePopulator must
be provided
"
);
Assert
.
notNull
(
dataSource
,
"DataSource must
be provided
"
);
Assert
.
notNull
(
populator
,
"DatabasePopulator must
not be null
"
);
Assert
.
notNull
(
dataSource
,
"DataSource must
not be null
"
);
try
{
Connection
connection
=
DataSourceUtils
.
getConnection
(
dataSource
);
try
{
...
...
@@ -53,11 +53,10 @@ public abstract class DatabasePopulatorUtils {
}
}
}
catch
(
Exception
ex
)
{
catch
(
Throwable
ex
)
{
if
(
ex
instanceof
ScriptException
)
{
throw
(
ScriptException
)
ex
;
}
throw
new
UncategorizedScriptException
(
"Failed to execute database script"
,
ex
);
}
}
...
...
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java
浏览文件 @
2f9ed591
...
...
@@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
*/
public
class
ResourceDatabasePopulator
implements
DatabasePopulator
{
private
List
<
Resource
>
scripts
=
new
ArrayList
<>();
List
<
Resource
>
scripts
=
new
ArrayList
<>();
private
String
sqlScriptEncoding
;
...
...
@@ -117,7 +117,7 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
*/
public
void
addScript
(
Resource
script
)
{
Assert
.
notNull
(
script
,
"Script must not be null"
);
getScripts
()
.
add
(
script
);
this
.
scripts
.
add
(
script
);
}
/**
...
...
@@ -126,7 +126,7 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
*/
public
void
addScripts
(
Resource
...
scripts
)
{
assertContentsOfScriptArray
(
scripts
);
getScripts
()
.
addAll
(
Arrays
.
asList
(
scripts
));
this
.
scripts
.
addAll
(
Arrays
.
asList
(
scripts
));
}
/**
...
...
@@ -140,6 +140,11 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
this
.
scripts
=
new
ArrayList
<>(
Arrays
.
asList
(
scripts
));
}
private
void
assertContentsOfScriptArray
(
Resource
...
scripts
)
{
Assert
.
notNull
(
scripts
,
"Scripts array must not be null"
);
Assert
.
noNullElements
(
scripts
,
"Scripts array must not contain null elements"
);
}
/**
* Specify the encoding for the configured SQL scripts, if different from the
* platform encoding.
...
...
@@ -220,6 +225,7 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
this
.
ignoreFailedDrops
=
ignoreFailedDrops
;
}
/**
* {@inheritDoc}
* @see #execute(DataSource)
...
...
@@ -227,10 +233,10 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
@Override
public
void
populate
(
Connection
connection
)
throws
ScriptException
{
Assert
.
notNull
(
connection
,
"Connection must not be null"
);
for
(
Resource
script
:
getScripts
()
)
{
ScriptUtils
.
executeSqlScript
(
connection
,
encodeScript
(
script
),
this
.
continueOnError
,
this
.
ignoreFailedDrops
,
this
.
commentPrefix
,
this
.
separator
,
this
.
blockCommentStartDelimiter
,
this
.
blockCommentEndDelimiter
);
for
(
Resource
script
:
this
.
scripts
)
{
EncodedResource
encodedScript
=
new
EncodedResource
(
script
,
this
.
sqlScriptEncoding
);
ScriptUtils
.
executeSqlScript
(
connection
,
encodedScript
,
this
.
continueOnError
,
this
.
ignoreFailedDrops
,
this
.
commentPrefix
,
this
.
separator
,
this
.
blockCommentStartDelimiter
,
this
.
blockCommentEndDelimiter
);
}
}
...
...
@@ -244,28 +250,7 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
* @see #populate(Connection)
*/
public
void
execute
(
DataSource
dataSource
)
throws
ScriptException
{
Assert
.
notNull
(
dataSource
,
"DataSource must not be null"
);
DatabasePopulatorUtils
.
execute
(
this
,
dataSource
);
}
final
List
<
Resource
>
getScripts
()
{
return
this
.
scripts
;
}
/**
* {@link EncodedResource} is not a sub-type of {@link Resource}. Thus we
* always need to wrap each script resource in an {@code EncodedResource}
* using the configured {@linkplain #setSqlScriptEncoding encoding}.
* @param script the script to wrap (never {@code null})
*/
private
EncodedResource
encodeScript
(
Resource
script
)
{
Assert
.
notNull
(
script
,
"Script must not be null"
);
return
new
EncodedResource
(
script
,
this
.
sqlScriptEncoding
);
}
private
void
assertContentsOfScriptArray
(
Resource
...
scripts
)
{
Assert
.
notNull
(
scripts
,
"Scripts must not be null"
);
Assert
.
noNullElements
(
scripts
,
"Scripts array must not contain null elements"
);
}
}
spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulatorTests.java
浏览文件 @
2f9ed591
/*
* Copyright 2002-201
4
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.
...
...
@@ -50,22 +50,22 @@ public class ResourceDatabasePopulatorTests {
@Test
public
void
constructWithResource
()
{
ResourceDatabasePopulator
databasePopulator
=
new
ResourceDatabasePopulator
(
script1
);
assertEquals
(
1
,
databasePopulator
.
getScripts
()
.
size
());
assertEquals
(
1
,
databasePopulator
.
scripts
.
size
());
}
@Test
public
void
constructWithMultipleResources
()
{
ResourceDatabasePopulator
databasePopulator
=
new
ResourceDatabasePopulator
(
script1
,
script2
);
assertEquals
(
2
,
databasePopulator
.
getScripts
()
.
size
());
assertEquals
(
2
,
databasePopulator
.
scripts
.
size
());
}
@Test
public
void
constructWithMultipleResourcesAndThenAddScript
()
{
ResourceDatabasePopulator
databasePopulator
=
new
ResourceDatabasePopulator
(
script1
,
script2
);
assertEquals
(
2
,
databasePopulator
.
getScripts
()
.
size
());
assertEquals
(
2
,
databasePopulator
.
scripts
.
size
());
databasePopulator
.
addScript
(
script3
);
assertEquals
(
3
,
databasePopulator
.
getScripts
()
.
size
());
assertEquals
(
3
,
databasePopulator
.
scripts
.
size
());
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
...
...
@@ -95,13 +95,13 @@ public class ResourceDatabasePopulatorTests {
@Test
public
void
setScriptsAndThenAddScript
()
{
ResourceDatabasePopulator
databasePopulator
=
new
ResourceDatabasePopulator
();
assertEquals
(
0
,
databasePopulator
.
getScripts
()
.
size
());
assertEquals
(
0
,
databasePopulator
.
scripts
.
size
());
databasePopulator
.
setScripts
(
script1
,
script2
);
assertEquals
(
2
,
databasePopulator
.
getScripts
()
.
size
());
assertEquals
(
2
,
databasePopulator
.
scripts
.
size
());
databasePopulator
.
addScript
(
script3
);
assertEquals
(
3
,
databasePopulator
.
getScripts
()
.
size
());
assertEquals
(
3
,
databasePopulator
.
scripts
.
size
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录