removed new EmbeddedDatabaeBuilder methods that don't seem very useful for embedded scenarios; javadoc polishing
This commit is contained in:
parent
222ae33666
commit
3f65721ba8
|
|
@ -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<Element> 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<String> locations;
|
||||
|
||||
public SortedResourcesFactoryBean(ResourceLoader resourceLoader, List<String> locations) {
|
||||
|
|
@ -115,9 +114,9 @@ public class InitializeDatabaseBeanDefinitionParser extends AbstractBeanDefiniti
|
|||
public Resource[] getObject() throws Exception {
|
||||
List<Resource> scripts = new ArrayList<Resource>();
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -82,11 +82,8 @@
|
|||
default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
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.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
|
|
@ -130,8 +127,7 @@
|
|||
<xsd:attribute name="location" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
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).
|
||||
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).
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
|
|
|
|||
Loading…
Reference in New Issue