org.castor.jdo.engine
Class DataSourceConnectionFactory

java.lang.Object
  extended by org.castor.jdo.engine.AbstractConnectionFactory
      extended by org.castor.jdo.engine.DataSourceConnectionFactory
All Implemented Interfaces:
ConnectionFactory

public final class DataSourceConnectionFactory
extends AbstractConnectionFactory

Since:
0.9.9
Version:
$Revision: 1.6 $ $Date: 2005/10/13 08:52:17 $
Author:
Werner Guttmann, Ralf Joachim

Field Summary
 
Fields inherited from class org.castor.jdo.engine.AbstractConnectionFactory
GENERIC_ENGINE
 
Constructor Summary
DataSourceConnectionFactory(JdoConf jdoConf, int index, Mapping mapping)
          Constructs a new DataSourceConnectionFactory with given database and mapping.
DataSourceConnectionFactory(java.lang.String name, java.lang.String engine, javax.sql.DataSource datasource, Mapping mapping, javax.transaction.TransactionManager txManager)
          Constructs a new DataSourceConnectionFactory with given name, engine, mapping and datasource.
 
Method Summary
static java.lang.String buildMethodName(java.lang.String name)
          Build the name of the method to set the parameter value of the given name.
 java.sql.Connection createConnection()
          Creates a new JDBC Connection instance.
protected  void initializeFactory()
          Initialize the concrete factory.
static javax.sql.DataSource loadDataSource(Database database, java.lang.ClassLoader loader)
          Initialize JDBC DataSource instance with the given database configuration instances and the given class loader.
static void setParameters(javax.sql.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.
 
Methods inherited from class org.castor.jdo.engine.AbstractConnectionFactory
getDatabase, getEngine, getMapping, getName, getTransactionManager, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceConnectionFactory

public DataSourceConnectionFactory(java.lang.String name,
                                   java.lang.String engine,
                                   javax.sql.DataSource datasource,
                                   Mapping mapping,
                                   javax.transaction.TransactionManager txManager)
                            throws MappingException
Constructs a new DataSourceConnectionFactory with given name, engine, mapping and datasource. Factory will be ready to use without calling initialize first.

Parameters:
name - The Name of the database configuration.
engine - The Name of the persistence factory to use.
datasource - The preconfigured datasource to use for creating connections.
mapping - The previously loaded mapping.
txManager - The transaction manager to use.
Throws:
MappingException - If LockEngine could not be initialized.

DataSourceConnectionFactory

public DataSourceConnectionFactory(JdoConf jdoConf,
                                   int index,
                                   Mapping mapping)
Constructs a new DataSourceConnectionFactory with given database and mapping. Initialize needs to be called before using the factory to create connections.

Parameters:
jdoConf - An in-memory jdo configuration.
index - Index of the database configuration inside the jdo configuration.
mapping - The mapping to load.
Method Detail

loadDataSource

public static javax.sql.DataSource loadDataSource(Database database,
                                                  java.lang.ClassLoader loader)
                                           throws MappingException
Initialize JDBC DataSource instance with the given database configuration instances and the given class loader.

Parameters:
database - Database configuration.
loader - ClassLoader to use.
Returns:
The initalized DataSource.
Throws:
MappingException - Problem related to analysing the JDO configuration.

setParameters

public static void setParameters(javax.sql.DataSource dataSource,
                                 Param[] params)
                          throws MappingException
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

public static java.lang.String buildMethodName(java.lang.String name)
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

protected void initializeFactory()
                          throws MappingException
Description copied from class: AbstractConnectionFactory
Initialize the concrete factory.

Specified by:
initializeFactory in class AbstractConnectionFactory
Throws:
MappingException - If concrete factory could not be initialized.
See Also:
AbstractConnectionFactory.initializeFactory()

createConnection

public java.sql.Connection createConnection()
                                     throws java.sql.SQLException
Description copied from interface: ConnectionFactory
Creates a new JDBC Connection instance.

Returns:
A JDBC Connection.
Throws:
java.sql.SQLException - If the JDBC connection cannot be created.
See Also:
ConnectionFactory.createConnection()


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com