org.apache.commons.scaffold.sql
Class ServletAdaptor

java.lang.Object
  extended by org.apache.commons.scaffold.sql.ConnectionAdaptor
      extended by org.apache.commons.scaffold.sql.ServletAdaptor

public class ServletAdaptor
extends ConnectionAdaptor

Connection adaptor for a connection pool that is exposed through the servlet context, like the Struts generic connection pool.

The ConnectionServlet will automatically set a reference to itself if an instance of this class is specified as the ConnectionAdaptor.

Version:
$Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $
Author:
Ted Husted

Field Summary
 
Fields inherited from class org.apache.commons.scaffold.sql.ConnectionAdaptor
DATA_SOURCE_KEY, datasource, JNDI_CONTEXT_KEY, pool
 
Constructor Summary
ServletAdaptor()
           
 
Method Summary
protected  DataSource getDataSource(String key)
          Return datasource from the servlet context using key as the attribute name.
 void setServlet(javax.servlet.http.HttpServlet servlet)
          Set a reference to a servlet in the application to allow access to the servlet context.
 
Methods inherited from class org.apache.commons.scaffold.sql.ConnectionAdaptor
getConnection, getConnection, getKey, getMessage, getPool, setKey, setMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletAdaptor

public ServletAdaptor()
Method Detail

setServlet

public void setServlet(javax.servlet.http.HttpServlet servlet)
Set a reference to a servlet in the application to allow access to the servlet context.


getDataSource

protected DataSource getDataSource(String key)
                            throws SQLException
Return datasource from the servlet context using key as the attribute name.

Overrides:
getDataSource in class ConnectionAdaptor
Parameters:
key - The attribute name for the resource. If null is passed, null is returned.
Returns:
null or the datasource object related to "key" TODO: Add cache to store references to the datasources by key.
Throws:
SQLException


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.