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 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.
UNKNOWN_TRANSACTIONISOLATION
Constructor and Description |
---|
PerUserPoolDataSource()
Default no-arg constructor for Serialization
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close pool(s) being maintained by this datasource.
|
protected org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionManager |
getConnectionManager(org.apache.tomcat.dbcp.dbcp2.datasources.UserPassKey upkey) |
int |
getNumActive() |
int |
getNumActive(String username) |
int |
getNumIdle() |
int |
getNumIdle(String username) |
boolean |
getPerUserBlockWhenExhausted(String key)
Gets the user specific value for
BaseGenericObjectPool.getBlockWhenExhausted() for the
specified user's pool or the default if no user specific value is defined. |
Boolean |
getPerUserDefaultAutoCommit(String key)
Gets the user specific default value for
Connection.setAutoCommit(boolean) for the specified user's pool. |
Boolean |
getPerUserDefaultReadOnly(String key)
Gets the user specific default value for
Connection.setReadOnly(boolean) for the specified user's pool. |
Integer |
getPerUserDefaultTransactionIsolation(String key)
Gets the user specific default value for
Connection.setTransactionIsolation(int) for the specified user's pool. |
String |
getPerUserEvictionPolicyClassName(String key)
Gets the user specific value for
BaseGenericObjectPool.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 for
BaseGenericObjectPool.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 for
GenericObjectPool.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 for
BaseGenericObjectPool.getMaxTotal() for the
specified user's pool or the default if no user specific value is defined. |
long |
getPerUserMaxWaitMillis(String key)
Gets the user specific value for
BaseGenericObjectPool.getMaxWaitMillis() for the
specified user's pool or the default if no user specific value is defined. |
long |
getPerUserMinEvictableIdleTimeMillis(String key)
Gets the user specific value for
BaseGenericObjectPool.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 for
GenericObjectPool.getMinIdle() for the
specified user's pool or the default if no user specific value is defined. |
int |
getPerUserNumTestsPerEvictionRun(String key)
Gets the user specific value for
BaseGenericObjectPool.getNumTestsPerEvictionRun() for the
specified user's pool or the default if no user specific value is defined. |
long |
getPerUserSoftMinEvictableIdleTimeMillis(String key)
Gets the user specific value for
BaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis() for the
specified user's pool or the default if no user specific value is defined. |
boolean |
getPerUserTestOnBorrow(String key)
Gets the user specific value for
BaseGenericObjectPool.getTestOnBorrow() for the
specified user's pool or the default if no user specific value is defined. |
boolean |
getPerUserTestOnCreate(String key)
Gets the user specific value for
BaseGenericObjectPool.getTestOnCreate() for the
specified user's pool or the default if no user specific value is defined. |
boolean |
getPerUserTestOnReturn(String key)
Gets the user specific value for
BaseGenericObjectPool.getTestOnReturn() for the
specified user's pool or the default if no user specific value is defined. |
boolean |
getPerUserTestWhileIdle(String key)
Gets the user specific value for
BaseGenericObjectPool.getTestWhileIdle() for the
specified user's pool or the default if no user specific value is defined. |
long |
getPerUserTimeBetweenEvictionRunsMillis(String key)
Gets the user specific value for
BaseGenericObjectPool.getTimeBetweenEvictionRunsMillis() for the
specified user's pool or the default if no user specific value is defined. |
protected org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionAndInfo |
getPooledConnectionAndInfo(String username,
String password) |
Reference |
getReference() |
void |
setPerUserBlockWhenExhausted(String username,
Boolean value)
Sets a user specific value for
BaseGenericObjectPool.getBlockWhenExhausted() for the specified
user's pool. |
void |
setPerUserDefaultAutoCommit(String username,
Boolean value)
Sets a user specific default value for
Connection.setAutoCommit(boolean) for the specified user's pool. |
void |
setPerUserDefaultReadOnly(String username,
Boolean value)
Sets a user specific default value for
Connection.setReadOnly(boolean) for the specified user's pool. |
void |
setPerUserDefaultTransactionIsolation(String username,
Integer value)
Sets a user specific default value for
Connection.setTransactionIsolation(int) for the specified user's pool. |
void |
setPerUserEvictionPolicyClassName(String username,
String value)
Sets a user specific value for
BaseGenericObjectPool.getEvictionPolicyClassName() for the specified
user's pool. |
void |
setPerUserLifo(String username,
Boolean value)
Sets a user specific value for
BaseGenericObjectPool.getLifo() for the specified
user's pool. |
void |
setPerUserMaxIdle(String username,
Integer value)
Sets a user specific value for
GenericObjectPool.getMaxIdle() for the specified
user's pool. |
void |
setPerUserMaxTotal(String username,
Integer value)
Sets a user specific value for
BaseGenericObjectPool.getMaxTotal() for the specified
user's pool. |
void |
setPerUserMaxWaitMillis(String username,
Long value)
Sets a user specific value for
BaseGenericObjectPool.getMaxWaitMillis() for the specified
user's pool. |
void |
setPerUserMinEvictableIdleTimeMillis(String username,
Long value)
Sets a user specific value for
BaseGenericObjectPool.getMinEvictableIdleTimeMillis() for the
specified user's pool. |
void |
setPerUserMinIdle(String username,
Integer value)
Sets a user specific value for
GenericObjectPool.getMinIdle() for the specified
user's pool. |
void |
setPerUserNumTestsPerEvictionRun(String username,
Integer value)
Sets a user specific value for
BaseGenericObjectPool.getNumTestsPerEvictionRun() for the specified
user's pool. |
void |
setPerUserSoftMinEvictableIdleTimeMillis(String username,
Long value)
Sets a user specific value for
BaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis() for the
specified user's pool. |
void |
setPerUserTestOnBorrow(String username,
Boolean value)
Sets a user specific value for
BaseGenericObjectPool.getTestOnBorrow() for the specified
user's pool. |
void |
setPerUserTestOnCreate(String username,
Boolean value)
Sets a user specific value for
BaseGenericObjectPool.getTestOnCreate() for the specified
user's pool. |
void |
setPerUserTestOnReturn(String username,
Boolean value)
Sets a user specific value for
BaseGenericObjectPool.getTestOnReturn() for the specified
user's pool. |
void |
setPerUserTestWhileIdle(String username,
Boolean value)
Sets a user specific value for
BaseGenericObjectPool.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. |
protected void |
setupDefaults(Connection con,
String username) |
assertInitializationAllowed, getConnection, getConnection, getConnectionPoolDataSource, getDataSourceName, getDefaultBlockWhenExhausted, getDefaultEvictionPolicyClassName, getDefaultLifo, getDefaultMaxIdle, getDefaultMaxTotal, getDefaultMaxWaitMillis, getDefaultMinEvictableIdleTimeMillis, getDefaultMinIdle, getDefaultNumTestsPerEvictionRun, getDefaultSoftMinEvictableIdleTimeMillis, getDefaultTestOnBorrow, getDefaultTestOnCreate, getDefaultTestOnReturn, getDefaultTestWhileIdle, getDefaultTimeBetweenEvictionRunsMillis, getDefaultTransactionIsolation, getDescription, getInstanceKey, 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, testCPDS, unwrap
public PerUserPoolDataSource()
public void close()
close
in interface AutoCloseable
close
in class InstanceKeyDataSource
public boolean getPerUserBlockWhenExhausted(String key)
BaseGenericObjectPool.getBlockWhenExhausted()
for the
specified user's pool or the default if no user specific value is defined.key
- The usertrue
to blockpublic void setPerUserBlockWhenExhausted(String username, Boolean value)
BaseGenericObjectPool.getBlockWhenExhausted()
for the specified
user's pool.username
- The uservalue
- The valuepublic String getPerUserEvictionPolicyClassName(String key)
BaseGenericObjectPool.getEvictionPolicyClassName()
for the
specified user's pool or the default if no user specific value is defined.key
- The userpublic void setPerUserEvictionPolicyClassName(String username, String value)
BaseGenericObjectPool.getEvictionPolicyClassName()
for the specified
user's pool.username
- The uservalue
- The valuepublic boolean getPerUserLifo(String key)
BaseGenericObjectPool.getLifo()
for
the specified user's pool or the default if no user specific value is
defined.key
- The usertrue
to use LIFOpublic void setPerUserLifo(String username, Boolean value)
BaseGenericObjectPool.getLifo()
for the specified
user's pool.username
- The uservalue
- The valuepublic int getPerUserMaxIdle(String key)
GenericObjectPool.getMaxIdle()
for the
specified user's pool or the default if no user specific value is defined.key
- The userpublic void setPerUserMaxIdle(String username, Integer value)
GenericObjectPool.getMaxIdle()
for the specified
user's pool.username
- The uservalue
- The valuepublic int getPerUserMaxTotal(String key)
BaseGenericObjectPool.getMaxTotal()
for the
specified user's pool or the default if no user specific value is defined.key
- The userpublic void setPerUserMaxTotal(String username, Integer value)
BaseGenericObjectPool.getMaxTotal()
for the specified
user's pool.username
- The uservalue
- The valuepublic long getPerUserMaxWaitMillis(String key)
BaseGenericObjectPool.getMaxWaitMillis()
for the
specified user's pool or the default if no user specific value is defined.key
- The userpublic void setPerUserMaxWaitMillis(String username, Long value)
BaseGenericObjectPool.getMaxWaitMillis()
for the specified
user's pool.username
- The uservalue
- The valuepublic long getPerUserMinEvictableIdleTimeMillis(String key)
BaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the
specified user's pool or the default if no user specific value is defined.key
- The userpublic void setPerUserMinEvictableIdleTimeMillis(String username, Long value)
BaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the
specified user's pool.username
- The uservalue
- The valuepublic int getPerUserMinIdle(String key)
GenericObjectPool.getMinIdle()
for the
specified user's pool or the default if no user specific value is defined.key
- The userpublic void setPerUserMinIdle(String username, Integer value)
GenericObjectPool.getMinIdle()
for the specified
user's pool.username
- The uservalue
- The valuepublic int getPerUserNumTestsPerEvictionRun(String key)
BaseGenericObjectPool.getNumTestsPerEvictionRun()
for the
specified user's pool or the default if no user specific value is defined.key
- The userpublic void setPerUserNumTestsPerEvictionRun(String username, Integer value)
BaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified
user's pool.username
- The uservalue
- The valuepublic long getPerUserSoftMinEvictableIdleTimeMillis(String key)
BaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the
specified user's pool or the default if no user specific value is defined.key
- The userpublic void setPerUserSoftMinEvictableIdleTimeMillis(String username, Long value)
BaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the
specified user's pool.username
- The uservalue
- The valuepublic boolean getPerUserTestOnCreate(String key)
BaseGenericObjectPool.getTestOnCreate()
for the
specified user's pool or the default if no user specific value is defined.key
- The usertrue
to test on createpublic void setPerUserTestOnCreate(String username, Boolean value)
BaseGenericObjectPool.getTestOnCreate()
for the specified
user's pool.username
- The uservalue
- The valuepublic boolean getPerUserTestOnBorrow(String key)
BaseGenericObjectPool.getTestOnBorrow()
for the
specified user's pool or the default if no user specific value is defined.key
- The usertrue
to test on borrowpublic void setPerUserTestOnBorrow(String username, Boolean value)
BaseGenericObjectPool.getTestOnBorrow()
for the specified
user's pool.username
- The uservalue
- The valuepublic boolean getPerUserTestOnReturn(String key)
BaseGenericObjectPool.getTestOnReturn()
for the
specified user's pool or the default if no user specific value is defined.key
- The usertrue
to test on returnpublic void setPerUserTestOnReturn(String username, Boolean value)
BaseGenericObjectPool.getTestOnReturn()
for the specified
user's pool.username
- The uservalue
- The valuepublic boolean getPerUserTestWhileIdle(String key)
BaseGenericObjectPool.getTestWhileIdle()
for the
specified user's pool or the default if no user specific value is defined.key
- The usertrue
to test while idlepublic void setPerUserTestWhileIdle(String username, Boolean value)
BaseGenericObjectPool.getTestWhileIdle()
for the specified
user's pool.username
- The uservalue
- The valuepublic long getPerUserTimeBetweenEvictionRunsMillis(String key)
BaseGenericObjectPool.getTimeBetweenEvictionRunsMillis()
for the
specified user's pool or the default if no user specific value is defined.key
- The userpublic void setPerUserTimeBetweenEvictionRunsMillis(String username, Long value)
()
for the specified
user's pool.username
- The uservalue
- The valuepublic Boolean getPerUserDefaultAutoCommit(String key)
Connection.setAutoCommit(boolean)
for the specified user's pool.key
- The usertrue
to commit automaticallypublic void setPerUserDefaultAutoCommit(String username, Boolean value)
Connection.setAutoCommit(boolean)
for the specified user's pool.username
- The uservalue
- The valuepublic Boolean getPerUserDefaultReadOnly(String key)
Connection.setReadOnly(boolean)
for the specified user's pool.key
- The usertrue
is read only by defaultpublic void setPerUserDefaultReadOnly(String username, Boolean value)
Connection.setReadOnly(boolean)
for the specified user's pool.username
- The uservalue
- The valuepublic Integer getPerUserDefaultTransactionIsolation(String key)
Connection.setTransactionIsolation(int)
for the specified user's pool.key
- The userpublic void setPerUserDefaultTransactionIsolation(String username, Integer value)
Connection.setTransactionIsolation(int)
for the specified user's pool.username
- The uservalue
- The valuepublic int getNumActive()
public int getNumActive(String username)
username
- The userpublic int getNumIdle()
public int getNumIdle(String username)
username
- The userprotected org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionAndInfo getPooledConnectionAndInfo(String username, String password) throws SQLException
getPooledConnectionAndInfo
in class InstanceKeyDataSource
SQLException
protected void setupDefaults(Connection con, String username) throws SQLException
setupDefaults
in class InstanceKeyDataSource
SQLException
protected org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionManager getConnectionManager(org.apache.tomcat.dbcp.dbcp2.datasources.UserPassKey upkey)
getConnectionManager
in class InstanceKeyDataSource
public Reference getReference() throws NamingException
PerUserPoolDataSource
Reference
.NamingException
- Should not happenCopyright © 2000-2016 Apache Software Foundation. All Rights Reserved.