removed new EmbeddedDatabaeBuilder methods that don't seem very useful for embedded scenarios; javadoc polishing
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user