当前位置: 首页>>代码示例>>Java>>正文


Java GenericObjectPool.setLifo方法代码示例

本文整理汇总了Java中org.apache.commons.pool2.impl.GenericObjectPool.setLifo方法的典型用法代码示例。如果您正苦于以下问题:Java GenericObjectPool.setLifo方法的具体用法?Java GenericObjectPool.setLifo怎么用?Java GenericObjectPool.setLifo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.pool2.impl.GenericObjectPool的用法示例。


在下文中一共展示了GenericObjectPool.setLifo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createConnectionPool

import org.apache.commons.pool2.impl.GenericObjectPool; //导入方法依赖的package包/类
/**
 * Creates a connection pool for this datasource.  This method only exists
 * so subclasses can replace the implementation class.
 *
 * This implementation configures all pool properties other than
 * timeBetweenEvictionRunsMillis.  Setting that property is deferred to
 * {@link #startPoolMaintenance()}, since setting timeBetweenEvictionRunsMillis
 * to a positive value causes {@link GenericObjectPool}'s eviction timer
 * to be started.
 */
protected void createConnectionPool(final PoolableConnectionFactory factory) {
    // Create an object pool to contain our active connections
    final GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    updateJmxName(config);
    config.setJmxEnabled(registeredJmxObjectName != null);  // Disable JMX on the underlying pool if the DS is not registered.
    final GenericObjectPool<PoolableConnection> gop = createObjectPool(factory, config, abandonedConfig);
    gop.setMaxTotal(maxTotal);
    gop.setMaxIdle(maxIdle);
    gop.setMinIdle(minIdle);
    gop.setMaxWaitMillis(maxWaitMillis);
    gop.setTestOnCreate(testOnCreate);
    gop.setTestOnBorrow(testOnBorrow);
    gop.setTestOnReturn(testOnReturn);
    gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
    gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    gop.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);
    gop.setTestWhileIdle(testWhileIdle);
    gop.setLifo(lifo);
    gop.setSwallowedExceptionListener(new SwallowedExceptionLogger(log, logExpiredConnections));
    gop.setEvictionPolicyClassName(evictionPolicyClassName);
    factory.setPool(gop);
    connectionPool = gop;
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:34,代码来源:BasicDataSource.java

示例2: createProcessPool

import org.apache.commons.pool2.impl.GenericObjectPool; //导入方法依赖的package包/类
private GenericObjectPool<PhantomJSProcess> createProcessPool(JRPropertiesUtil properties)
{
	ProcessFactory processFactory = new ProcessFactory(this, properties);
	GenericObjectPool<PhantomJSProcess> pool = new GenericObjectPool<>(processFactory);
	pool.setLifo(true);
	
	int maxProcessCount = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_MAX_PROCESS_COUNT, 
			PhantomJS.DEFAULT_PHANTOMJS_MAX_PROCESS_COUNT);
	pool.setMaxTotal(maxProcessCount);
	pool.setMaxIdle(maxProcessCount);
	
	int borrowTimeout = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_POOL_BORROW_TIMEOUT, 
			PhantomJS.DEFAULT_PHANTOMJS_POOL_BORROW_TIMEOUT);
	pool.setMaxWaitMillis(borrowTimeout);
	
	int idleTimeout = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_IDLE_TIMEOUT, 
			PhantomJS.DEFAULT_PHANTOMJS_IDLE_TIMEOUT);
	pool.setMinEvictableIdleTimeMillis(idleTimeout);
	
	pool.setTimeBetweenEvictionRunsMillis(idlePingInterval);
	
	pool.setTestWhileIdle(true);
	pool.setNumTestsPerEvictionRun(Integer.MAX_VALUE);
	
	pool.setSwallowedExceptionListener(new SwallowedExceptionListener()
	{
		@Override
		public void onSwallowException(Exception e)
		{
			if (log.isDebugEnabled())
			{
				log.debug("Pool exception", e);
			}
		}
	});
	
	return pool;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:39,代码来源:ProcessDirector.java

示例3: registerPool

import org.apache.commons.pool2.impl.GenericObjectPool; //导入方法依赖的package包/类
private synchronized void registerPool(final String username, final String password)
        throws NamingException, SQLException {

    final ConnectionPoolDataSource cpds = testCPDS(username, password);

    // 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)
    final CPDSConnectionFactory factory = new CPDSConnectionFactory(cpds,
            getValidationQuery(), getValidationQueryTimeout(),
            isRollbackAfterValidation(), username, password);
    factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis());

    // Create an object pool to contain our PooledConnections
    final GenericObjectPool<PooledConnectionAndInfo> pool =
            new GenericObjectPool<>(factory);
    factory.setPool(pool);
    pool.setBlockWhenExhausted(getPerUserBlockWhenExhausted(username));
    pool.setEvictionPolicyClassName(
            getPerUserEvictionPolicyClassName(username));
    pool.setLifo(getPerUserLifo(username));
    pool.setMaxIdle(getPerUserMaxIdle(username));
    pool.setMaxTotal(getPerUserMaxTotal(username));
    pool.setMaxWaitMillis(getPerUserMaxWaitMillis(username));
    pool.setMinEvictableIdleTimeMillis(
            getPerUserMinEvictableIdleTimeMillis(username));
    pool.setMinIdle(getPerUserMinIdle(username));
    pool.setNumTestsPerEvictionRun(
            getPerUserNumTestsPerEvictionRun(username));
    pool.setSoftMinEvictableIdleTimeMillis(
            getPerUserSoftMinEvictableIdleTimeMillis(username));
    pool.setTestOnCreate(getPerUserTestOnCreate(username));
    pool.setTestOnBorrow(getPerUserTestOnBorrow(username));
    pool.setTestOnReturn(getPerUserTestOnReturn(username));
    pool.setTestWhileIdle(getPerUserTestWhileIdle(username));
    pool.setTimeBetweenEvictionRunsMillis(
            getPerUserTimeBetweenEvictionRunsMillis(username));

    pool.setSwallowedExceptionListener(new SwallowedExceptionLogger(log));

    final Object old = managers.put(getPoolKey(username), factory);
    if (old != null) {
        throw new IllegalStateException("Pool already contains an entry for this user/password: " + username);
    }
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:46,代码来源:PerUserPoolDataSource.java


注:本文中的org.apache.commons.pool2.impl.GenericObjectPool.setLifo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。