|
PAJES 3.0.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.pajes.servlet.PajesContextListener
org.pajes.db.ConnectionManager
public class ConnectionManager
Manages named connection pools and the retrieval of database connections from them.
The connection manager maintains a cache of one or more connection pools, each registered under a unique pool name.
The ConnectionManager should be defined as a <listener> in the web application deployment descriptor.
ConnectionPool| Field Summary | |
|---|---|
static java.lang.String |
DB_XML
The path of the database.xml file, relative to the servlet
context root. |
| Constructor Summary | |
|---|---|
ConnectionManager()
Creates a new ConnectionManager. |
|
| Method Summary | |
|---|---|
void |
contextDestroyed(javax.servlet.ServletContextEvent sce)
Notification that the servlet context is about to be shut down. |
void |
contextInitialized(javax.servlet.ServletContextEvent sce)
Notification that the web application is ready to process requests. |
ConnectionPool |
createPool(ConnectionPoolDefinition defn)
Creates and registers a new connection pool. |
protected ConnectionPool |
createPool(java.lang.String jdbcDriverClass,
java.lang.String dbServerURL,
int numInitialConnections,
int maxConnections,
java.lang.String user,
java.lang.String password,
long connectionTimeout,
long retryInterval)
Creates a new connection pool. |
ConnectionPool |
createPool(java.lang.String poolName,
java.lang.String jdbcDriverClass,
java.lang.String dbServerURL,
int numInitialConnections,
int maxConnections,
java.lang.String user,
java.lang.String password,
long connectionTimeout,
long retryInterval)
Creates and registers a new connection pool. |
void |
destroyPool(java.lang.String poolName)
Calls the specified pools destroy() method, and removes the pool from the list of available pools. |
protected ConnectionPoolConfiguration |
getConnectionPoolConfiguration(javax.servlet.ServletContext context)
Returns the ConnectionPoolConfiguration object. |
java.lang.String |
getLinkedPool(java.lang.String poolName)
Returns the pool to which the nominated pool is linked, or null if the pool is not managed by this instance, or the pool name does not exist. |
ConnectionPool |
getPool()
Returns the default connection pool. |
ConnectionPool |
getPool(java.lang.String poolName)
Return a connection pool with the specified name. |
java.util.Enumeration<java.lang.String> |
getPoolNames()
Get the names of the registered connection pools. |
protected void |
init(javax.servlet.ServletContext context)
Called by contextInitialized(javax.servlet.ServletContextEvent). |
void |
registerPool(java.lang.String poolName,
ConnectionPool connectionPool,
java.lang.String linkedPoolName)
Registers a connection pool under a specified name with this connection manager, and then initialises it. |
boolean |
releaseConnections(java.lang.Thread thread)
Release all connections that may have been left open by a Thread. |
void |
removePool(java.lang.String poolName)
Removes the pool from management by this connection manager. |
void |
setDefaultPool(java.lang.String poolName)
Sets the default connection pool. |
void |
shutdown()
Destroys all registered pools and shuts down the manager. |
java.lang.String |
toString()
Over-rides toString() from Object. |
| Methods inherited from class org.pajes.servlet.PajesContextListener |
|---|
getContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DB_XML
database.xml file, relative to the servlet
context root.
| Constructor Detail |
|---|
public ConnectionManager()
| Method Detail |
|---|
public void contextDestroyed(javax.servlet.ServletContextEvent sce)
contextDestroyed in interface javax.servlet.ServletContextListenercontextDestroyed in class PajesContextListenersce - the event class for notifications about changes to the servlet
context of a web application.public void contextInitialized(javax.servlet.ServletContextEvent sce)
Sub-classes that over-ride this MUST call
super.contextInitialized(sce) to complete PAJES
initialisation before performing any application-specific
processing.
contextInitialized in interface javax.servlet.ServletContextListenercontextInitialized in class PajesContextListenersce - the event class for notifications about changes to the servlet
context of a web application.
public ConnectionPool createPool(ConnectionPoolDefinition defn)
throws java.lang.ClassNotFoundException,
java.sql.SQLException
defn - The ConnectionPoolDefinition object.
java.lang.ClassNotFoundException - if the JDBC driver class could not be found.
java.sql.SQLException - if an error occurs creating the connection pool.
public ConnectionPool createPool(java.lang.String poolName,
java.lang.String jdbcDriverClass,
java.lang.String dbServerURL,
int numInitialConnections,
int maxConnections,
java.lang.String user,
java.lang.String password,
long connectionTimeout,
long retryInterval)
throws java.lang.ClassNotFoundException,
java.sql.SQLException
poolName - The name to register the connection pool underjdbcDriverClass - The JDBC driver class namedbServerURL - The address of a JDBC data sourcenumInitialConnections - The number of connections to initially openmaxConnections - The maximum number of connections to openuser - The database useridpassword - The database passwordconnectionTimeout - The number of milliseconds to wait for a free connection to
become availableretryInterval - The number of milliseconds between checking for a free
connection
java.lang.ClassNotFoundException - if the JDBC driver class could not be found.
java.sql.SQLException - if an error occurs creating the connection pool.
public void destroyPool(java.lang.String poolName)
throws java.sql.SQLException
poolName - the name of the connection pool to destroy.
java.sql.SQLException - if an error occurs accessing the database.
ConnectionPoolException - if the specified pool was not found.public java.lang.String getLinkedPool(java.lang.String poolName)
poolName - the name of the pool for which the linked pool is to be
retrieved
public ConnectionPool getPool()
default connection pool.
public ConnectionPool getPool(java.lang.String poolName)
poolName - the name of the connection pool to get.
ConnectionPoolException - if the specified pool was not found.public java.util.Enumeration<java.lang.String> getPoolNames()
public void registerPool(java.lang.String poolName,
ConnectionPool connectionPool,
java.lang.String linkedPoolName)
poolName - the name to register the connection pool under.connectionPool - the connection pool to be registered.linkedPoolName - the name of the pool to which this pool is linked. If null,
the pool is not linked.
ConnectionPoolException - if the specified pool already exists.ConnectionPoolpublic boolean releaseConnections(java.lang.Thread thread)
thread - the Thread object that may have opened a connection.
public void removePool(java.lang.String poolName)
poolName - the connection pool to removepublic void setDefaultPool(java.lang.String poolName)
registered is the default pool.
poolName - the default connection pool namepublic void shutdown()
public java.lang.String toString()
toString in class java.lang.Object
protected ConnectionPool createPool(java.lang.String jdbcDriverClass,
java.lang.String dbServerURL,
int numInitialConnections,
int maxConnections,
java.lang.String user,
java.lang.String password,
long connectionTimeout,
long retryInterval)
throws java.lang.ClassNotFoundException,
java.sql.SQLException
jdbcDriverClass - The JDBC driver class namedbServerURL - The address of a JDBC data sourcenumInitialConnections - The number of connections to initially openmaxConnections - The maximum number of connections to openuser - The database useridpassword - The database passwordconnectionTimeout - The number of milliseconds to wait for a free connection to
become availableretryInterval - The number of milliseconds between checking for a free
connection
java.lang.ClassNotFoundException - if the JDBC driver class could not be found.
java.sql.SQLException - if an error occurs creating the connection pool.
protected ConnectionPoolConfiguration getConnectionPoolConfiguration(javax.servlet.ServletContext context)
throws java.io.IOException
context - the servlet context.
WEB-INF/database.xml file can be located.
java.io.IOException - if an error occurs reading the deployment descriptor.protected void init(javax.servlet.ServletContext context)
contextInitialized(javax.servlet.ServletContextEvent).
Sub-classes that over-ride this MUST call
super.init(context) to complete PAJES initialisation.
context - the servlet context.
|
PAJES 3.0.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||