Skip to content

Commit 3f65721

Browse files
author
Keith Donald
committed
removed new EmbeddedDatabaeBuilder methods that don't seem very useful for embedded scenarios; javadoc polishing
1 parent 222ae33 commit 3f65721

File tree

5 files changed

+12
-53
lines changed

5 files changed

+12
-53
lines changed

org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/InitializeDatabaseBeanDefinitionParser.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
import org.w3c.dom.Element;
4141

4242
/**
43-
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses {@code initialize-database} element and
44-
* creates a {@link BeanDefinition} for {@link DataSourceInitializer}. Picks up nested {@code script} elements and
43+
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses an {@code initialize-database} element and
44+
* creates a {@link BeanDefinition} of type {@link DataSourceInitializer}. Picks up nested {@code script} elements and
4545
* configures a {@link ResourceDatabasePopulator} for them.
46-
@author Dave Syer
47-
*
46+
* @author Dave Syer
47+
* @since 3.0
4848
*/
4949
public class InitializeDatabaseBeanDefinitionParser extends AbstractBeanDefinitionParser {
5050

@@ -70,7 +70,6 @@ private void setDatabasePopulator(Element element, ParserContext context, BeanDe
7070
}
7171

7272
private BeanDefinition createDatabasePopulator(Element element, List<Element> scripts, ParserContext context) {
73-
7473
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ResourceDatabasePopulator.class);
7574
builder.addPropertyValue("ignoreFailedDrops", element.getAttribute("ignore-failures").equals("DROPS"));
7675
builder.addPropertyValue("continueOnError", element.getAttribute("ignore-failures").equals("ALL"));
@@ -89,7 +88,6 @@ private BeanDefinition createDatabasePopulator(Element element, List<Element> sc
8988
builder.addPropertyValue("scripts", resourcesFactory.getBeanDefinition());
9089

9190
return builder.getBeanDefinition();
92-
9391
}
9492

9593
private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Element source,
@@ -104,6 +102,7 @@ public static class SortedResourcesFactoryBean implements FactoryBean<Resource[]
104102
private static final Log logger = LogFactory.getLog(SortedResourcesFactoryBean.class);
105103

106104
private ResourceLoader resourceLoader;
105+
107106
private List<String> locations;
108107

109108
public SortedResourcesFactoryBean(ResourceLoader resourceLoader, List<String> locations) {
@@ -115,9 +114,9 @@ public SortedResourcesFactoryBean(ResourceLoader resourceLoader, List<String> lo
115114
public Resource[] getObject() throws Exception {
116115
List<Resource> scripts = new ArrayList<Resource>();
117116
for (String location : locations) {
118-
117+
119118
if (logger.isDebugEnabled()) {
120-
logger.debug("Adding resources from pattern: "+location);
119+
logger.debug("Adding resources from pattern: " + location);
121120
}
122121

123122
if (resourceLoader instanceof ResourcePatternResolver) {

org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,6 @@ public EmbeddedDatabaseBuilder setName(String databaseName) {
7272
return this;
7373
}
7474

75-
/**
76-
* Sets a flag to say that the database populator should continue on
77-
* errors in the scripts provided (if any).
78-
*
79-
* @param continueOnError the flag value
80-
* @return this, for fluent call chaining
81-
*/
82-
public EmbeddedDatabaseBuilder continueOnError(boolean continueOnError) {
83-
this.databasePopulator.setContinueOnError(continueOnError);
84-
return this;
85-
}
86-
87-
/**
88-
* Sets a flag to say that the database populator should continue on
89-
* errors in DROP statements in the scripts provided (if any).
90-
*
91-
* @param ignoreFailedDrops the flag value
92-
* @return this, for fluent call chaining
93-
*/
94-
public EmbeddedDatabaseBuilder ignoreFailedDrops(boolean ignoreFailedDrops) {
95-
this.databasePopulator.setIgnoreFailedDrops(ignoreFailedDrops);
96-
return this;
97-
}
98-
9975
/**
10076
* Sets the type of embedded database.
10177
* Defaults to HSQL if not called.
@@ -127,7 +103,7 @@ public EmbeddedDatabaseBuilder addDefaultScripts() {
127103
addScript("data.sql");
128104
return this;
129105
}
130-
106+
131107
/**
132108
* Build the embedded database.
133109
* @return the embedded database

org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/init/DataSourceInitializer.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class DataSourceInitializer implements InitializingBean {
3636

3737
/**
3838
* Flag to explicitly enable or disable the database populator.
39-
*
4039
* @param enabled true if the database populator will be called on startup
4140
*/
4241
public void setEnabled(boolean enabled) {
@@ -45,7 +44,6 @@ public void setEnabled(boolean enabled) {
4544

4645
/**
4746
* The {@link DatabasePopulator} to use to populate the data source. Mandatory with no default.
48-
*
4947
* @param databasePopulator the database populator to use.
5048
*/
5149
public void setDatabasePopulator(DatabasePopulator databasePopulator) {
@@ -54,16 +52,14 @@ public void setDatabasePopulator(DatabasePopulator databasePopulator) {
5452

5553
/**
5654
* The {@link DataSource} to populate when this component is initialized. Mandatory with no default.
57-
*
5855
* @param dataSource the DataSource
5956
*/
6057
public void setDataSource(DataSource dataSource) {
6158
this.dataSource = dataSource;
6259
}
6360

6461
/**
65-
* Use the populator to set up data in the data source. Both properties are mandatory with no defaults.
66-
*
62+
* Use the populator to set up data in the data source. Both properties are mandatory with no defaults.
6763
* @see InitializingBean#afterPropertiesSet()
6864
*/
6965
public void afterPropertiesSet() throws Exception {

org.springframework.jdbc/src/main/resources/org/springframework/jdbc/config/spring-jdbc-3.0.xsd

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,8 @@
8282
default="true">
8383
<xsd:annotation>
8484
<xsd:documentation>
85-
Is this bean "enabled", that is, will the
86-
scripts be executed?
87-
Defaults to true, but can be used to switch on
88-
and off the
89-
initialization depending on the environment.
85+
Is this bean "enabled", meaning the scripts will be executed?
86+
Defaults to true, but can be used to switch on and off the initialization depending on the environment.
9087
</xsd:documentation>
9188
</xsd:annotation>
9289
</xsd:attribute>
@@ -130,8 +127,7 @@
130127
<xsd:attribute name="location" type="xsd:string">
131128
<xsd:annotation>
132129
<xsd:documentation><![CDATA[
133-
The resource location of an SQL script to execute. Can be a single script location or
134-
a pattern (e.g. classpath:/com/foo/sql/*-data.sql).
130+
The resource location of an SQL script to execute. Can be a single script location or a pattern (e.g. classpath:/com/foo/sql/*-data.sql).
135131
]]></xsd:documentation>
136132
</xsd:annotation>
137133
</xsd:attribute>

org.springframework.jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,13 @@ public void testBuildWithComments() {
3333
assertDatabaseCreatedAndShutdown(db);
3434
}
3535

36-
@Test
37-
public void testBuildWithCommentsAndFailedDrop() {
38-
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass()));
39-
EmbeddedDatabase db = builder.ignoreFailedDrops(true).addScript("db-schema-failed-drop-comments.sql").addScript("db-test-data.sql").build();
40-
assertDatabaseCreatedAndShutdown(db);
41-
}
42-
4336
@Test
4437
public void testBuildH2() {
4538
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass()));
4639
EmbeddedDatabase db = builder.setType(H2).addScript("db-schema.sql").addScript("db-test-data.sql").build();
4740
assertDatabaseCreatedAndShutdown(db);
4841
}
4942

50-
5143
@Test
5244
public void testBuildDerby() {
5345
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass()));

0 commit comments

Comments
 (0)