本文整理汇总了Java中org.apache.commons.pool.impl.GenericObjectPool.setMinEvictableIdleTimeMillis方法的典型用法代码示例。如果您正苦于以下问题:Java GenericObjectPool.setMinEvictableIdleTimeMillis方法的具体用法?Java GenericObjectPool.setMinEvictableIdleTimeMillis怎么用?Java GenericObjectPool.setMinEvictableIdleTimeMillis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.pool.impl.GenericObjectPool
的用法示例。
在下文中一共展示了GenericObjectPool.setMinEvictableIdleTimeMillis方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureGenericObjectPool
import org.apache.commons.pool.impl.GenericObjectPool; //导入方法依赖的package包/类
protected void configureGenericObjectPool(GenericObjectPool genericObjectPool) throws SyslogRuntimeException {
SyslogPoolConfigIF poolConfig = null;
try {
poolConfig = (SyslogPoolConfigIF) this.syslog.getConfig();
} catch (ClassCastException cce) {
throw new SyslogRuntimeException("config must implement interface SyslogPoolConfigIF");
}
genericObjectPool.setMaxActive(poolConfig.getMaxActive());
genericObjectPool.setMaxIdle(poolConfig.getMaxIdle());
genericObjectPool.setMaxWait(poolConfig.getMaxWait());
genericObjectPool.setMinEvictableIdleTimeMillis(poolConfig.getMinEvictableIdleTimeMillis());
genericObjectPool.setMinIdle(poolConfig.getMinIdle());
genericObjectPool.setNumTestsPerEvictionRun(poolConfig.getNumTestsPerEvictionRun());
genericObjectPool.setSoftMinEvictableIdleTimeMillis(poolConfig.getSoftMinEvictableIdleTimeMillis());
genericObjectPool.setTestOnBorrow(poolConfig.isTestOnBorrow());
genericObjectPool.setTestOnReturn(poolConfig.isTestOnReturn());
genericObjectPool.setTestWhileIdle(poolConfig.isTestWhileIdle());
genericObjectPool.setTimeBetweenEvictionRunsMillis(poolConfig.getTimeBetweenEvictionRunsMillis());
genericObjectPool.setWhenExhaustedAction(poolConfig.getWhenExhaustedAction());
}
示例2: init
import org.apache.commons.pool.impl.GenericObjectPool; //导入方法依赖的package包/类
public void init(ApplicationContext context) {
DriverManagerResource driverManagerResource = (DriverManagerResource) getBindResource();
String userName = driverManagerResource.getUsername();
String password = driverManagerResource.getPassword();
String url = driverManagerResource.getUrl();
String driverClassName = driverManagerResource.getDriverClassName();
DataSource springDS =
new org.springframework.jdbc.datasource.DriverManagerDataSource(url, userName, password);
((org.springframework.jdbc.datasource.DriverManagerDataSource) springDS)
.setDriverClassName(driverClassName);
GenericObjectPool pool = new GenericObjectPool();
pool.setMinEvictableIdleTimeMillis(300000);
pool.setTimeBetweenEvictionRunsMillis(60000);
PoolableConnectionFactory connectionFactory =
new PoolableConnectionFactory(new DataSourceConnectionFactory(springDS), pool, null, null, false,
true);
PoolingDataSource poolingDataSource = new PoolingDataSource(pool);
poolingDataSource.setAccessToUnderlyingConnectionAllowed(true);
setDataSource(poolingDataSource);
postInit(context);
}
示例3: configureGenericObjectPool
import org.apache.commons.pool.impl.GenericObjectPool; //导入方法依赖的package包/类
protected void configureGenericObjectPool(GenericObjectPool genericObjectPool) throws SyslogRuntimeException {
SyslogPoolConfigIF poolConfig = null;
try {
poolConfig = (SyslogPoolConfigIF) this.syslog.getConfig();
} catch (ClassCastException cce) {
throw new SyslogRuntimeException("config must implement interface SyslogPoolConfigIF");
}
genericObjectPool.setMaxActive(poolConfig.getMaxActive());
genericObjectPool.setMaxIdle(poolConfig.getMaxIdle());
genericObjectPool.setMaxWait(poolConfig.getMaxWait());
genericObjectPool.setMinEvictableIdleTimeMillis(poolConfig.getMinEvictableIdleTimeMillis());
genericObjectPool.setMinIdle(poolConfig.getMinIdle());
genericObjectPool.setNumTestsPerEvictionRun(poolConfig.getNumTestsPerEvictionRun());
genericObjectPool.setSoftMinEvictableIdleTimeMillis(poolConfig.getSoftMinEvictableIdleTimeMillis());
genericObjectPool.setTestOnBorrow(poolConfig.isTestOnBorrow());
genericObjectPool.setTestOnReturn(poolConfig.isTestOnReturn());
genericObjectPool.setTestWhileIdle(poolConfig.isTestWhileIdle());
genericObjectPool.setTimeBetweenEvictionRunsMillis(poolConfig.getTimeBetweenEvictionRunsMillis());
genericObjectPool.setWhenExhaustedAction(poolConfig.getWhenExhaustedAction());
}
示例4: createObjectPool
import org.apache.commons.pool.impl.GenericObjectPool; //导入方法依赖的package包/类
/**
* Subclasses can override this if they want to return a specific Commons pool.
* They should apply any configuration properties to the pool here.
* <p>Default is a GenericObjectPool instance with the given pool size.
* @return an empty Commons {@code ObjectPool}.
* @see org.apache.commons.pool.impl.GenericObjectPool
* @see #setMaxSize
*/
protected ObjectPool createObjectPool() {
GenericObjectPool gop = new GenericObjectPool(this);
gop.setMaxActive(getMaxSize());
gop.setMaxIdle(getMaxIdle());
gop.setMinIdle(getMinIdle());
gop.setMaxWait(getMaxWait());
gop.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
gop.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
gop.setWhenExhaustedAction(getWhenExhaustedAction());
return gop;
}
示例5: configurePool
import org.apache.commons.pool.impl.GenericObjectPool; //导入方法依赖的package包/类
/**
* Configures the database connection pool and sets the pool configuration.
*
* @param connectionPool
* The ObjectPool
* @param connectURI
* The url specifying the database to which it
* connects using JDBC
* @param pUserId
* The user id attribute
* @param pPassword
* The password attribute
*
* @throws java.lang.Exception
* Throws an SQL exception that provides
* information on a database access error
* or other errors
*
* @todo Make the pool access dynamic (use the dynamic class loader?)
* so that the application will compile/run without the Apache
* commons library.
*/
private void configurePool(GenericObjectPool connectionPool,
String connectURI, String pUserId, String pPassword) throws
Exception {
String lowerCaseConnectURI;
String validationQuery;
lowerCaseConnectURI = connectURI.toLowerCase();
validationQuery = null;
if (lowerCaseConnectURI.startsWith("jdbc:sybase")) {
validationQuery = "select getdate()";
} else if (lowerCaseConnectURI.startsWith("jdbc:mysql")) {
validationQuery = "select 1";
} else if (lowerCaseConnectURI.startsWith("jdbc:oracle")) {
validationQuery = "select sysdate from dual";
} else if (lowerCaseConnectURI.startsWith("jdbc:mssql")) {
validationQuery = "select 1";
}
// Pool settings - someday a dialog and persistence should be
// added to put these under user control
connectionPool.setMaxActive(1);
connectionPool.setWhenExhaustedAction(GenericObjectPool.
WHEN_EXHAUSTED_BLOCK);
connectionPool.setMaxWait(CONN_POOL_MAX_WAIT_MS);
connectionPool.setMaxIdle(CONN_POOL_MAX_IDLE_CONNECTIONS);
connectionPool
.setTimeBetweenEvictionRunsMillis(CONN_POOL_TIME_BETWEEN_EVICT_RUNS_MS);
connectionPool.setNumTestsPerEvictionRun(CONN_POOL_NUM_TESTS_PER_EVICT_RUN);
connectionPool.setMinEvictableIdleTimeMillis(CONN_POOL_EVICT_IDLE_TIME_MS);
final DriverManagerConnectionFactory connectionFactory = new
DriverManagerConnectionFactory(connectURI, pUserId, pPassword);
final PoolableConnectionFactory poolableConnectionFactory = new
PoolableConnectionFactory(connectionFactory, connectionPool, null,
null, false, true);
if (validationQuery != null) {
connectionPool.setTestOnBorrow(true);
connectionPool.setTestWhileIdle(true);
poolableConnectionFactory.setValidationQuery(validationQuery);
}
}
示例6: registerPool
import org.apache.commons.pool.impl.GenericObjectPool; //导入方法依赖的package包/类
private synchronized void registerPool(
String username, String password)
throws javax.naming.NamingException, SQLException {
ConnectionPoolDataSource cpds = testCPDS(username, password);
Integer userMax = getPerUserMaxActive(username);
int maxActive = (userMax == null) ?
getDefaultMaxActive() : userMax.intValue();
userMax = getPerUserMaxIdle(username);
int maxIdle = (userMax == null) ?
getDefaultMaxIdle() : userMax.intValue();
userMax = getPerUserMaxWait(username);
int maxWait = (userMax == null) ?
getDefaultMaxWait() : userMax.intValue();
// Create an object pool to contain our PooledConnections
GenericObjectPool pool = new GenericObjectPool(null);
pool.setMaxActive(maxActive);
pool.setMaxIdle(maxIdle);
pool.setMaxWait(maxWait);
pool.setWhenExhaustedAction(whenExhaustedAction(maxActive, maxWait));
pool.setTestOnBorrow(getTestOnBorrow());
pool.setTestOnReturn(getTestOnReturn());
pool.setTimeBetweenEvictionRunsMillis(
getTimeBetweenEvictionRunsMillis());
pool.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun());
pool.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
pool.setTestWhileIdle(getTestWhileIdle());
// Set up the factory we will use (passing the pool associates
// the factory with the pool, so we do not have to do so
// explicitly)
CPDSConnectionFactory factory = new CPDSConnectionFactory(cpds, pool, getValidationQuery(),
isRollbackAfterValidation(), username, password);
Object old = managers.put(getPoolKey(username,password), factory);
if (old != null) {
throw new IllegalStateException("Pool already contains an entry for this user/password: "+username);
}
}