|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.turbine.services.BaseInitable | +--org.apache.turbine.services.BaseService | +--org.apache.turbine.services.db.TurbinePoolBrokerService
Turbine's default implementation of PoolBrokerService
.
Inner Class Summary | |
protected class |
TurbinePoolBrokerService.Monitor
This inner class monitors the PoolBrokerService . |
Field Summary | |
static java.lang.String |
DEFAULT
Name of the default connection pool. |
private java.lang.String |
defaultPool
Default database pool |
private java.util.Map |
pools
The various connection pools this broker contains. |
Fields inherited from class org.apache.turbine.services.BaseService |
configuration, name, properties, serviceBroker |
Fields inherited from class org.apache.turbine.services.BaseInitable |
initableBroker, isInitialized |
Fields inherited from interface org.apache.turbine.services.db.PoolBrokerService |
DEFAULT_POOL, SERVICE_NAME |
Constructor Summary | |
TurbinePoolBrokerService()
|
Method Summary | |
DBConnection |
getConnection()
This method returns a DBConnection from the default pool. |
DBConnection |
getConnection(java.lang.String name)
This method returns a DBConnection from the pool with the specified name. |
DBConnection |
getConnection(java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password)
Deprecated. Database parameters should not be specified each time a DBConnection is fetched from the service. |
private static java.lang.String |
getDatabaseProperty(java.lang.String db,
java.lang.String prop)
Returns the specified property of the given database, or the empty string if no value is set for the property. |
DB |
getDB()
Returns the database adapter for the default connection pool. |
DB |
getDB(java.lang.String name)
Returns database adapter for a specific connection pool. |
java.lang.String |
getDefaultDB()
Return the default pool. |
private ConnectionPool |
getPool()
This method returns the default pool. |
private ConnectionPool |
getPool(java.lang.String name)
This method returns a pool with the specified name. |
private java.lang.String |
getProperty(java.lang.String db,
java.lang.String prop)
Returns the string for the specified property of the given database. |
void |
init()
Initialize the connection pool broker. |
void |
registerPool(java.lang.String name,
java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password)
This method registers a new pool using the given parameters. |
void |
registerPool(java.lang.String name,
java.lang.String driver,
java.lang.String url,
java.lang.String username,
java.lang.String password,
int maxCons,
long expiryTime)
This thread-safe method registers a new pool using the given parameters. |
void |
releaseConnection(DBConnection dbconn)
Release a connection back to the database pool. |
void |
shutdown()
Release the database connections for all pools on service shutdown. |
Methods inherited from class org.apache.turbine.services.BaseService |
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker |
Methods inherited from class org.apache.turbine.services.BaseInitable |
getInit, getInitableBroker, init, setInit, setInitableBroker |
Methods inherited from class java.lang.Object |
|
Methods inherited from interface org.apache.turbine.services.Service |
getConfiguration, getName, getProperties, setName, setServiceBroker |
Methods inherited from interface org.apache.turbine.services.Initable |
getInit, init, setInitableBroker |
Field Detail |
public static final java.lang.String DEFAULT
private java.lang.String defaultPool
private java.util.Map pools
Constructor Detail |
public TurbinePoolBrokerService()
Method Detail |
public void init()
init
in interface Initable
init
in class BaseInitable
org.apache.turbine.services.Initable
InitializationException,
- if initialization of this
class was not successful.public java.lang.String getDefaultDB()
getDefaultDB
in interface PoolBrokerService
public void shutdown()
shutdown
in interface Initable
shutdown
in class BaseInitable
public DBConnection getConnection() throws java.lang.Exception
getConnection
in interface PoolBrokerService
TurbineException
- Any exceptions caught during processing will be
rethrown wrapped into a TurbineException.public DBConnection getConnection(java.lang.String name) throws java.lang.Exception
registerPool(String,String,String,String,String)
method, or be specified in the property file using the
following syntax:
database.[name].driver database.[name].url database.[name].username database.[name].password
getConnection
in interface PoolBrokerService
name
- The name of the pool to get a connection from.TurbineException
- Any exceptions caught during processing will be
rethrown wrapped into a TurbineException.public DBConnection getConnection(java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password) throws java.lang.Exception
getConnection
in interface PoolBrokerService
driver
- The fully-qualified name of the JDBC driver to use.url
- The URL of the database from which the connection is
desired.username
- The name of the database user.password
- The password of the database user.TurbineException
- Any exceptions caught during processing will be
rethrown wrapped into a TurbineException.public void releaseConnection(DBConnection dbconn) throws java.lang.Exception
null
references are ignored.releaseConnection
in interface PoolBrokerService
TurbineException
- Any exceptions caught during processing will be
rethrown wrapped into a TurbineException.java.lang.Exception
- A generic exception.public void registerPool(java.lang.String name, java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password) throws java.lang.Exception
registerPool
in interface PoolBrokerService
name
- The name of the pool to register.driver
- The fully-qualified name of the JDBC driver to use.url
- The URL of the database to use.username
- The name of the database user.password
- The password of the database user.java.lang.Exception
- Any exceptions caught during processing will be
rethrown wrapped into a TurbineException.public void registerPool(java.lang.String name, java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, int maxCons, long expiryTime) throws java.lang.Exception
name
- The name of the pool to register.driver
- The fully-qualified name of the JDBC driver to use.url
- The URL of the database to use.username
- The name of the database user.password
- The password of the database user.java.lang.Exception
- A generic exception.public DB getDB() throws java.lang.Exception
getDB
in interface PoolBrokerService
TurbineException
- Any exceptions caught during processing will be
rethrown wrapped into a TurbineException.public DB getDB(java.lang.String name) throws java.lang.Exception
getDB
in interface PoolBrokerService
name
- A pool name.TurbineException
- Any exceptions caught during processing will be
rethrown wrapped into a TurbineException.private ConnectionPool getPool() throws java.lang.Exception
java.lang.Exception
- A generic exception.private ConnectionPool getPool(java.lang.String name) throws java.lang.Exception
registerPool(String,String,String,String,String)
methd, or be
specified in the TurbineResources properties. This method is used
interanlly by the service.name
- The name of the pool to get.java.lang.Exception
- A generic exception.private static final java.lang.String getDatabaseProperty(java.lang.String db, java.lang.String prop)
db
- The name of the database whose property to get.prop
- The name of the property to get.private java.lang.String getProperty(java.lang.String db, java.lang.String prop)
db
- The name of the database whose property to get.prop
- The name of the property to get.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |