Class DataSourceConnectionFactory
java.lang.Object
org.castor.cpa.persistence.sql.connection.DataSourceConnectionFactory
- All Implemented Interfaces:
ConnectionFactory
- Since:
- 0.9.9
- Version:
- $Revision: 8111 $ $Date: 2006-04-12 15:13:08 -0600 (Wed, 12 Apr 2006) $
- Author:
- Werner Guttmann, Ralf Joachim
-
Constructor Summary
ConstructorsConstructorDescriptionDataSourceConnectionFactory
(DataSource dataSource, boolean useProxies, ClassLoader loader) Constructs a new DataSourceConnectionFactory with given database and mapping.DataSourceConnectionFactory
(DataSource datasource, boolean useProxies) Constructs a new DataSourceConnectionFactory with given name, engine, mapping and datasource. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
buildMethodName
(String name) Build the name of the method to set the parameter value of the given name.Creates a new JDBC Connection instance.void
Initialize the concrete factory.static DataSource
loadDataSource
(DataSource confDataSource, ClassLoader loader) Initialize JDBC DataSource instance with the given database configuration instances and the given class loader.static void
setParameters
(DataSource dataSource, Param[] params) Set all the parameters of the given array at the given datasource by calling one of the set methods of the datasource.
-
Constructor Details
-
DataSourceConnectionFactory
Constructs a new DataSourceConnectionFactory with given name, engine, mapping and datasource. Factory will be ready to use without calling initialize first.- Parameters:
datasource
- The preconfigured datasource to use for creating connections.useProxies
- Wrap JDBC connections by proxies?
-
DataSourceConnectionFactory
Constructs a new DataSourceConnectionFactory with given database and mapping. Initialize needs to be called before using the factory to create connections.- Parameters:
dataSource
- DataSouce configuration.useProxies
- Wrap JDBC connections by proxies?loader
- ClassLoader to use.
-
-
Method Details
-
loadDataSource
public static DataSource loadDataSource(DataSource confDataSource, ClassLoader loader) throws MappingException Initialize JDBC DataSource instance with the given database configuration instances and the given class loader.- Parameters:
confDataSource
- DataSource configuration.loader
- ClassLoader to use.- Returns:
- The initialized DataSource.
- Throws:
MappingException
- Problem related to analysing the JDO configuration.
-
setParameters
Set all the parameters of the given array at the given datasource by calling one of the set methods of the datasource.- Parameters:
dataSource
- The datasource to set the parameters on.params
- The parameters to set on the datasource.- Throws:
MappingException
- If one of the parameters could not be set.
-
buildMethodName
Build the name of the method to set the parameter value of the given name. The name of the method is build by preceding given parameter name with 'set' followed by all letters of the name. In addition the first letter and all letters following a '-' sign are converted to upper case.- Parameters:
name
- The name of the parameter.- Returns:
- The name of the method to set the value of this parameter.
-
initializeFactory
Initialize the concrete factory.- Specified by:
initializeFactory
in interfaceConnectionFactory
- Throws:
MappingException
- If concrete factory could not be initialized.
-
createConnection
Creates a new JDBC Connection instance.- Specified by:
createConnection
in interfaceConnectionFactory
- Returns:
- A JDBC Connection.
- Throws:
SQLException
- If the JDBC connection cannot be created.
-