public interface DataSourceFactory
DataSource instances at runtime. In contrast to the regular datasource definitions, this
interface allows the dynamic creation of datasource at runtime. This is especially useful and needed if the datasource
information like the url, username and password are not available at configuration time. With this factory it
is possible to create datasource with configuration information which is fetched while starting the application.
Because of the dynamic creation of datasource at runtime, this interface also provides the lifecycle method closeDataSource(javax.sql.DataSource) to actually shutdown the created datasource. This method should be called
while destroying the application itself.
Note: This interface does not assume what kind of datasource is returned. It is strongly recommended to use an already existing and pooled datasource like Tomcat JDBC datasource for real life production applications.
| Modifier and Type | Method and Description |
|---|---|
void |
closeDataSource(DataSource dataSource)
Will be called if the datasource is not used anymore to allow the factory to release any resource that are used by
the created object.
|
DataSource |
createDataSource(DataSourceInformation dataSourceInformation)
Creates a datasource with the passed in information.
|
DataSource createDataSource(DataSourceInformation dataSourceInformation)
dataSourceInformation - - the DataSourceInformation parameter object which holds all dynamic information for the datasource
creation.void closeDataSource(DataSource dataSource)
dataSource - - The datasource that is not used anymore and can be destroyed by the factoryCopyright © 2016 Pivotal Software, Inc.. All rights reserved.