org.unitils.database.config
Class PropertiesDataSourceFactory

java.lang.Object
  extended by org.unitils.database.config.PropertiesDataSourceFactory
All Implemented Interfaces:
Configurable, DataSourceFactory

public class PropertiesDataSourceFactory
extends Object
implements DataSourceFactory

A DataSourceFactory that loads the necessary information from a properties file.

Author:
Tim Ducheyne, Filip Neven

Constructor Summary
PropertiesDataSourceFactory()
           
 
Method Summary
 DataSource createDataSource()
          Creates a new DataSource
protected  org.apache.commons.dbcp.BasicDataSource getNewDataSource()
          Returns a concrete instance of BasicDataSource.
 void init(DatabaseConfiguration tempConfig)
          Configure the default database by DatabaseConfiguration
 void init(Properties configuration)
          Initialises itself using the properties in the given Properties object.
 void init(Properties configuration, String databaseName)
          Initialises itself using the properties in the given Properties object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesDataSourceFactory

public PropertiesDataSourceFactory()
Method Detail

init

public void init(Properties configuration,
                 String databaseName)
Initialises itself using the properties in the given Properties object.

Specified by:
init in interface DataSourceFactory
Parameters:
configuration - The config, not null
databaseName -

init

public void init(Properties configuration)
Initialises itself using the properties in the given Properties object.

Specified by:
init in interface Configurable
Parameters:
configuration - The config, not null

init

public void init(DatabaseConfiguration tempConfig)
Description copied from interface: DataSourceFactory
Configure the default database by DatabaseConfiguration

Specified by:
init in interface DataSourceFactory

createDataSource

public DataSource createDataSource()
Description copied from interface: DataSourceFactory
Creates a new DataSource

Specified by:
createDataSource in interface DataSourceFactory
Returns:
The DataSource, not null

getNewDataSource

protected org.apache.commons.dbcp.BasicDataSource getNewDataSource()
Returns a concrete instance of BasicDataSource. This method may be overridden e.g. to return a mock instance for testing

Returns:
An instance of BasicDataSource


Copyright © 2014. All Rights Reserved.