Search in sources :

Example 11 with GenericKeyedObjectPoolConfig

use of org.apache.tomcat.dbcp.pool2.impl.GenericKeyedObjectPoolConfig in project datanucleus-rdbms by datanucleus.

the class SharedPoolDataSource method registerPool.

private void registerPool(final String userName, final String password) throws NamingException, SQLException {
    final ConnectionPoolDataSource cpds = testCPDS(userName, password);
    // Create an object pool to contain our PooledConnections
    factory = new KeyedCPDSConnectionFactory(cpds, getValidationQuery(), getValidationQueryTimeout(), isRollbackAfterValidation());
    factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis());
    final GenericKeyedObjectPoolConfig<PooledConnectionAndInfo> config = new GenericKeyedObjectPoolConfig<>();
    config.setBlockWhenExhausted(getDefaultBlockWhenExhausted());
    config.setEvictionPolicyClassName(getDefaultEvictionPolicyClassName());
    config.setLifo(getDefaultLifo());
    config.setMaxIdlePerKey(getDefaultMaxIdle());
    config.setMaxTotal(getMaxTotal());
    config.setMaxTotalPerKey(getDefaultMaxTotal());
    config.setMaxWaitMillis(getDefaultMaxWaitMillis());
    config.setMinEvictableIdleTimeMillis(getDefaultMinEvictableIdleTimeMillis());
    config.setMinIdlePerKey(getDefaultMinIdle());
    config.setNumTestsPerEvictionRun(getDefaultNumTestsPerEvictionRun());
    config.setSoftMinEvictableIdleTimeMillis(getDefaultSoftMinEvictableIdleTimeMillis());
    config.setTestOnCreate(getDefaultTestOnCreate());
    config.setTestOnBorrow(getDefaultTestOnBorrow());
    config.setTestOnReturn(getDefaultTestOnReturn());
    config.setTestWhileIdle(getDefaultTestWhileIdle());
    config.setTimeBetweenEvictionRunsMillis(getDefaultTimeBetweenEvictionRunsMillis());
    final KeyedObjectPool<UserPassKey, PooledConnectionAndInfo> tmpPool = new GenericKeyedObjectPool<>(factory, config);
    factory.setPool(tmpPool);
    pool = tmpPool;
}
Also used : ConnectionPoolDataSource(javax.sql.ConnectionPoolDataSource) GenericKeyedObjectPoolConfig(org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericKeyedObjectPoolConfig) GenericKeyedObjectPool(org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericKeyedObjectPool)

Aggregations

GenericKeyedObjectPoolConfig (org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig)4 GenericKeyedObjectPoolConfig (org.apache.tomcat.dbcp.pool2.impl.GenericKeyedObjectPoolConfig)4 Connection (java.sql.Connection)3 ObjectName (javax.management.ObjectName)3 GenericKeyedObjectPool (org.apache.tomcat.dbcp.pool2.impl.GenericKeyedObjectPool)3 GenericKeyedObjectPoolConfig (org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericKeyedObjectPoolConfig)3 SQLException (java.sql.SQLException)2 ConnectionPoolDataSource (javax.sql.ConnectionPoolDataSource)2 DefaultPooledObject (org.apache.tomcat.dbcp.pool2.impl.DefaultPooledObject)2 GenericKeyedObjectPool (org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericKeyedObjectPool)2 Script (groovy.lang.Script)1 BaseKeyedPooledObjectFactory (org.apache.commons.pool2.BaseKeyedPooledObjectFactory)1 DefaultPooledObject (org.apache.commons.pool2.impl.DefaultPooledObject)1 GenericKeyedObjectPool (org.apache.commons.pool2.impl.GenericKeyedObjectPool)1 DelegatingPreparedStatement (org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement)1 PStmtKey (org.apache.tomcat.dbcp.dbcp2.PStmtKey)1 PoolableConnection (org.apache.tomcat.dbcp.dbcp2.PoolableConnection)1 PoolablePreparedStatement (org.apache.tomcat.dbcp.dbcp2.PoolablePreparedStatement)1 PoolingConnection (org.apache.tomcat.dbcp.dbcp2.PoolingConnection)1 PoolablePreparedStatement (org.datanucleus.store.rdbms.datasource.dbcp2.PoolablePreparedStatement)1