org.apache.torque.dsfactory
Interface DataSourceFactory

All Known Implementing Classes:
AbstractDataSourceFactory, JndiDataSourceFactory, PerUserPoolDataSourceFactory, SharedPoolDataSourceFactory

public interface DataSourceFactory

A factory that returns a DataSource.

Version:
$Id: DataSourceFactory.java 239636 2005-08-24 12:38:09Z henning $
Author:
John McNally, Thomas Fischer

Field Summary
static java.lang.String DSFACTORY_KEY
          Key for the configuration which contains DataSourceFactories
static java.lang.String FACTORY_KEY
          Key for the configuration which contains the fully qualified name of the factory implementation class
 
Method Summary
 void close()
          A hook which is called when the resources of the associated DataSource can be released.
 javax.sql.DataSource getDataSource()
           
 java.lang.String getSchema()
          This method returns the current schema for the database connection
 void initialize(org.apache.commons.configuration.Configuration configuration)
          Initialize the factory.
 void setSchema(java.lang.String schema)
          Sets the current schema for the database connection
 

Field Detail

DSFACTORY_KEY

public static final java.lang.String DSFACTORY_KEY
Key for the configuration which contains DataSourceFactories

See Also:
Constant Field Values

FACTORY_KEY

public static final java.lang.String FACTORY_KEY
Key for the configuration which contains the fully qualified name of the factory implementation class

See Also:
Constant Field Values
Method Detail

getDataSource

public javax.sql.DataSource getDataSource()
                                   throws TorqueException
Returns:
the DataSource configured by the factory.
Throws:
TorqueException - if the source can't be returned

initialize

public void initialize(org.apache.commons.configuration.Configuration configuration)
                throws TorqueException
Initialize the factory.

Parameters:
configuration - where to load the factory settings from
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

setSchema

public void setSchema(java.lang.String schema)
Sets the current schema for the database connection

Parameters:
schema - The current schema name

getSchema

public java.lang.String getSchema()
This method returns the current schema for the database connection

Returns:
The current schema name. Null means, no schema has been set.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

close

public void close()
           throws TorqueException
A hook which is called when the resources of the associated DataSource can be released. After close() is called, the other methods may not work any more (e.g. getDataSource() might return null). It is not guaranteed that this method does anything. For example, we do not want to close connections retrieved via JNDI, so the JndiDataSouurceFactory does not close these connections

Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.


Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.