From 3f65721ba855a4816e53286f2308c6efd4294322 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Tue, 17 Nov 2009 00:47:34 +0000 Subject: [PATCH] removed new EmbeddedDatabaeBuilder methods that don't seem very useful for embedded scenarios; javadoc polishing --- ...nitializeDatabaseBeanDefinitionParser.java | 15 +++++------ .../embedded/EmbeddedDatabaseBuilder.java | 26 +------------------ .../init/DataSourceInitializer.java | 6 +---- .../jdbc/config/spring-jdbc-3.0.xsd | 10 +++---- .../EmbeddedDatabaseBuilderTests.java | 8 ------ 5 files changed, 12 insertions(+), 53 deletions(-) diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/InitializeDatabaseBeanDefinitionParser.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/InitializeDatabaseBeanDefinitionParser.java index 6cb07401e3..f714084c1c 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/InitializeDatabaseBeanDefinitionParser.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/InitializeDatabaseBeanDefinitionParser.java @@ -40,11 +40,11 @@ import org.springframework.util.xml.DomUtils; import org.w3c.dom.Element; /** - * {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses {@code initialize-database} element and - * creates a {@link BeanDefinition} for {@link DataSourceInitializer}. Picks up nested {@code script} elements and + * {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses an {@code initialize-database} element and + * creates a {@link BeanDefinition} of type {@link DataSourceInitializer}. Picks up nested {@code script} elements and * configures a {@link ResourceDatabasePopulator} for them. -@author Dave Syer - * + * @author Dave Syer + * @since 3.0 */ public class InitializeDatabaseBeanDefinitionParser extends AbstractBeanDefinitionParser { @@ -70,7 +70,6 @@ public class InitializeDatabaseBeanDefinitionParser extends AbstractBeanDefiniti } private BeanDefinition createDatabasePopulator(Element element, List scripts, ParserContext context) { - BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ResourceDatabasePopulator.class); builder.addPropertyValue("ignoreFailedDrops", element.getAttribute("ignore-failures").equals("DROPS")); builder.addPropertyValue("continueOnError", element.getAttribute("ignore-failures").equals("ALL")); @@ -89,7 +88,6 @@ public class InitializeDatabaseBeanDefinitionParser extends AbstractBeanDefiniti builder.addPropertyValue("scripts", resourcesFactory.getBeanDefinition()); return builder.getBeanDefinition(); - } private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Element source, @@ -104,6 +102,7 @@ public class InitializeDatabaseBeanDefinitionParser extends AbstractBeanDefiniti private static final Log logger = LogFactory.getLog(SortedResourcesFactoryBean.class); private ResourceLoader resourceLoader; + private List locations; public SortedResourcesFactoryBean(ResourceLoader resourceLoader, List locations) { @@ -115,9 +114,9 @@ public class InitializeDatabaseBeanDefinitionParser extends AbstractBeanDefiniti public Resource[] getObject() throws Exception { List scripts = new ArrayList(); for (String location : locations) { - + if (logger.isDebugEnabled()) { - logger.debug("Adding resources from pattern: "+location); + logger.debug("Adding resources from pattern: " + location); } if (resourceLoader instanceof ResourcePatternResolver) { diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java index 2da28c039d..0f26e4bc69 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java @@ -72,30 +72,6 @@ public class EmbeddedDatabaseBuilder { return this; } - /** - * Sets a flag to say that the database populator should continue on - * errors in the scripts provided (if any). - * - * @param continueOnError the flag value - * @return this, for fluent call chaining - */ - public EmbeddedDatabaseBuilder continueOnError(boolean continueOnError) { - this.databasePopulator.setContinueOnError(continueOnError); - return this; - } - - /** - * Sets a flag to say that the database populator should continue on - * errors in DROP statements in the scripts provided (if any). - * - * @param ignoreFailedDrops the flag value - * @return this, for fluent call chaining - */ - public EmbeddedDatabaseBuilder ignoreFailedDrops(boolean ignoreFailedDrops) { - this.databasePopulator.setIgnoreFailedDrops(ignoreFailedDrops); - return this; - } - /** * Sets the type of embedded database. * Defaults to HSQL if not called. @@ -127,7 +103,7 @@ public class EmbeddedDatabaseBuilder { addScript("data.sql"); return this; } - + /** * Build the embedded database. * @return the embedded database diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/init/DataSourceInitializer.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/init/DataSourceInitializer.java index 041b6bb274..f90d32a155 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/init/DataSourceInitializer.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/init/DataSourceInitializer.java @@ -36,7 +36,6 @@ public class DataSourceInitializer implements InitializingBean { /** * Flag to explicitly enable or disable the database populator. - * * @param enabled true if the database populator will be called on startup */ public void setEnabled(boolean enabled) { @@ -45,7 +44,6 @@ public class DataSourceInitializer implements InitializingBean { /** * The {@link DatabasePopulator} to use to populate the data source. Mandatory with no default. - * * @param databasePopulator the database populator to use. */ public void setDatabasePopulator(DatabasePopulator databasePopulator) { @@ -54,7 +52,6 @@ public class DataSourceInitializer implements InitializingBean { /** * The {@link DataSource} to populate when this component is initialized. Mandatory with no default. - * * @param dataSource the DataSource */ public void setDataSource(DataSource dataSource) { @@ -62,8 +59,7 @@ public class DataSourceInitializer implements InitializingBean { } /** - * Use the populator to set up data in the data source. Both properties are mandatory with no defaults. - * + * Use the populator to set up data in the data source. Both properties are mandatory with no defaults. * @see InitializingBean#afterPropertiesSet() */ public void afterPropertiesSet() throws Exception { diff --git a/org.springframework.jdbc/src/main/resources/org/springframework/jdbc/config/spring-jdbc-3.0.xsd b/org.springframework.jdbc/src/main/resources/org/springframework/jdbc/config/spring-jdbc-3.0.xsd index b6fa4d00d9..c7e57ae8e2 100644 --- a/org.springframework.jdbc/src/main/resources/org/springframework/jdbc/config/spring-jdbc-3.0.xsd +++ b/org.springframework.jdbc/src/main/resources/org/springframework/jdbc/config/spring-jdbc-3.0.xsd @@ -82,11 +82,8 @@ default="true"> - Is this bean "enabled", that is, will the - scripts be executed? - Defaults to true, but can be used to switch on - and off the - initialization depending on the environment. + Is this bean "enabled", meaning the scripts will be executed? + Defaults to true, but can be used to switch on and off the initialization depending on the environment. @@ -130,8 +127,7 @@ diff --git a/org.springframework.jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java b/org.springframework.jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java index b8a30a868b..c9afebf91d 100644 --- a/org.springframework.jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java +++ b/org.springframework.jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java @@ -33,13 +33,6 @@ public class EmbeddedDatabaseBuilderTests { assertDatabaseCreatedAndShutdown(db); } - @Test - public void testBuildWithCommentsAndFailedDrop() { - EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass())); - EmbeddedDatabase db = builder.ignoreFailedDrops(true).addScript("db-schema-failed-drop-comments.sql").addScript("db-test-data.sql").build(); - assertDatabaseCreatedAndShutdown(db); - } - @Test public void testBuildH2() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass())); @@ -47,7 +40,6 @@ public class EmbeddedDatabaseBuilderTests { assertDatabaseCreatedAndShutdown(db); } - @Test public void testBuildDerby() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass())); -- GitLab