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.

Version:
$Id: JndiDataSourceFactory.java,v 1.6 2003/05/14 19:38:04 mpoeschl Exp $
Author:
John McNally

Field Summary
private  javax.naming.Context ctx
          The context to get the resource from.
private static org.apache.commons.logging.Log log
          The log.
private  java.lang.String path
          The path to get the resource from.
 
Fields inherited from class org.apache.torque.dsfactory.AbstractDataSourceFactory
CONNECTION_KEY, DEFAULT_CONNECTION_KEY, DEFAULT_POOL_KEY, POOL_KEY
 
Constructor Summary
JndiDataSourceFactory()
           
 
Method Summary
private  void bindDStoJndi(javax.naming.Context ctx, java.lang.String path, java.lang.Object ds)
           
private  void debugCtx(javax.naming.Context ctx)
           
 javax.sql.DataSource getDataSource()
           
private  void initDataSource(org.apache.commons.configuration.Configuration configuration)
          Initializes the DataSource.
 void initialize(org.apache.commons.configuration.Configuration configuration)
          Initialize the factory.
private  void initJNDI(org.apache.commons.configuration.Configuration configuration)
          Initializes JNDI.
 
Methods inherited from class org.apache.torque.dsfactory.AbstractDataSourceFactory
applyConfiguration, initCPDS, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
The log.


path

private java.lang.String path
The path to get the resource from.


ctx

private javax.naming.Context ctx
The context to get the resource from.

Constructor Detail

JndiDataSourceFactory

public JndiDataSourceFactory()
Method Detail

getDataSource

public javax.sql.DataSource getDataSource()
                                   throws TorqueException
Specified by:
getDataSource in interface DataSourceFactory
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
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)

initJNDI

private void initJNDI(org.apache.commons.configuration.Configuration configuration)
               throws TorqueException
Initializes JNDI.

Parameters:
configuration - where to read the settings from
Throws:
TorqueException - if a property set fails

initDataSource

private void initDataSource(org.apache.commons.configuration.Configuration configuration)
                     throws TorqueException
Initializes the DataSource.

Parameters:
configuration - where to read the settings from
Throws:
TorqueException - if a property set fails

debugCtx

private void debugCtx(javax.naming.Context ctx)
               throws javax.naming.NamingException
Parameters:
ctx - the context
Throws:
javax.naming.NamingException

bindDStoJndi

private void bindDStoJndi(javax.naming.Context ctx,
                          java.lang.String path,
                          java.lang.Object ds)
                   throws java.lang.Exception
Parameters:
ctx -
path -
ds -
Throws:
java.lang.Exception


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