org.springframework.jdbc.datasource.embedded
Class EmbeddedDatabaseFactoryBean
java.lang.Object
org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory
org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean
- All Implemented Interfaces:
- org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<javax.sql.DataSource>, org.springframework.beans.factory.InitializingBean
public class EmbeddedDatabaseFactoryBean
- extends EmbeddedDatabaseFactory
- implements org.springframework.beans.factory.FactoryBean<javax.sql.DataSource>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
A subclass of EmbeddedDatabaseFactory
that implements FactoryBean
for registration as a Spring bean.
Returns the actual DataSource
that provides connectivity to the embedded database to Spring.
The target DataSource is returned instead of a EmbeddedDatabase
proxy since the FactoryBean
will manage the initialization and destruction lifecycle of the database instance.
Implements DisposableBean to shutdown the embedded database when the managing Spring container is shutdown.
- Since:
- 3.0
- Author:
- Keith Donald, Juergen Hoeller
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EmbeddedDatabaseFactoryBean
public EmbeddedDatabaseFactoryBean()
setDatabaseCleaner
public void setDatabaseCleaner(DatabasePopulator databaseCleaner)
- Set a script execution to be run in the bean destruction callback,
cleaning up the database and leaving it in a known state for others.
- Parameters:
databaseCleaner
- the database script executor to run on destroy- See Also:
EmbeddedDatabaseFactory.setDatabasePopulator(org.springframework.jdbc.datasource.init.DatabasePopulator)
,
DataSourceInitializer.setDatabaseCleaner(org.springframework.jdbc.datasource.init.DatabasePopulator)
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
destroy
public void destroy()
- Specified by:
destroy
in interface org.springframework.beans.factory.DisposableBean
getObject
public javax.sql.DataSource getObject()
- Specified by:
getObject
in interface org.springframework.beans.factory.FactoryBean<javax.sql.DataSource>
getObjectType
public java.lang.Class<? extends javax.sql.DataSource> getObjectType()
- Specified by:
getObjectType
in interface org.springframework.beans.factory.FactoryBean<javax.sql.DataSource>
isSingleton
public boolean isSingleton()
- Specified by:
isSingleton
in interface org.springframework.beans.factory.FactoryBean<javax.sql.DataSource>