org.apache.torque.dsfactory
Class JndiDataSourceFactory

java.lang.Object
  extended byorg.apache.torque.dsfactory.AbstractDataSourceFactory
      extended byorg.apache.torque.dsfactory.JndiDataSourceFactory
All Implemented Interfaces:
DataSourceFactory

public class JndiDataSourceFactory
extends AbstractDataSourceFactory
implements DataSourceFactory

A factory that looks up the DataSource from JNDI. It is also able to deploy the DataSource based on properties found in the configuration. This factory tries to avoid excessive context lookups to improve speed. The time between two lookups can be configured. The default is 0 (no cache).

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

Field Summary
 
Fields inherited from class org.apache.torque.dsfactory.AbstractDataSourceFactory
CONNECTION_KEY, DEFAULT_CONNECTION_KEY, DEFAULT_POOL_KEY, DEFAULT_SCHEMA_KEY, DEFAULTS_KEY, POOL_KEY, SCHEMA_KEY
 
Fields inherited from interface org.apache.torque.dsfactory.DataSourceFactory
DSFACTORY_KEY, FACTORY_KEY
 
Constructor Summary
JndiDataSourceFactory()
           
 
Method Summary
 void close()
          Does nothing.
 javax.sql.DataSource getDataSource()
           
 void initialize(org.apache.commons.configuration.Configuration configuration)
          Initialize the factory.
 
Methods inherited from class org.apache.torque.dsfactory.AbstractDataSourceFactory
applyConfiguration, getSchema, initCPDS, setProperty, setSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.torque.dsfactory.DataSourceFactory
getSchema, setSchema
 

Constructor Detail

JndiDataSourceFactory

public JndiDataSourceFactory()
Method Detail

getDataSource

public javax.sql.DataSource getDataSource()
                                   throws TorqueException
Specified by:
getDataSource in interface DataSourceFactory
Specified by:
getDataSource in class AbstractDataSourceFactory
Returns:
the DataSource configured by the factory.
Throws:
TorqueException - if the source can't be returned
See Also:
DataSourceFactory.getDataSource()

initialize

public void initialize(org.apache.commons.configuration.Configuration configuration)
                throws TorqueException
Description copied from interface: DataSourceFactory
Initialize the factory.

Specified by:
initialize in interface DataSourceFactory
Overrides:
initialize in class AbstractDataSourceFactory
Parameters:
configuration - where to load the factory settings from
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
See Also:
DataSourceFactory.initialize(org.apache.commons.configuration.Configuration)

close

public void close()
Does nothing. We do not want to close a dataSource retrieved from Jndi, because other applications might use it as well.

Specified by:
close in interface DataSourceFactory


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