Class PerUserPoolDataSource
- java.lang.Object
-
- org.apache.commons.dbcp2.datasources.InstanceKeyDataSource
-
- org.apache.commons.dbcp2.datasources.PerUserPoolDataSource
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.AutoCloseable
,java.sql.Wrapper
,javax.naming.Referenceable
,javax.sql.CommonDataSource
,javax.sql.DataSource
public class PerUserPoolDataSource extends InstanceKeyDataSource
A pooling
DataSource
appropriate for deployment within J2EE environment. There are many configuration options, most of which are defined in the parent class. This datasource uses individual pools per user, and some properties can be set specifically for a given user, if the deployment environment can support initialization of mapped properties. So for example, a pool of admin or write-access Connections can be guaranteed a certain number of connections, separate from a maximum set for users with read-only connections.User passwords can be changed without re-initializing the datasource. When a
getConnection(username, password)
request is processed with a password that is different from those used to create connections in the pool associated withusername
, an attempt is made to create a new connection using the supplied password and if this succeeds, the existing pool is cleared and a new pool is created for connections using the new password.- Since:
- 2.0
- Version:
- $Id: PerUserPoolDataSource.java 1649430 2015-01-04 21:29:32Z tn $
- Author:
- John D. McNally
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PerUserPoolDataSource()
Default no-arg constructor for Serialization
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close pool(s) being maintained by this datasource.int
getNumActive()
Get the number of active connections in the default pool.int
getNumActive(java.lang.String username)
Get the number of active connections in the pool for a given user.int
getNumIdle()
Get the number of idle connections in the default pool.int
getNumIdle(java.lang.String username)
Get the number of idle connections in the pool for a given user.boolean
getPerUserBlockWhenExhausted(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool or the default if no user specific value is defined.java.lang.Boolean
getPerUserDefaultAutoCommit(java.lang.String key)
Gets the user specific default value forConnection.setAutoCommit(boolean)
for the specified user's pool.java.lang.Boolean
getPerUserDefaultReadOnly(java.lang.String key)
Gets the user specific default value forConnection.setReadOnly(boolean)
for the specified user's pool.java.lang.Integer
getPerUserDefaultTransactionIsolation(java.lang.String key)
Gets the user specific default value forConnection.setTransactionIsolation(int)
for the specified user's pool.java.lang.String
getPerUserEvictionPolicyClassName(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()
for the specified user's pool or the default if no user specific value is defined.boolean
getPerUserLifo(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getLifo()
for the specified user's pool or the default if no user specific value is defined.int
getPerUserMaxIdle(java.lang.String key)
Gets the user specific value forGenericObjectPool.getMaxIdle()
for the specified user's pool or the default if no user specific value is defined.int
getPerUserMaxTotal(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getMaxTotal()
for the specified user's pool or the default if no user specific value is defined.long
getPerUserMaxWaitMillis(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool or the default if no user specific value is defined.long
getPerUserMinEvictableIdleTimeMillis(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the specified user's pool or the default if no user specific value is defined.int
getPerUserMinIdle(java.lang.String key)
Gets the user specific value forGenericObjectPool.getMinIdle()
for the specified user's pool or the default if no user specific value is defined.int
getPerUserNumTestsPerEvictionRun(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's pool or the default if no user specific value is defined.long
getPerUserSoftMinEvictableIdleTimeMillis(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified user's pool or the default if no user specific value is defined.boolean
getPerUserTestOnBorrow(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool or the default if no user specific value is defined.boolean
getPerUserTestOnCreate(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTestOnCreate()
for the specified user's pool or the default if no user specific value is defined.boolean
getPerUserTestOnReturn(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTestOnReturn()
for the specified user's pool or the default if no user specific value is defined.boolean
getPerUserTestWhileIdle(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool or the default if no user specific value is defined.long
getPerUserTimeBetweenEvictionRunsMillis(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTimeBetweenEvictionRunsMillis()
for the specified user's pool or the default if no user specific value is defined.javax.naming.Reference
getReference()
Returns aPerUserPoolDataSource
Reference
.void
setPerUserBlockWhenExhausted(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool.void
setPerUserDefaultAutoCommit(java.lang.String username, java.lang.Boolean value)
Sets a user specific default value forConnection.setAutoCommit(boolean)
for the specified user's pool.void
setPerUserDefaultReadOnly(java.lang.String username, java.lang.Boolean value)
Sets a user specific default value forConnection.setReadOnly(boolean)
for the specified user's pool.void
setPerUserDefaultTransactionIsolation(java.lang.String username, java.lang.Integer value)
Sets a user specific default value forConnection.setTransactionIsolation(int)
for the specified user's pool.void
setPerUserEvictionPolicyClassName(java.lang.String username, java.lang.String value)
Sets a user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()
for the specified user's pool.void
setPerUserLifo(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getLifo()
for the specified user's pool.void
setPerUserMaxIdle(java.lang.String username, java.lang.Integer value)
Sets a user specific value forGenericObjectPool.getMaxIdle()
for the specified user's pool.void
setPerUserMaxTotal(java.lang.String username, java.lang.Integer value)
Sets a user specific value forBaseGenericObjectPool.getMaxTotal()
for the specified user's pool.void
setPerUserMaxWaitMillis(java.lang.String username, java.lang.Long value)
Sets a user specific value forBaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool.void
setPerUserMinEvictableIdleTimeMillis(java.lang.String username, java.lang.Long value)
Sets a user specific value forBaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the specified user's pool.void
setPerUserMinIdle(java.lang.String username, java.lang.Integer value)
Sets a user specific value forGenericObjectPool.getMinIdle()
for the specified user's pool.void
setPerUserNumTestsPerEvictionRun(java.lang.String username, java.lang.Integer value)
Sets a user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's pool.void
setPerUserSoftMinEvictableIdleTimeMillis(java.lang.String username, java.lang.Long value)
Sets a user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified user's pool.void
setPerUserTestOnBorrow(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool.void
setPerUserTestOnCreate(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getTestOnCreate()
for the specified user's pool.void
setPerUserTestOnReturn(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getTestOnReturn()
for the specified user's pool.void
setPerUserTestWhileIdle(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool.void
setPerUserTimeBetweenEvictionRunsMillis(java.lang.String username, java.lang.Long value)
Sets a user specific value for()
for the specified user's pool.-
Methods inherited from class org.apache.commons.dbcp2.datasources.InstanceKeyDataSource
getConnection, getConnection, getConnectionPoolDataSource, getDataSourceName, getDefaultBlockWhenExhausted, getDefaultEvictionPolicyClassName, getDefaultLifo, getDefaultMaxIdle, getDefaultMaxTotal, getDefaultMaxWaitMillis, getDefaultMinEvictableIdleTimeMillis, getDefaultMinIdle, getDefaultNumTestsPerEvictionRun, getDefaultSoftMinEvictableIdleTimeMillis, getDefaultTestOnBorrow, getDefaultTestOnCreate, getDefaultTestOnReturn, getDefaultTestWhileIdle, getDefaultTimeBetweenEvictionRunsMillis, getDefaultTransactionIsolation, getDescription, getJndiEnvironment, getLoginTimeout, getLogWriter, getMaxConnLifetimeMillis, getParentLogger, getValidationQuery, getValidationQueryTimeout, isDefaultAutoCommit, isDefaultReadOnly, isRollbackAfterValidation, isWrapperFor, setConnectionPoolDataSource, setDataSourceName, setDefaultAutoCommit, setDefaultBlockWhenExhausted, setDefaultEvictionPolicyClassName, setDefaultLifo, setDefaultMaxIdle, setDefaultMaxTotal, setDefaultMaxWaitMillis, setDefaultMinEvictableIdleTimeMillis, setDefaultMinIdle, setDefaultNumTestsPerEvictionRun, setDefaultReadOnly, setDefaultSoftMinEvictableIdleTimeMillis, setDefaultTestOnBorrow, setDefaultTestOnCreate, setDefaultTestOnReturn, setDefaultTestWhileIdle, setDefaultTimeBetweenEvictionRunsMillis, setDefaultTransactionIsolation, setDescription, setJndiEnvironment, setLoginTimeout, setLogWriter, setMaxConnLifetimeMillis, setRollbackAfterValidation, setValidationQuery, setValidationQueryTimeout, unwrap
-
-
-
-
Method Detail
-
close
public void close()
Close pool(s) being maintained by this datasource.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in classInstanceKeyDataSource
-
getPerUserBlockWhenExhausted
public boolean getPerUserBlockWhenExhausted(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserBlockWhenExhausted
public void setPerUserBlockWhenExhausted(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool.
-
getPerUserEvictionPolicyClassName
public java.lang.String getPerUserEvictionPolicyClassName(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserEvictionPolicyClassName
public void setPerUserEvictionPolicyClassName(java.lang.String username, java.lang.String value)
Sets a user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()
for the specified user's pool.
-
getPerUserLifo
public boolean getPerUserLifo(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getLifo()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserLifo
public void setPerUserLifo(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getLifo()
for the specified user's pool.
-
getPerUserMaxIdle
public int getPerUserMaxIdle(java.lang.String key)
Gets the user specific value forGenericObjectPool.getMaxIdle()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserMaxIdle
public void setPerUserMaxIdle(java.lang.String username, java.lang.Integer value)
Sets a user specific value forGenericObjectPool.getMaxIdle()
for the specified user's pool.
-
getPerUserMaxTotal
public int getPerUserMaxTotal(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getMaxTotal()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserMaxTotal
public void setPerUserMaxTotal(java.lang.String username, java.lang.Integer value)
Sets a user specific value forBaseGenericObjectPool.getMaxTotal()
for the specified user's pool.
-
getPerUserMaxWaitMillis
public long getPerUserMaxWaitMillis(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserMaxWaitMillis
public void setPerUserMaxWaitMillis(java.lang.String username, java.lang.Long value)
Sets a user specific value forBaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool.
-
getPerUserMinEvictableIdleTimeMillis
public long getPerUserMinEvictableIdleTimeMillis(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserMinEvictableIdleTimeMillis
public void setPerUserMinEvictableIdleTimeMillis(java.lang.String username, java.lang.Long value)
Sets a user specific value forBaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the specified user's pool.
-
getPerUserMinIdle
public int getPerUserMinIdle(java.lang.String key)
Gets the user specific value forGenericObjectPool.getMinIdle()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserMinIdle
public void setPerUserMinIdle(java.lang.String username, java.lang.Integer value)
Sets a user specific value forGenericObjectPool.getMinIdle()
for the specified user's pool.
-
getPerUserNumTestsPerEvictionRun
public int getPerUserNumTestsPerEvictionRun(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserNumTestsPerEvictionRun
public void setPerUserNumTestsPerEvictionRun(java.lang.String username, java.lang.Integer value)
Sets a user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's pool.
-
getPerUserSoftMinEvictableIdleTimeMillis
public long getPerUserSoftMinEvictableIdleTimeMillis(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserSoftMinEvictableIdleTimeMillis
public void setPerUserSoftMinEvictableIdleTimeMillis(java.lang.String username, java.lang.Long value)
Sets a user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified user's pool.
-
getPerUserTestOnCreate
public boolean getPerUserTestOnCreate(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTestOnCreate()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserTestOnCreate
public void setPerUserTestOnCreate(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getTestOnCreate()
for the specified user's pool.
-
getPerUserTestOnBorrow
public boolean getPerUserTestOnBorrow(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserTestOnBorrow
public void setPerUserTestOnBorrow(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool.
-
getPerUserTestOnReturn
public boolean getPerUserTestOnReturn(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTestOnReturn()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserTestOnReturn
public void setPerUserTestOnReturn(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getTestOnReturn()
for the specified user's pool.
-
getPerUserTestWhileIdle
public boolean getPerUserTestWhileIdle(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserTestWhileIdle
public void setPerUserTestWhileIdle(java.lang.String username, java.lang.Boolean value)
Sets a user specific value forBaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool.
-
getPerUserTimeBetweenEvictionRunsMillis
public long getPerUserTimeBetweenEvictionRunsMillis(java.lang.String key)
Gets the user specific value forBaseGenericObjectPool.getTimeBetweenEvictionRunsMillis()
for the specified user's pool or the default if no user specific value is defined.
-
setPerUserTimeBetweenEvictionRunsMillis
public void setPerUserTimeBetweenEvictionRunsMillis(java.lang.String username, java.lang.Long value)
Sets a user specific value for()
for the specified user's pool.
-
getPerUserDefaultAutoCommit
public java.lang.Boolean getPerUserDefaultAutoCommit(java.lang.String key)
Gets the user specific default value forConnection.setAutoCommit(boolean)
for the specified user's pool.
-
setPerUserDefaultAutoCommit
public void setPerUserDefaultAutoCommit(java.lang.String username, java.lang.Boolean value)
Sets a user specific default value forConnection.setAutoCommit(boolean)
for the specified user's pool.
-
getPerUserDefaultReadOnly
public java.lang.Boolean getPerUserDefaultReadOnly(java.lang.String key)
Gets the user specific default value forConnection.setReadOnly(boolean)
for the specified user's pool.
-
setPerUserDefaultReadOnly
public void setPerUserDefaultReadOnly(java.lang.String username, java.lang.Boolean value)
Sets a user specific default value forConnection.setReadOnly(boolean)
for the specified user's pool.
-
getPerUserDefaultTransactionIsolation
public java.lang.Integer getPerUserDefaultTransactionIsolation(java.lang.String key)
Gets the user specific default value forConnection.setTransactionIsolation(int)
for the specified user's pool.
-
setPerUserDefaultTransactionIsolation
public void setPerUserDefaultTransactionIsolation(java.lang.String username, java.lang.Integer value)
Sets a user specific default value forConnection.setTransactionIsolation(int)
for the specified user's pool.
-
getNumActive
public int getNumActive()
Get the number of active connections in the default pool.
-
getNumActive
public int getNumActive(java.lang.String username)
Get the number of active connections in the pool for a given user.
-
getNumIdle
public int getNumIdle()
Get the number of idle connections in the default pool.
-
getNumIdle
public int getNumIdle(java.lang.String username)
Get the number of idle connections in the pool for a given user.
-
getReference
public javax.naming.Reference getReference() throws javax.naming.NamingException
Returns aPerUserPoolDataSource
Reference
.- Throws:
javax.naming.NamingException
-
-