org.mortbay.jetty.plus
Class AbstractDataSourceService
- LifeCycle, Service
public abstract class AbstractDataSourceService
AbstractDataSourceService
Base class for DataSource Service implementations.
This class provides support for plugging DataSources and
DataSource Connection pooling implementations into JettyPlus.
A DefaultDataSourceService subclass provides a Connection pooling
implementation courtesy of XAPool project http://xapool.experlog.com.
If you wish to incorporate a different connection pooling implementation,
then subclass this class an implement the addDataSource(name, connectionpoolingdatasource)
method.
protected Map | dsMap - Map of jndiNames to DataSource objects.
|
DataSource | addConnectionPoolDataSource(String jndiName, ConnectionPoolDataSource cpds) - Add a JDBC2/3 compliant source of poolable connections.
|
void | addDataSource(String jndiName, DataSource ds) - Add a DataSource implementation to JettyPlus.
|
abstract DataSource | createPooledDataSource(String jndiName, ConnectionPoolDataSource cpds) - Implement this method to create your pool implementation.
|
DataSource | getDataSource(String jndiName) - Get a DataSource implementation from the list of registered DataSources.
|
protected Reference | getDataSourceReference(String jndiName, DataSource ds) - Create a Reference for a DataSource.
|
void | start() - Start the Service.
|
dsMap
protected Map dsMap
Map of jndiNames to DataSource objects.
AbstractDataSourceService
public AbstractDataSourceService()
Constructor.
addConnectionPoolDataSource
public DataSource addConnectionPoolDataSource(String jndiName,
ConnectionPoolDataSource cpds)
throws Exception
Add a JDBC2/3 compliant source of poolable connections.
The pool implementation is pluggable in JettyPlus. To use
a particular pool implementation (eg XAPool, DBCP etc),
subclass this class and implement the method createPooledDataSource()
to instantiate the pool. A DefaultDataSourceService is provided that uses
XAPool to plug in a Pool implementation.
The DataSource returned by this method must be capable of
interacting with the pool implemenation, as the DataSource
will be bound into JNDI and will be accessed by webapps
doing a lookup on java:comp/env/
addDataSource
public void addDataSource(String jndiName,
DataSource ds)
throws Exception
Add a DataSource implementation to JettyPlus.
Note that the particular javax.sql.DataSource implementation
may implement many other features, such as internal connection
pooling. If this is the case, and you want to take advantage
jndiName
- then name the client uses to lookup the DataSource relative to java:comp/envds
- the javax.sql.DataSource implementation
createPooledDataSource
public abstract DataSource createPooledDataSource(String jndiName,
ConnectionPoolDataSource cpds)
throws Exception
Implement this method to create your pool implementation.
The method must return a javax.sql.DataSource that will be bound
into JNDI for client lookups on java:comp/env
getDataSource
public DataSource getDataSource(String jndiName)
Get a DataSource implementation from the list of registered DataSources.
jndiName
- the name of the DataSource from addDataSource()
getDataSourceReference
protected Reference getDataSourceReference(String jndiName,
DataSource ds)
Create a Reference for a DataSource.
The Reference will be bound into JNDI. Lookups on the Reference
will return the instance of the DataSource as stored in the dsMap.
start
public void start()
throws Exception
Start the Service. Called by org.mortbay.jetty.plus.Server.start().
This will bind all of the registered DataSources into the global java:
namespace in JNDI.
- start in interface Service
- start in interface LifeCycle
- start in interface AbstractService
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.