Class PerUserPoolDataSource
- All Implemented Interfaces:
Serializable
,AutoCloseable
,Wrapper
,Referenceable
,CommonDataSource
,DataSource
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 with username
, 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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close pool(s) being maintained by this datasource.int
Get the number of active connections in the default pool.int
getNumActive
(String username) Get the number of active connections in the pool for a given user.int
Get the number of idle connections in the default pool.int
getNumIdle
(String username) Get the number of idle connections in the pool for a given user.boolean
Gets the user specific value forBaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool or the default if no user specific value is defined.Gets the user specific default value forConnection.setAutoCommit(boolean)
for the specified user's pool.Gets the user specific default value forConnection.setReadOnly(boolean)
for the specified user's pool.Gets the user specific default value forConnection.setTransactionIsolation(int)
for the specified user's pool.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
(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
(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
(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
Gets the user specific value forBaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool or the default if no user specific value is defined.long
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
(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
Gets the user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's pool or the default if no user specific value is defined.long
Gets the user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified user's pool or the default if no user specific value is defined.boolean
Gets the user specific value forBaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool or the default if no user specific value is defined.boolean
Gets the user specific value forBaseGenericObjectPool.getTestOnCreate()
for the specified user's pool or the default if no user specific value is defined.boolean
Gets the user specific value forBaseGenericObjectPool.getTestOnReturn()
for the specified user's pool or the default if no user specific value is defined.boolean
Gets the user specific value forBaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool or the default if no user specific value is defined.long
Gets the user specific value forBaseGenericObjectPool.getTimeBetweenEvictionRunsMillis()
for the specified user's pool or the default if no user specific value is defined.Returns aPerUserPoolDataSource
Reference
.void
setPerUserBlockWhenExhausted
(String username, Boolean value) Sets a user specific value forBaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool.void
setPerUserDefaultAutoCommit
(String username, Boolean value) Sets a user specific default value forConnection.setAutoCommit(boolean)
for the specified user's pool.void
setPerUserDefaultReadOnly
(String username, Boolean value) Sets a user specific default value forConnection.setReadOnly(boolean)
for the specified user's pool.void
setPerUserDefaultTransactionIsolation
(String username, Integer value) Sets a user specific default value forConnection.setTransactionIsolation(int)
for the specified user's pool.void
setPerUserEvictionPolicyClassName
(String username, String value) Sets a user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()
for the specified user's pool.void
setPerUserLifo
(String username, Boolean value) Sets a user specific value forBaseGenericObjectPool.getLifo()
for the specified user's pool.void
setPerUserMaxIdle
(String username, Integer value) Sets a user specific value forGenericObjectPool.getMaxIdle()
for the specified user's pool.void
setPerUserMaxTotal
(String username, Integer value) Sets a user specific value forBaseGenericObjectPool.getMaxTotal()
for the specified user's pool.void
setPerUserMaxWaitMillis
(String username, Long value) Sets a user specific value forBaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool.void
setPerUserMinEvictableIdleTimeMillis
(String username, Long value) Sets a user specific value forBaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the specified user's pool.void
setPerUserMinIdle
(String username, Integer value) Sets a user specific value forGenericObjectPool.getMinIdle()
for the specified user's pool.void
setPerUserNumTestsPerEvictionRun
(String username, Integer value) Sets a user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's pool.void
setPerUserSoftMinEvictableIdleTimeMillis
(String username, Long value) Sets a user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified user's pool.void
setPerUserTestOnBorrow
(String username, Boolean value) Sets a user specific value forBaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool.void
setPerUserTestOnCreate
(String username, Boolean value) Sets a user specific value forBaseGenericObjectPool.getTestOnCreate()
for the specified user's pool.void
setPerUserTestOnReturn
(String username, Boolean value) Sets a user specific value forBaseGenericObjectPool.getTestOnReturn()
for the specified user's pool.void
setPerUserTestWhileIdle
(String username, Boolean value) Sets a user specific value forBaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool.void
setPerUserTimeBetweenEvictionRunsMillis
(String username, 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
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Constructor Details
-
PerUserPoolDataSource
public PerUserPoolDataSource()Default no-arg constructor for Serialization
-
-
Method Details
-
close
public void close()Close pool(s) being maintained by this datasource.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in classInstanceKeyDataSource
-
getPerUserBlockWhenExhausted
Gets the user specific value forBaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserBlockWhenExhausted
Sets a user specific value forBaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool. -
getPerUserEvictionPolicyClassName
Gets the user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserEvictionPolicyClassName
Sets a user specific value forBaseGenericObjectPool.getEvictionPolicyClassName()
for the specified user's pool. -
getPerUserLifo
Gets the user specific value forBaseGenericObjectPool.getLifo()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserLifo
Sets a user specific value forBaseGenericObjectPool.getLifo()
for the specified user's pool. -
getPerUserMaxIdle
Gets the user specific value forGenericObjectPool.getMaxIdle()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserMaxIdle
Sets a user specific value forGenericObjectPool.getMaxIdle()
for the specified user's pool. -
getPerUserMaxTotal
Gets the user specific value forBaseGenericObjectPool.getMaxTotal()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserMaxTotal
Sets a user specific value forBaseGenericObjectPool.getMaxTotal()
for the specified user's pool. -
getPerUserMaxWaitMillis
Gets the user specific value forBaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserMaxWaitMillis
Sets a user specific value forBaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool. -
getPerUserMinEvictableIdleTimeMillis
Gets the user specific value forBaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserMinEvictableIdleTimeMillis
Sets a user specific value forBaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the specified user's pool. -
getPerUserMinIdle
Gets the user specific value forGenericObjectPool.getMinIdle()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserMinIdle
Sets a user specific value forGenericObjectPool.getMinIdle()
for the specified user's pool. -
getPerUserNumTestsPerEvictionRun
Gets the user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserNumTestsPerEvictionRun
Sets a user specific value forBaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's pool. -
getPerUserSoftMinEvictableIdleTimeMillis
Gets the user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserSoftMinEvictableIdleTimeMillis
Sets a user specific value forBaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified user's pool. -
getPerUserTestOnCreate
Gets the user specific value forBaseGenericObjectPool.getTestOnCreate()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserTestOnCreate
Sets a user specific value forBaseGenericObjectPool.getTestOnCreate()
for the specified user's pool. -
getPerUserTestOnBorrow
Gets the user specific value forBaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserTestOnBorrow
Sets a user specific value forBaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool. -
getPerUserTestOnReturn
Gets the user specific value forBaseGenericObjectPool.getTestOnReturn()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserTestOnReturn
Sets a user specific value forBaseGenericObjectPool.getTestOnReturn()
for the specified user's pool. -
getPerUserTestWhileIdle
Gets the user specific value forBaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserTestWhileIdle
Sets a user specific value forBaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool. -
getPerUserTimeBetweenEvictionRunsMillis
Gets the user specific value forBaseGenericObjectPool.getTimeBetweenEvictionRunsMillis()
for the specified user's pool or the default if no user specific value is defined. -
setPerUserTimeBetweenEvictionRunsMillis
Sets a user specific value for()
for the specified user's pool. -
getPerUserDefaultAutoCommit
Gets the user specific default value forConnection.setAutoCommit(boolean)
for the specified user's pool. -
setPerUserDefaultAutoCommit
Sets a user specific default value forConnection.setAutoCommit(boolean)
for the specified user's pool. -
getPerUserDefaultReadOnly
Gets the user specific default value forConnection.setReadOnly(boolean)
for the specified user's pool. -
setPerUserDefaultReadOnly
Sets a user specific default value forConnection.setReadOnly(boolean)
for the specified user's pool. -
getPerUserDefaultTransactionIsolation
Gets the user specific default value forConnection.setTransactionIsolation(int)
for the specified user's pool. -
setPerUserDefaultTransactionIsolation
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
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
Get the number of idle connections in the pool for a given user. -
getReference
Returns aPerUserPoolDataSource
Reference
.- Throws:
NamingException
-