Package org.apache.torque.dsfactory
Class AbstractDataSourceFactory
java.lang.Object
org.apache.torque.dsfactory.AbstractDataSourceFactory
- All Implemented Interfaces:
DataSourceFactory
- Direct Known Subclasses:
JndiDataSourceFactory,PerUserPool2DataSourceFactory,SharedPool2DataSourceFactory
A class that contains common functionality of the factories in this
package.
- Version:
- $Id: AbstractDataSourceFactory.java 1917245 2024-04-21 14:06:23Z tv $
- Author:
- John McNally, Henning P. Schmiedehausen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String"connection" Key for the configurationstatic final String"defaults.connection" Key for the configurationstatic final String"defaults.pool" Key for the configurationstatic final String"defaults" Key for the configurationstatic final String"pool" Key for the configurationstatic booleanif format described inDuration.parse(CharSequence)should be used.Fields inherited from interface org.apache.torque.dsfactory.DataSourceFactory
DSFACTORY_KEY, FACTORY_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyAndRemoveGlobal(org.apache.commons.configuration2.Configuration conf) protected voidapplyConfiguration(org.apache.commons.configuration2.Configuration c, Object o) Iterate over a Configuration subset and apply all properties to a passed object which must contain Bean setter and getterabstract DataSourceprotected voidinitCPDS(org.apache.commons.configuration2.Configuration configuration, ConnectionPoolDataSource cpds) Initializes the ConnectionPoolDataSource.abstract voidinitialize(org.apache.commons.configuration2.Configuration configuration) Initialize the factory.protected voidinitJdbc2Pool(DataSource dataSource, org.apache.commons.configuration2.Configuration configuration) Initializes the Jdbc2PoolDataSource.protected voidsetProperty(String property, org.apache.commons.configuration2.Configuration c, Object ds) Encapsulates setting configuration properties onDataSourceobjects.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.torque.dsfactory.DataSourceFactory
close
-
Field Details
-
POOL_KEY
"pool" Key for the configuration- See Also:
-
CONNECTION_KEY
"connection" Key for the configuration- See Also:
-
DEFAULTS_KEY
"defaults" Key for the configuration- See Also:
-
DEFAULT_POOL_KEY
"defaults.pool" Key for the configuration- See Also:
-
DEFAULT_CONNECTION_KEY
"defaults.connection" Key for the configuration- See Also:
-
USE_DURATION_TEXT_FORMAT
public static boolean USE_DURATION_TEXT_FORMATif format described inDuration.parse(CharSequence)should be used.
-
-
Constructor Details
-
AbstractDataSourceFactory
public AbstractDataSourceFactory()
-
-
Method Details
-
setProperty
protected void setProperty(String property, org.apache.commons.configuration2.Configuration c, Object ds) throws Exception Encapsulates setting configuration properties onDataSourceobjects.- Parameters:
property- the property to read from the configurationc- the configuration to read the property fromds- theDataSourceinstance to write the property to- Throws:
Exception- if anything goes wrong
-
applyConfiguration
protected void applyConfiguration(org.apache.commons.configuration2.Configuration c, Object o) throws TorqueException Iterate over a Configuration subset and apply all properties to a passed object which must contain Bean setter and getter- Parameters:
c- The configuration subseto- The object to apply the properties to- Throws:
TorqueException- if a property set fails
-
initCPDS
protected void initCPDS(org.apache.commons.configuration2.Configuration configuration, ConnectionPoolDataSource cpds) throws TorqueException Initializes the ConnectionPoolDataSource.- Parameters:
configuration- where to read the settings fromcpds- data source to configure- Throws:
TorqueException- if a property set fails
-
initJdbc2Pool
protected void initJdbc2Pool(DataSource dataSource, org.apache.commons.configuration2.Configuration configuration) throws TorqueException Initializes the Jdbc2PoolDataSource.- Parameters:
dataSource- the dataSource to initialize, not null.configuration- where to read the settings from, not null.- Throws:
TorqueException- if a property set fails.
-
applyAndRemoveGlobal
public void applyAndRemoveGlobal(org.apache.commons.configuration2.Configuration conf) -
getDataSource
- Specified by:
getDataSourcein interfaceDataSourceFactory- Returns:
- the
DataSourceconfigured by the factory. - Throws:
TorqueException- if the source can't be returned
-
initialize
public abstract void initialize(org.apache.commons.configuration2.Configuration configuration) throws TorqueException Initialize the factory.- Specified by:
initializein interfaceDataSourceFactory- Parameters:
configuration- where to load the factory settings from- Throws:
TorqueException- Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
-