Class DataSourceInitializer
java.lang.Object
org.springframework.jdbc.datasource.init.DataSourceInitializer
- All Implemented Interfaces:
DisposableBean,InitializingBean
- Since:
- 3.0
- Author:
- Dave Syer, Sam Brannen
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidUse the database populator to set up the database.voiddestroy()Use the database cleaner to clean up the database.voidsetDatabaseCleaner(DatabasePopulator databaseCleaner) Set theDatabasePopulatorto execute during the bean destruction phase, cleaning up the database and leaving it in a known state for others.voidsetDatabasePopulator(DatabasePopulator databasePopulator) Set theDatabasePopulatorto execute during the bean initialization phase.voidsetDataSource(DataSource dataSource) TheDataSourcefor the database to populate when this component is initialized and to clean up when this component is shut down.voidsetEnabled(boolean enabled) Flag to explicitly enable or disable the database populator and database cleaner.
-
Constructor Details
-
DataSourceInitializer
public DataSourceInitializer()
-
-
Method Details
-
setDataSource
TheDataSourcefor the database to populate when this component is initialized and to clean up when this component is shut down.This property is mandatory with no default provided.
- Parameters:
dataSource- the DataSource
-
setDatabasePopulator
Set theDatabasePopulatorto execute during the bean initialization phase.- Parameters:
databasePopulator- theDatabasePopulatorto use during initialization- See Also:
-
setDatabaseCleaner
Set theDatabasePopulatorto execute during the bean destruction phase, cleaning up the database and leaving it in a known state for others.- Parameters:
databaseCleaner- theDatabasePopulatorto use during destruction- See Also:
-
setEnabled
public void setEnabled(boolean enabled) Flag to explicitly enable or disable the database populator and database cleaner.- Parameters:
enabled-trueif the database populator and database cleaner should be called on startup and shutdown, respectively
-
afterPropertiesSet
public void afterPropertiesSet()Use the database populator to set up the database.- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
destroy
public void destroy()Use the database cleaner to clean up the database.- Specified by:
destroyin interfaceDisposableBean
-