com.github.springtestdbunit.bean
Class DatabaseDataSourceConnectionFactoryBean

java.lang.Object
  extended by com.github.springtestdbunit.bean.DatabaseDataSourceConnectionFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<org.dbunit.database.DatabaseDataSourceConnection>

public class DatabaseDataSourceConnectionFactoryBean
extends Object
implements org.springframework.beans.factory.FactoryBean<org.dbunit.database.DatabaseDataSourceConnection>

A FactoryBean that can be used to create a transaction aware DatabaseDataSourceConnection using the specified dataSource. Additional configuration is also supported using setDatabaseConfig(DatabaseConfigBean).

Author:
Phillip Webb

Constructor Summary
DatabaseDataSourceConnectionFactoryBean()
           
DatabaseDataSourceConnectionFactoryBean(DataSource dataSource)
           
 
Method Summary
 org.dbunit.database.DatabaseDataSourceConnection getObject()
           
 Class<?> getObjectType()
           
 boolean isSingleton()
           
static org.dbunit.database.IDatabaseConnection newConnection(DataSource dataSource)
          Convenience method that can be used to construct a transaction aware IDatabaseConnection from a DataSource.
 void setDatabaseConfig(DatabaseConfigBean databaseConfig)
          Set an optional configuration that will be applied to the newly created DatabaseDataSourceConnection
 void setDataSource(DataSource dataSource)
          Set the data source that will be used for the DatabaseDataSourceConnection.
 void setPassword(String password)
          Set the password to use when accessing the data source.
 void setSchema(String schema)
          Set the schema to use when accessing the data source.
 void setTransactionAware(boolean transactionAware)
          Determines if the IDatabaseConnection created by this bean should be aware of Spring PlatformTransactionManagers.
 void setUsername(String username)
          Set the user name to use when accessing the data source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseDataSourceConnectionFactoryBean

public DatabaseDataSourceConnectionFactoryBean()

DatabaseDataSourceConnectionFactoryBean

public DatabaseDataSourceConnectionFactoryBean(DataSource dataSource)
Method Detail

getObject

public org.dbunit.database.DatabaseDataSourceConnection getObject()
                                                           throws Exception
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<org.dbunit.database.DatabaseDataSourceConnection>
Throws:
Exception

getObjectType

public Class<?> getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<org.dbunit.database.DatabaseDataSourceConnection>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<org.dbunit.database.DatabaseDataSourceConnection>

setDataSource

public void setDataSource(DataSource dataSource)
Set the data source that will be used for the DatabaseDataSourceConnection. This value must be set before the connection can be created.

Parameters:
dataSource - the data source

setUsername

public void setUsername(String username)
Set the user name to use when accessing the data source.

Parameters:
username - the user name or null

setPassword

public void setPassword(String password)
Set the password to use when accessing the data source.

Parameters:
password - the password or null

setSchema

public void setSchema(String schema)
Set the schema to use when accessing the data source.

Parameters:
schema - the schema or null

setDatabaseConfig

public void setDatabaseConfig(DatabaseConfigBean databaseConfig)
Set an optional configuration that will be applied to the newly created DatabaseDataSourceConnection

Parameters:
databaseConfig - the database configuration or null if no additional configuration is required.

setTransactionAware

public void setTransactionAware(boolean transactionAware)
Determines if the IDatabaseConnection created by this bean should be aware of Spring PlatformTransactionManagers. Defaults to true

Parameters:
transactionAware - If the connection should be transaction aware

newConnection

public static org.dbunit.database.IDatabaseConnection newConnection(DataSource dataSource)
Convenience method that can be used to construct a transaction aware IDatabaseConnection from a DataSource.

Parameters:
dataSource - The data source
Returns:
A IDatabaseConnection


Copyright © 2012. All Rights Reserved.