當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericObjectPool.setTimeBetweenEvictionRunsMillis方法代碼示例

本文整理匯總了Java中org.apache.commons.pool.impl.GenericObjectPool.setTimeBetweenEvictionRunsMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java GenericObjectPool.setTimeBetweenEvictionRunsMillis方法的具體用法?Java GenericObjectPool.setTimeBetweenEvictionRunsMillis怎麽用?Java GenericObjectPool.setTimeBetweenEvictionRunsMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.pool.impl.GenericObjectPool的用法示例。


在下文中一共展示了GenericObjectPool.setTimeBetweenEvictionRunsMillis方法的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());
}
 
開發者ID:syslog4j,項目名稱:syslog4j,代碼行數:24,代碼來源:GenericSyslogPoolFactory.java

示例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);
}
 
開發者ID:qafedev,項目名稱:qafe-platform,代碼行數:26,代碼來源:DriverManagerDataSource.java

示例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());
}
 
開發者ID:graylog-labs,項目名稱:syslog4j-graylog2,代碼行數:24,代碼來源:GenericSyslogPoolFactory.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:20,代碼來源:CommonsPoolTargetSource.java

示例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);
  }
}
 
開發者ID:DaveRead,項目名稱:BasicQuery,代碼行數:66,代碼來源:BasicQuery.java

示例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);
    }
}
 
開發者ID:WhiteBearSolutions,項目名稱:WBSAirback,代碼行數:42,代碼來源:PerUserPoolDataSource.java


注:本文中的org.apache.commons.pool.impl.GenericObjectPool.setTimeBetweenEvictionRunsMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。