Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.torque.dsfactory
Class JndiDataSourceFactory  view JndiDataSourceFactory download JndiDataSourceFactory.java

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,v 1.6.2.3 2004/10/20 14:13:58 henning Exp $

Field Summary
private  javax.naming.Context ctx
          The context to get the resource from.
private  javax.sql.DataSource ds
          A locally cached copy of the DataSource
private  long lastLookup
          Time of last actual lookup action
private static org.apache.commons.logging.Log log
          The log.
private  java.lang.String path
          The path to get the resource from.
private  long ttl
          Time between two lookups
 
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.


ds

private javax.sql.DataSource ds
A locally cached copy of the DataSource


lastLookup

private long lastLookup
Time of last actual lookup action


ttl

private long ttl
Time between two lookups

Constructor Detail

JndiDataSourceFactory

public JndiDataSourceFactory()
Method Detail

getDataSource

public javax.sql.DataSource getDataSource()
                                   throws org.apache.torque.TorqueException
Specified by:
getDataSource in interface DataSourceFactory

initialize

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

Specified by:
initialize in interface DataSourceFactory

initJNDI

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


initDataSource

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


debugCtx

private void debugCtx(javax.naming.Context ctx)
               throws javax.naming.NamingException

bindDStoJndi

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