|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.conn.PoolManager
public class PoolManager
PoolManager is a Cayenne implementation of a pooling DataSource.
Field Summary | |
---|---|
protected java.lang.String |
dataSourceUrl
|
protected java.lang.String |
jdbcDriver
|
static int |
MAX_QUEUE_WAIT
Defines a maximum time in milliseconds that a connection request could wait in the connection queue. |
protected int |
maxConnections
|
protected int |
minConnections
|
protected java.lang.String |
password
|
protected javax.sql.ConnectionPoolDataSource |
poolDataSource
|
protected java.util.List<javax.sql.PooledConnection> |
unusedPool
|
protected java.util.List<javax.sql.PooledConnection> |
usedPool
|
protected java.lang.String |
userName
|
Constructor Summary | |
---|---|
PoolManager(javax.sql.ConnectionPoolDataSource poolDataSource,
int minCons,
int maxCons,
java.lang.String userName,
java.lang.String password)
Creates new PoolManager with the specified policy for connection pooling and a ConnectionPoolDataSource object. |
|
PoolManager(java.lang.String jdbcDriver,
java.lang.String dataSourceUrl,
int minCons,
int maxCons,
java.lang.String userName,
java.lang.String password)
Creates new PoolManager using org.apache.cayenne.conn.PoolDataSource for an underlying ConnectionPoolDataSource. |
|
PoolManager(java.lang.String jdbcDriver,
java.lang.String dataSourceUrl,
int minCons,
int maxCons,
java.lang.String userName,
java.lang.String password,
JdbcEventLogger logger)
|
Method Summary | ||
---|---|---|
void |
beforeScopeEnd()
An implementation of ScopeEventListener that simply calls
shutdown() . |
|
protected boolean |
canGrowPool()
|
|
void |
connectionClosed(javax.sql.ConnectionEvent event)
Returns closed connection to the pool. |
|
void |
connectionErrorOccurred(javax.sql.ConnectionEvent event)
Removes connection with an error from the pool. |
|
void |
dispose()
Deprecated. since 3.1 replaced with shutdown() method for naming
consistency. |
|
protected void |
disposeOfMaintenanceThread()
|
|
java.sql.Connection |
getConnection()
Returns connection from the pool using internal values of user name and password. |
|
java.sql.Connection |
getConnection(java.lang.String userName,
java.lang.String password)
Returns connection from the pool. |
|
int |
getCurrentlyInUse()
Returns the number of connections obtained via this DataSource that are currently in use by the DataSource clients. |
|
int |
getCurrentlyUnused()
Returns the number of connections maintained in the pool that are currently not used by any clients and are available immediately via getConnection
method. |
|
java.lang.String |
getDataSourceUrl()
Returns a database URL used to initialize this pool. |
|
java.lang.String |
getJdbcDriver()
Returns a name of a JDBC driver used to initialize this pool. |
|
int |
getLoginTimeout()
|
|
java.io.PrintWriter |
getLogWriter()
|
|
int |
getMaxConnections()
Returns maximum number of connections this pool can keep. |
|
int |
getMinConnections()
Returns the absolute minimum number of connections allowed in this pool at any moment in time. |
|
java.util.logging.Logger |
getParentLogger()
|
|
java.lang.String |
getPassword()
Returns a data source password used to initialize this pool. |
|
int |
getPoolSize()
Returns current number of connections. |
|
java.lang.String |
getUserName()
Returns a data source user name used to initialize this pool. |
|
protected int |
growPool(int addConnections,
java.lang.String userName,
java.lang.String password)
Increases connection pool by the specified number of connections. |
|
protected void |
init(javax.sql.ConnectionPoolDataSource poolDataSource,
int minCons,
int maxCons,
java.lang.String userName,
java.lang.String password)
Initializes pool. |
|
boolean |
isWrapperFor(java.lang.Class<?> iface)
|
|
protected javax.sql.PooledConnection |
newPooledConnection(java.lang.String userName,
java.lang.String password)
Creates and returns new PooledConnection object, adding itself as a listener for connection events. |
|
void |
setLoginTimeout(int seconds)
|
|
void |
setLogWriter(java.io.PrintWriter out)
|
|
void |
setMaxConnections(int maxConnections)
|
|
void |
setMinConnections(int minConnections)
|
|
protected void |
shrinkPool(int closeConnections)
|
|
void |
shutdown()
Closes all existing connections, drains the pool and stops the maintenance thread. |
|
protected void |
startMaintenanceThread()
|
|
|
unwrap(java.lang.Class<T> iface)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_QUEUE_WAIT
protected javax.sql.ConnectionPoolDataSource poolDataSource
protected int minConnections
protected int maxConnections
protected java.lang.String dataSourceUrl
protected java.lang.String jdbcDriver
protected java.lang.String password
protected java.lang.String userName
protected java.util.List<javax.sql.PooledConnection> unusedPool
protected java.util.List<javax.sql.PooledConnection> usedPool
Constructor Detail |
---|
public PoolManager(java.lang.String jdbcDriver, java.lang.String dataSourceUrl, int minCons, int maxCons, java.lang.String userName, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
public PoolManager(java.lang.String jdbcDriver, java.lang.String dataSourceUrl, int minCons, int maxCons, java.lang.String userName, java.lang.String password, JdbcEventLogger logger) throws java.sql.SQLException
java.sql.SQLException
public PoolManager(javax.sql.ConnectionPoolDataSource poolDataSource, int minCons, int maxCons, java.lang.String userName, java.lang.String password) throws java.sql.SQLException
poolDataSource
- data source for pooled connectionsminCons
- Non-negative integer that specifies a minimum number of open
connections to keep in the pool at all timesmaxCons
- Non-negative integer that specifies maximum number of simultaneuosly
open connections
java.sql.SQLException
- if pool manager can not be created.Method Detail |
---|
protected void init(javax.sql.ConnectionPoolDataSource poolDataSource, int minCons, int maxCons, java.lang.String userName, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
protected void startMaintenanceThread()
protected javax.sql.PooledConnection newPooledConnection(java.lang.String userName, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
public void dispose() throws java.sql.SQLException
shutdown()
method for naming
consistency.
java.sql.SQLException
public void shutdown() throws java.sql.SQLException
java.sql.SQLException
public void beforeScopeEnd()
ScopeEventListener
that simply calls
shutdown()
.
beforeScopeEnd
in interface ScopeEventListener
protected void disposeOfMaintenanceThread()
protected boolean canGrowPool()
protected int growPool(int addConnections, java.lang.String userName, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
- if an error happens when creating a new connection.protected void shrinkPool(int closeConnections)
public int getMaxConnections()
public void setMaxConnections(int maxConnections)
public int getMinConnections()
public void setMinConnections(int minConnections)
public java.lang.String getDataSourceUrl()
public java.lang.String getJdbcDriver()
public java.lang.String getPassword()
public java.lang.String getUserName()
public int getPoolSize()
public int getCurrentlyInUse()
public int getCurrentlyUnused()
getConnection
method.
public java.sql.Connection getConnection() throws java.sql.SQLException
ds.getConnection(ds.getUserName(), ds.getPassword())
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String userName, java.lang.String password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public int getLoginTimeout() throws java.sql.SQLException
getLoginTimeout
in interface javax.sql.DataSource
java.sql.SQLException
public void setLoginTimeout(int seconds) throws java.sql.SQLException
setLoginTimeout
in interface javax.sql.DataSource
java.sql.SQLException
public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
getLogWriter
in interface javax.sql.DataSource
java.sql.SQLException
public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
setLogWriter
in interface javax.sql.DataSource
java.sql.SQLException
public void connectionClosed(javax.sql.ConnectionEvent event)
connectionClosed
in interface javax.sql.ConnectionEventListener
public void connectionErrorOccurred(javax.sql.ConnectionEvent event)
connectionErrorOccurred
in interface javax.sql.ConnectionEventListener
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
java.sql.SQLException
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException
SQLFeatureNotSupportedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |