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 |
clear()
Clears pool(s) maintained by this data source.
|
void |
close()
Closes pool(s) maintained by this data source.
|
protected org.apache.commons.dbcp2.datasources.PooledConnectionManager |
getConnectionManager(org.apache.commons.dbcp2.datasources.UserPassKey upKey) |
int |
getNumActive()
Gets the number of active connections in the default pool.
|
int |
getNumActive(String userName)
Gets the number of active connections in the pool for a given user.
|
int |
getNumIdle()
Gets the number of idle connections in the default pool.
|
int |
getNumIdle(String userName)
Gets the number of idle connections in the pool for a given user.
|
boolean |
getPerUserBlockWhenExhausted(String userName)
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 userName)
Gets the user specific default value for
Connection.setAutoCommit(boolean) for the specified user's pool. |
Boolean |
getPerUserDefaultReadOnly(String userName)
Gets the user specific default value for
Connection.setReadOnly(boolean) for the specified user's pool. |
Integer |
getPerUserDefaultTransactionIsolation(String userName)
Gets the user specific default value for
Connection.setTransactionIsolation(int) for the specified user's
pool. |
String |
getPerUserEvictionPolicyClassName(String userName)
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 userName)
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 userName)
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 userName)
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 userName)
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 userName)
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 userName)
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 userName)
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 userName)
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 userName)
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 userName)
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 userName)
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 userName)
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 userName)
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.commons.dbcp2.datasources.PooledConnectionAndInfo |
getPooledConnectionAndInfo(String userName,
String password) |
Reference |
getReference()
Returns a
PerUserPoolDataSource Reference . |
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, toString, toStringFields, unwrap
public PerUserPoolDataSource()
public void clear()
ObjectPool.clear()
public void close()
close
in interface AutoCloseable
close
in class InstanceKeyDataSource
ObjectPool.close()
protected org.apache.commons.dbcp2.datasources.PooledConnectionManager getConnectionManager(org.apache.commons.dbcp2.datasources.UserPassKey upKey)
getConnectionManager
in class InstanceKeyDataSource
public int getNumActive()
public int getNumActive(String userName)
userName
- The user name key.public int getNumIdle()
public int getNumIdle(String userName)
userName
- The user name key.public boolean getPerUserBlockWhenExhausted(String userName)
BaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool
or the default if no user specific value is defined.userName
- The user name key.public Boolean getPerUserDefaultAutoCommit(String userName)
Connection.setAutoCommit(boolean)
for the specified user's pool.userName
- The user name key.public Boolean getPerUserDefaultReadOnly(String userName)
Connection.setReadOnly(boolean)
for the specified user's pool.userName
- The user name key.public Integer getPerUserDefaultTransactionIsolation(String userName)
Connection.setTransactionIsolation(int)
for the specified user's
pool.userName
- The user name key.public String getPerUserEvictionPolicyClassName(String userName)
BaseGenericObjectPool.getEvictionPolicyClassName()
for the specified user's
pool or the default if no user specific value is defined.userName
- The user name key.public boolean getPerUserLifo(String userName)
BaseGenericObjectPool.getLifo()
for the specified user's pool or the default
if no user specific value is defined.userName
- The user name key.public int getPerUserMaxIdle(String userName)
GenericObjectPool.getMaxIdle()
for the specified user's pool or the
default if no user specific value is defined.userName
- The user name key.public int getPerUserMaxTotal(String userName)
BaseGenericObjectPool.getMaxTotal()
for the specified user's pool or the
default if no user specific value is defined.userName
- The user name key.public long getPerUserMaxWaitMillis(String userName)
BaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool or
the default if no user specific value is defined.userName
- The user name key.public long getPerUserMinEvictableIdleTimeMillis(String userName)
BaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the specified
user's pool or the default if no user specific value is defined.userName
- The user name key.public int getPerUserMinIdle(String userName)
GenericObjectPool.getMinIdle()
for the specified user's pool or the
default if no user specific value is defined.userName
- The user name key.public int getPerUserNumTestsPerEvictionRun(String userName)
BaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's
pool or the default if no user specific value is defined.userName
- The user name key.public long getPerUserSoftMinEvictableIdleTimeMillis(String userName)
BaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified
user's pool or the default if no user specific value is defined.userName
- The user name key.public boolean getPerUserTestOnBorrow(String userName)
BaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool or the
default if no user specific value is defined.userName
- The user name key.public boolean getPerUserTestOnCreate(String userName)
BaseGenericObjectPool.getTestOnCreate()
for the specified user's pool or the
default if no user specific value is defined.userName
- The user name key.public boolean getPerUserTestOnReturn(String userName)
BaseGenericObjectPool.getTestOnReturn()
for the specified user's pool or the
default if no user specific value is defined.userName
- The user name key.public boolean getPerUserTestWhileIdle(String userName)
BaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool or
the default if no user specific value is defined.userName
- The user name key.public long getPerUserTimeBetweenEvictionRunsMillis(String userName)
BaseGenericObjectPool.getTimeBetweenEvictionRunsMillis()
for the specified
user's pool or the default if no user specific value is defined.userName
- The user name key.protected org.apache.commons.dbcp2.datasources.PooledConnectionAndInfo getPooledConnectionAndInfo(String userName, String password) throws SQLException
getPooledConnectionAndInfo
in class InstanceKeyDataSource
SQLException
public Reference getReference() throws NamingException
PerUserPoolDataSource
Reference
.NamingException
public void setPerUserBlockWhenExhausted(String userName, Boolean value)
BaseGenericObjectPool.getBlockWhenExhausted()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserDefaultAutoCommit(String userName, Boolean value)
Connection.setAutoCommit(boolean)
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserDefaultReadOnly(String userName, Boolean value)
Connection.setReadOnly(boolean)
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserDefaultTransactionIsolation(String userName, Integer value)
Connection.setTransactionIsolation(int)
for the specified user's
pool.userName
- The user name key.value
- The user specific value.public void setPerUserEvictionPolicyClassName(String userName, String value)
BaseGenericObjectPool.getEvictionPolicyClassName()
for the specified user's
pool.userName
- The user name key.value
- The user specific value.public void setPerUserLifo(String userName, Boolean value)
BaseGenericObjectPool.getLifo()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserMaxIdle(String userName, Integer value)
GenericObjectPool.getMaxIdle()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserMaxTotal(String userName, Integer value)
BaseGenericObjectPool.getMaxTotal()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserMaxWaitMillis(String userName, Long value)
BaseGenericObjectPool.getMaxWaitMillis()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserMinEvictableIdleTimeMillis(String userName, Long value)
BaseGenericObjectPool.getMinEvictableIdleTimeMillis()
for the specified user's
pool.userName
- The user name key.value
- The user specific value.public void setPerUserMinIdle(String userName, Integer value)
GenericObjectPool.getMinIdle()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserNumTestsPerEvictionRun(String userName, Integer value)
BaseGenericObjectPool.getNumTestsPerEvictionRun()
for the specified user's
pool.userName
- The user name key.value
- The user specific value.public void setPerUserSoftMinEvictableIdleTimeMillis(String userName, Long value)
BaseGenericObjectPool.getSoftMinEvictableIdleTimeMillis()
for the specified
user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserTestOnBorrow(String userName, Boolean value)
BaseGenericObjectPool.getTestOnBorrow()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserTestOnCreate(String userName, Boolean value)
BaseGenericObjectPool.getTestOnCreate()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserTestOnReturn(String userName, Boolean value)
BaseGenericObjectPool.getTestOnReturn()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserTestWhileIdle(String userName, Boolean value)
BaseGenericObjectPool.getTestWhileIdle()
for the specified user's pool.userName
- The user name key.value
- The user specific value.public void setPerUserTimeBetweenEvictionRunsMillis(String userName, Long value)
()
for the specified
user's pool.userName
- The user name key.value
- The user specific value.protected void setupDefaults(Connection con, String userName) throws SQLException
setupDefaults
in class InstanceKeyDataSource
SQLException
Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.