Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
296099f2
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,发现更多精彩内容 >>
提交
296099f2
编写于
8月 09, 2011
作者:
D
David Syer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SPR-8592: add SpEL support in <jdbc:/>
上级
0c0ab97a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
7 deletion
+33
-7
org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java
...ngframework/jdbc/config/DatabasePopulatorConfigUtils.java
+5
-7
org.springframework.jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java
...ework/jdbc/config/InitializeDatabaseIntegrationTests.java
+7
-0
org.springframework.jdbc/src/test/resources/org/springframework/jdbc/config/jdbc-initialize-expression-config.xml
...amework/jdbc/config/jdbc-initialize-expression-config.xml
+21
-0
未找到文件。
org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java
浏览文件 @
296099f2
...
@@ -16,19 +16,18 @@
...
@@ -16,19 +16,18 @@
package
org.springframework.jdbc.config
;
package
org.springframework.jdbc.config
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
org.w3c.dom.Element
;
import
org.springframework.beans.BeanMetadataElement
;
import
org.springframework.beans.BeanMetadataElement
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.TypedStringValue
;
import
org.springframework.beans.factory.support.BeanDefinitionBuilder
;
import
org.springframework.beans.factory.support.BeanDefinitionBuilder
;
import
org.springframework.beans.factory.support.ManagedList
;
import
org.springframework.beans.factory.support.ManagedList
;
import
org.springframework.jdbc.datasource.init.CompositeDatabasePopulator
;
import
org.springframework.jdbc.datasource.init.CompositeDatabasePopulator
;
import
org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
;
import
org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.xml.DomUtils
;
import
org.springframework.util.xml.DomUtils
;
import
org.w3c.dom.Element
;
/**
/**
* @author Juergen Hoeller
* @author Juergen Hoeller
...
@@ -63,16 +62,15 @@ class DatabasePopulatorConfigUtils {
...
@@ -63,16 +62,15 @@ class DatabasePopulatorConfigUtils {
delegate
.
addPropertyValue
(
"ignoreFailedDrops"
,
ignoreFailedDrops
);
delegate
.
addPropertyValue
(
"ignoreFailedDrops"
,
ignoreFailedDrops
);
delegate
.
addPropertyValue
(
"continueOnError"
,
continueOnError
);
delegate
.
addPropertyValue
(
"continueOnError"
,
continueOnError
);
List
<
String
>
locations
=
Arrays
.
asList
(
scriptElement
.
getAttribute
(
"location"
));
// Use a factory bean for the resources so they can be given an order if a pattern is used
// Use a factory bean for the resources so they can be given an order if a pattern is used
BeanDefinitionBuilder
resourcesFactory
=
BeanDefinitionBuilder
.
genericBeanDefinition
(
SortedResourcesFactoryBean
.
class
);
BeanDefinitionBuilder
resourcesFactory
=
BeanDefinitionBuilder
.
genericBeanDefinition
(
SortedResourcesFactoryBean
.
class
);
resourcesFactory
.
addConstructorArgValue
(
locations
);
resourcesFactory
.
addConstructorArgValue
(
new
TypedStringValue
(
scriptElement
.
getAttribute
(
"location"
))
);
delegate
.
addPropertyValue
(
"scripts"
,
resourcesFactory
.
getBeanDefinition
());
delegate
.
addPropertyValue
(
"scripts"
,
resourcesFactory
.
getBeanDefinition
());
if
(
StringUtils
.
hasLength
(
scriptElement
.
getAttribute
(
"encoding"
)))
{
if
(
StringUtils
.
hasLength
(
scriptElement
.
getAttribute
(
"encoding"
)))
{
delegate
.
addPropertyValue
(
"sqlScriptEncoding"
,
scriptElement
.
getAttribute
(
"encoding"
));
delegate
.
addPropertyValue
(
"sqlScriptEncoding"
,
new
TypedStringValue
(
scriptElement
.
getAttribute
(
"encoding"
)
));
}
}
if
(
StringUtils
.
hasLength
(
scriptElement
.
getAttribute
(
"separator"
)))
{
if
(
StringUtils
.
hasLength
(
scriptElement
.
getAttribute
(
"separator"
)))
{
delegate
.
addPropertyValue
(
"separator"
,
scriptElement
.
getAttribute
(
"separator"
));
delegate
.
addPropertyValue
(
"separator"
,
new
TypedStringValue
(
scriptElement
.
getAttribute
(
"separator"
)
));
}
}
delegates
.
add
(
delegate
.
getBeanDefinition
());
delegates
.
add
(
delegate
.
getBeanDefinition
());
}
}
...
...
org.springframework.jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java
浏览文件 @
296099f2
...
@@ -91,6 +91,13 @@ public class InitializeDatabaseIntegrationTests {
...
@@ -91,6 +91,13 @@ public class InitializeDatabaseIntegrationTests {
assertCorrectSetup
(
dataSource
);
assertCorrectSetup
(
dataSource
);
}
}
@Test
public
void
testScriptNameWithExpressions
()
throws
Exception
{
context
=
new
ClassPathXmlApplicationContext
(
"org/springframework/jdbc/config/jdbc-initialize-expression-config.xml"
);
DataSource
dataSource
=
context
.
getBean
(
"dataSource"
,
DataSource
.
class
);
assertCorrectSetup
(
dataSource
);
}
@Test
@Test
public
void
testCacheInitialization
()
throws
Exception
{
public
void
testCacheInitialization
()
throws
Exception
{
context
=
new
ClassPathXmlApplicationContext
(
"org/springframework/jdbc/config/jdbc-initialize-cache-config.xml"
);
context
=
new
ClassPathXmlApplicationContext
(
"org/springframework/jdbc/config/jdbc-initialize-cache-config.xml"
);
...
...
org.springframework.jdbc/src/test/resources/org/springframework/jdbc/config/jdbc-initialize-expression-config.xml
0 → 100644
浏览文件 @
296099f2
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:jdbc=
"http://www.springframework.org/schema/jdbc"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:util=
"http://www.springframework.org/schema/util"
xsi:schemaLocation=
"http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"
>
<jdbc:embedded-database
id=
"dataSource"
type=
"HSQL"
/>
<jdbc:initialize-database
data-source=
"dataSource"
enabled=
"#{properties['data.source.init']}"
>
<jdbc:script
location=
"#{properties['schema.scripts']}"
/>
<jdbc:script
location=
"#{properties['insert.scripts']}"
/>
</jdbc:initialize-database>
<util:properties
id=
"properties"
>
<prop
key=
"schema.scripts"
>
classpath:org/springframework/jdbc/config/db-schema.sql
</prop>
<prop
key=
"insert.scripts"
>
classpath*:org/springframework/jdbc/config/*-data.sql
</prop>
<prop
key=
"data.source.init"
>
true
</prop>
</util:properties>
</beans>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录