|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory
public class EmbeddedDatabaseFactory
Creates a EmbeddedDatabase
instance. Callers are guaranteed that the returned database has been fully
initialized and populated.
Can be configured:
Call setDatabaseName(String)
to change the name of the database.
Call setDatabaseType(EmbeddedDatabaseType)
to set the database type if you wish to use one of the supported types.
Call setDatabaseConfigurer(EmbeddedDatabaseConfigurer)
to configure support for your own embedded database type.
Call setDatabasePopulator(DatabasePopulator)
to change the algorithm used to populate the database.
Call setDataSourceFactory(DataSourceFactory)
to change the type of DataSource used to connect to the database.
Call getDatabase()
to get the EmbeddedDatabase
instance.
Constructor Summary | |
---|---|
EmbeddedDatabaseFactory()
|
Method Summary | |
---|---|
EmbeddedDatabase |
getDatabase()
Factory method that returns the embedded database instance. |
protected DataSource |
getDataSource()
Hook that gets the DataSource that provides the connectivity to the embedded database. |
protected void |
initDatabase()
Hook to initialize the embedded database. |
void |
setDatabaseConfigurer(EmbeddedDatabaseConfigurer configurer)
Set the strategy that will be used to configure the embedded database instance. |
void |
setDatabaseName(String databaseName)
Set the name of the database. |
void |
setDatabasePopulator(DatabasePopulator populator)
Set the strategy that will be used to populate the embedded database. |
void |
setDatabaseType(EmbeddedDatabaseType type)
Set the type of embedded database to use. |
void |
setDataSourceFactory(DataSourceFactory dataSourceFactory)
Set the factory to use to create the DataSource instance that connects to the embedded database. |
protected void |
shutdownDatabase()
Hook to shutdown the embedded database. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EmbeddedDatabaseFactory()
Method Detail |
---|
public void setDatabaseName(String databaseName)
databaseName
- name of the test databasepublic void setDataSourceFactory(DataSourceFactory dataSourceFactory)
Defaults to SimpleDriverDataSourceFactory
.
public void setDatabaseType(EmbeddedDatabaseType type)
type
- the test database typepublic void setDatabaseConfigurer(EmbeddedDatabaseConfigurer configurer)
Call this when you wish to use an embedded database type not already supported.
public void setDatabasePopulator(DatabasePopulator populator)
DataSourceInitializer.setDatabasePopulator(org.springframework.jdbc.datasource.init.DatabasePopulator)
public EmbeddedDatabase getDatabase()
protected void initDatabase()
getDataSource()
returns the DataSource providing connectivity to the db.
protected void shutdownDatabase()
getDataSource()
returns null. Does nothing if no embedded database has been initialized.
protected final DataSource getDataSource()
Returns null
if the DataSource has not been initialized or the database
has been shut down. Subclasses may call to access the DataSource instance directly.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |