Top Description Fields Constructors Methods
org.springframework.jdbc.datasource.init

public Class DataSourceInitializer

extends Object
implements InitializingBean, DisposableBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean
Imports
javax.sql.DataSource, org.springframework.beans.factory.DisposableBean, .InitializingBean, org.springframework.lang.Nullable, org.springframework.util.Assert

Used to set up a database during initialization and clean up a database during destruction.
Authors
Dave Syer, Sam Brannen
Since
3.0
See Also
DatabasePopulator

Field Summary

Modifier and TypeField and Description
private DatabasePopulator
private DatabasePopulator
private DataSource
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
private void
public void
setDatabaseCleaner(DatabasePopulator
the DatabasePopulator to use during destruction
databaseCleaner
)

Set the DatabasePopulator to execute during the bean destruction phase, if any, cleaning up the database and leaving it in a known state for others.

public void
setDatabasePopulator(DatabasePopulator
the DatabasePopulator to use during initialization
databasePopulator
)

Set the DatabasePopulator to execute during the bean initialization phase, if any.

public void
setDataSource(DataSource
the DataSource
dataSource
)

The DataSource for the database to populate when this component is initialized and to clean up when this component is shut down.

public void
setEnabled(boolean
true if the database populator and database cleaner should be called on startup and shutdown, respectively
enabled
)

Flag to explicitly enable or disable the database populator and database cleaner.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

databaseCleanerback to summary
private DatabasePopulator databaseCleaner
Annotations
@Nullable
databasePopulatorback to summary
private DatabasePopulator databasePopulator
Annotations
@Nullable
dataSourceback to summary
private DataSource dataSource
Annotations
@Nullable
enabledback to summary
private boolean enabled

Constructor Detail

DataSourceInitializerback to summary
public DataSourceInitializer()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Use the database populator to set up the database.

Annotations
@Override
destroyback to summary
public void destroy()

Implements org.springframework.beans.factory.DisposableBean.destroy.

Use the database cleaner to clean up the database.

Annotations
@Override
executeback to summary
private void execute(DatabasePopulator populator)
setDatabaseCleanerback to summary
public void setDatabaseCleaner(DatabasePopulator databaseCleaner)

Set the DatabasePopulator to execute during the bean destruction phase, if any, cleaning up the database and leaving it in a known state for others.

Parameters
databaseCleaner:DatabasePopulator

the DatabasePopulator to use during destruction

See Also
setDatabasePopulator
setDatabasePopulatorback to summary
public void setDatabasePopulator(DatabasePopulator databasePopulator)

Set the DatabasePopulator to execute during the bean initialization phase, if any.

Parameters
databasePopulator:DatabasePopulator

the DatabasePopulator to use during initialization

See Also
setDatabaseCleaner
setDataSourceback to summary
public void setDataSource(DataSource dataSource)

The DataSource for 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:DataSource

the DataSource

setEnabledback to summary
public void setEnabled(boolean enabled)

Flag to explicitly enable or disable the database populator and database cleaner.

Parameters
enabled:boolean

true if the database populator and database cleaner should be called on startup and shutdown, respectively