|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.cjdbc.controller.connection.AbstractConnectionManager org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager org.objectweb.cjdbc.controller.connection.VariablePoolConnectionManager
This connection manager provides connection pooling with a dynamically adjustable pool size.
If the maximum number of active connections is not reached, the
getConnection()
method creates a connection. Else, the execution is
blocked until a connection is freed or the timeout expires. blocked until a
connection is freed or the timeout expires.
Idle connections in the pool are removed after the timeout idleTimeout if the minimum pool size has not been reached.
Nested Class Summary | |
protected class |
VariablePoolConnectionManager.RemoveIdleConnectionsThread
Allows to remove idle free connections after the idleTimeout timeout. |
Field Summary | |
static int |
DEFAULT_IDLE_TIMEOUT
Default idle timeout in milliseconds: default is 0 and means that once allocated, connections are never released. |
static int |
DEFAULT_MAX_POOL_SIZE
Default maximum pool size: default is 0 and means no limit. |
static int |
DEFAULT_WAIT_TIMEOUT
Default wait timeout in milliseconds: the default is 0 and means no timeout: waits until one connection is freed. |
private int |
idleTimeout
Time a connection can stay idle before begin released (removed from the pool) in milliseconds (0 means forever) |
private int |
initPoolSize
Initial pool size to be initialized at startup. |
private int |
maxPoolSize
Maximum pool size. |
private int |
minPoolSize
Minimum pool size. |
private java.util.LinkedList |
releaseTimes
Stores the time on which connections have been released. |
private VariablePoolConnectionManager.RemoveIdleConnectionsThread |
removeIdleConnectionsThread
Allow to remove idle connections in the pool. |
private int |
waitTimeout
Maximum time to wait for a connection in milliseconds. |
Fields inherited from class org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager |
activeConnections, freeConnections, poolSize |
Fields inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager |
backendName, backendUrl, driverClassName, driverPath, initialized, logger, rLogin, rPassword |
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent |
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION |
Constructor Summary | |
VariablePoolConnectionManager(java.lang.String backendUrl,
java.lang.String backendName,
java.lang.String rLogin,
java.lang.String rPassword,
java.lang.String driverPath,
java.lang.String driverClassName,
int minPoolSize,
int maxPoolSize,
int idleTimeout,
int waitTimeout)
Creates a new VariablePoolConnectionManager instance with
the default minPoolSize(initial pool size to be initialized at startup). |
|
VariablePoolConnectionManager(java.lang.String backendUrl,
java.lang.String backendName,
java.lang.String rLogin,
java.lang.String rPassword,
java.lang.String driverPath,
java.lang.String driverClassName,
int initPoolSize,
int minPoolSize,
int maxPoolSize,
int idleTimeout,
int waitTimeout)
Creates a new VariablePoolConnectionManager instance. |
Method Summary | |
protected java.lang.Object |
clone()
|
void |
deleteConnection(java.sql.Connection c)
Delete a connection that is no more valid. |
void |
finalizeConnections()
Releases all the connections to the database. |
java.sql.Connection |
getConnection()
Gets a connection from the pool. |
int |
getIdleTimeout()
Gets the idle timeout. |
int |
getMaxPoolSize()
Gets the max pool size. |
int |
getMinPoolSize()
Gets the min pool size. |
int |
getWaitTimeout()
Gets the wait timeout. |
java.lang.String |
getXmlImpl()
Gets xml formatted information on this connection manager |
void |
initializeConnections()
Initializes the connection(s) to the database. |
void |
releaseConnection(java.sql.Connection c)
Releases a connection. |
Methods inherited from class org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager |
getCurrentNumberOfConnections, initializeConnections |
Methods inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager |
copy, deleteConnection, finalize, getConnection, getConnectionFromDriver, getDriverClassName, getDriverPath, getLogin, getPassword, getVLogin, getXml, isInitialized, releaseConnection, retrieveConnection, setDriverClassName, setDriverPath, setLogin, setPassword, setVLogin |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_MAX_POOL_SIZE
public static final int DEFAULT_IDLE_TIMEOUT
public static final int DEFAULT_WAIT_TIMEOUT
private int initPoolSize
private int minPoolSize
private int maxPoolSize
private int idleTimeout
private int waitTimeout
private java.util.LinkedList releaseTimes
private VariablePoolConnectionManager.RemoveIdleConnectionsThread removeIdleConnectionsThread
Constructor Detail |
public VariablePoolConnectionManager(java.lang.String backendUrl, java.lang.String backendName, java.lang.String rLogin, java.lang.String rPassword, java.lang.String driverPath, java.lang.String driverClassName, int minPoolSize, int maxPoolSize, int idleTimeout, int waitTimeout)
VariablePoolConnectionManager
instance with
the default minPoolSize(initial pool size to be initialized at startup).
backendUrl
- URL of the DatabaseBackend
owning this
connection managerbackendName
- name of the DatabaseBackend
owning this
connection managerrLogin
- backend connection login to be used by this connection
managerrPassword
- backend connection password to be used by this connection
managerdriverPath
- path for driverdriverClassName
- class name for driverminPoolSize
- minimum pool size.maxPoolSize
- maximum pool size. 0 means no limit.idleTimeout
- time a connection can stay idle before begin released
(removed from the pool) in seconds. 0 means no timeout: once
allocated, connections are never released.waitTimeout
- maximum time to wait for a connection in seconds. 0
means no timeout: waits until one connection is freed.public VariablePoolConnectionManager(java.lang.String backendUrl, java.lang.String backendName, java.lang.String rLogin, java.lang.String rPassword, java.lang.String driverPath, java.lang.String driverClassName, int initPoolSize, int minPoolSize, int maxPoolSize, int idleTimeout, int waitTimeout)
VariablePoolConnectionManager
instance.
backendUrl
- URL of the DatabaseBackend
owning this
connection managerbackendName
- name of the DatabaseBackend
owning this
connection managerrLogin
- backend connection login to be used by this connection
managerrPassword
- backend connection password to be used by this connection
managerdriverPath
- path for driverdriverClassName
- class name for driverinitPoolSize
- initial pool size to be intialized at startupminPoolSize
- minimum pool size.maxPoolSize
- maximum pool size. 0 means no limit.idleTimeout
- time a connection can stay idle before begin released
(removed from the pool) in seconds. 0 means no timeout: once
allocated, connections are never released.waitTimeout
- maximum time to wait for a connection in seconds. 0
means no timeout: waits until one connection is freed.Method Detail |
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class AbstractConnectionManager
java.lang.CloneNotSupportedException
Object.clone()
public int getMaxPoolSize()
int
value.public int getMinPoolSize()
int
value.public int getIdleTimeout()
int
value.public int getWaitTimeout()
int
value.public void initializeConnections() throws java.sql.SQLException
AbstractConnectionManager
initializeConnections
in class AbstractPoolConnectionManager
java.sql.SQLException
AbstractPoolConnectionManager.initializeConnections()
public void finalizeConnections() throws java.sql.SQLException
AbstractConnectionManager
finalizeConnections
in class AbstractPoolConnectionManager
java.sql.SQLException
AbstractConnectionManager.finalizeConnections()
public java.sql.Connection getConnection() throws UnreachableBackendException
If the current number of active connections is lower than the maximum pool size, a new connection is created. If the creation fails, this method waits for a connection to be freed.
If the maximum number of active connections is reached, this methods blocks until a connection is freed or the timeout expires.
getConnection
in class AbstractConnectionManager
null
if the timeout
has expired.
UnreachableBackendException
- if the backend must be disabledAbstractConnectionManager.getConnection()
public void releaseConnection(java.sql.Connection c)
AbstractConnectionManager
releaseConnection
in class AbstractConnectionManager
c
- the connection to release.AbstractConnectionManager.releaseConnection(Connection)
public void deleteConnection(java.sql.Connection c)
AbstractConnectionManager
deleteConnection
in class AbstractConnectionManager
c
- the connection to delete.AbstractConnectionManager.deleteConnection(Connection)
public java.lang.String getXmlImpl()
AbstractConnectionManager
getXmlImpl
in class AbstractConnectionManager
AbstractConnectionManager.getXmlImpl()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |