objectPool.setMaxWait(connectionTimeout); objectPool.setMaxIdle(connectionMaxIlde); objectPool.setMinIdle(connectionMinIlde); objectPool.setTestOnBorrow(testOnBorrow); objectPool.setTestWhileIdle(testWhileIdle);
/** * Sets my configuration. * * @param conf configuration to use. * @see GenericObjectPool.Config */ public void setConfig(GenericObjectPool.Config conf) { synchronized (this) { setMaxIdle(conf.maxIdle); setMinIdle(conf.minIdle); setMaxActive(conf.maxActive); setMaxWait(conf.maxWait); setWhenExhaustedAction(conf.whenExhaustedAction); setTestOnBorrow(conf.testOnBorrow); setTestOnReturn(conf.testOnReturn); setTestWhileIdle(conf.testWhileIdle); setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun); setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis); setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis); setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis); setLifo(conf.lifo); } allocate(); }
/** * Sets the minimum number of idle connections in the pool. * * @param minIdle the new value for minIdle * @see GenericObjectPool#setMinIdle(int) */ public void setMinIdle(int minIdle) { this.minIdle = minIdle; if (sessionPool != null) { sessionPool.setMinIdle(minIdle); } }
/** * Sets the minimum number of idle connections in the pool. * * @param minIdle the new value for minIdle * @see GenericObjectPool#setMinIdle(int) */ public synchronized void setMinIdle(int minIdle) { this.minIdle = minIdle; if (connectionPool != null) { connectionPool.setMinIdle(minIdle); } }
/** * Sets the minimum number of idle connections in the pool. * * @param minIdle the new value for minIdle * @see GenericObjectPool#setMinIdle(int) */ public synchronized void setMinIdle(int minIdle) { this.minIdle = minIdle; if (connectionPool != null) { connectionPool.setMinIdle(minIdle); } }
/** * Sets the minimum number of idle connections in the pool. * * @param minIdle the new value for minIdle * @see GenericObjectPool#setMinIdle(int) */ public synchronized void setMinIdle(int minIdle) { this.minIdle = minIdle; if (connectionPool != null) { connectionPool.setMinIdle(minIdle); } }
/** * Sets the minimum number of idle connections in the pool. * * @param minIdle the new value for minIdle * @see GenericObjectPool#setMinIdle(int) */ public synchronized void setMinIdle(int minIdle) { this.minIdle = minIdle; if (connectionPool != null) { connectionPool.setMinIdle(minIdle); } }
public XsltTransformer() { super(); transformerPool = new GenericObjectPool(new PooledXsltTransformerFactory()); transformerPool.setMinIdle(MIN_IDLE_TRANSFORMERS); transformerPool.setMaxIdle(MAX_IDLE_TRANSFORMERS); transformerPool.setMaxActive(MAX_ACTIVE_TRANSFORMERS); contextProperties = new HashMap<String, Object>(); }
private GenericObjectPool<XPathExpression> getXPathExpressionPool(String expression) { GenericObjectPool genericPool = new GenericObjectPool(new XPathExpressionFactory(xpathFactory, expression, namespaceContext, this)); genericPool.setMaxActive(MAX_ACTIVE_XPATH_EXPRESSIONS); genericPool.setMaxIdle(MAX_IDLE_XPATH_EXPRESSIONS); genericPool.setMinIdle(MIN_IDLE_XPATH_EXPRESSIONS); return genericPool; }
public DefaultComponentPool(PoolableObjectFactory objectFactory) { pool = new GenericObjectPool(objectFactory); pool.setMinIdle(POOL_SIZE); pool.setMaxActive(POOL_SIZE); pool.setNumTestsPerEvictionRun(0); pool.setMinEvictableIdleTimeMillis(0); pool.setTimeBetweenEvictionRunsMillis(POOL_SPAWN_DELAY); }
private DataSource setupDataSource(String connectURI, IModule module) { // Ensure the JDBC driver class is loaded // TODO - AHK final List<? extends ITypeLoader> typeLoaders = module.getTypeLoaders(IDefaultTypeLoader.class); ((IDefaultTypeLoader)typeLoaders.get(0)).loadClass(getDriverName(connectURI)); // TODO - AHK - Figure out the implications of the connection pooling when the jdbc url changes GenericObjectPool connectionPool = new GenericObjectPool(null); connectionPool.setMinIdle( 1 ); connectionPool.setMaxActive( 10 ); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI,null); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true); return new PoolingDataSource(connectionPool); } }
@Override public void afterPropertiesSet() throws Exception { // 对象池 objectPool = new GenericObjectPool<TTransport>(); // ((GenericObjectPool<TTransport>) objectPool).setMaxActive(maxActive); ((GenericObjectPool<TTransport>) objectPool).setMaxIdle(maxIdle); ((GenericObjectPool<TTransport>) objectPool).setMinIdle(minIdle); ((GenericObjectPool<TTransport>) objectPool).setMaxWait(maxWait); ((GenericObjectPool<TTransport>) objectPool).setTestOnBorrow(testOnBorrow); ((GenericObjectPool<TTransport>) objectPool).setTestOnReturn(testOnReturn); ((GenericObjectPool<TTransport>) objectPool).setTestWhileIdle(testWhileIdle); ((GenericObjectPool<TTransport>) objectPool).setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK); // 设置factory ThriftPoolableObjectFactory thriftPoolableObjectFactory = new ThriftPoolableObjectFactory(serviceIP, servicePort, conTimeOut); ((GenericObjectPool<TTransport>) objectPool).setFactory(thriftPoolableObjectFactory); }
/** * Sets my configuration. * * @param conf configuration to use. * @see GenericObjectPool.Config */ public synchronized void setConfig(GenericObjectPool.Config conf) { setMaxIdle(conf.maxIdle); setMinIdle(conf.minIdle); setMaxActive(conf.maxActive); setMaxWait(conf.maxWait); setWhenExhaustedAction(conf.whenExhaustedAction); setTestOnBorrow(conf.testOnBorrow); setTestOnReturn(conf.testOnReturn); setTestWhileIdle(conf.testWhileIdle); setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun); setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis); setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis); setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis); setLifo(conf.lifo); allocate(); }
/** * Sets my configuration. * * @param conf configuration to use. * @see GenericObjectPool.Config */ public synchronized void setConfig(GenericObjectPool.Config conf) { setMaxIdle(conf.maxIdle); setMinIdle(conf.minIdle); setMaxActive(conf.maxActive); setMaxWait(conf.maxWait); setWhenExhaustedAction(conf.whenExhaustedAction); setTestOnBorrow(conf.testOnBorrow); setTestOnReturn(conf.testOnReturn); setTestWhileIdle(conf.testWhileIdle); setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun); setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis); setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis); setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis); setLifo(conf.lifo); allocate(); }
/** * Sets my configuration. * * @param conf configuration to use. * @see GenericObjectPool.Config */ public void setConfig(GenericObjectPool.Config conf) { synchronized (this) { setMaxIdle(conf.maxIdle); setMinIdle(conf.minIdle); setMaxActive(conf.maxActive); setMaxWait(conf.maxWait); setWhenExhaustedAction(conf.whenExhaustedAction); setTestOnBorrow(conf.testOnBorrow); setTestOnReturn(conf.testOnReturn); setTestWhileIdle(conf.testWhileIdle); setNumTestsPerEvictionRun(conf.numTestsPerEvictionRun); setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis); setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis); setSoftMinEvictableIdleTimeMillis(conf.softMinEvictableIdleTimeMillis); setLifo(conf.lifo); } allocate(); }
/** * 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; }
/** * 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</code>. * @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; }
public XQueryTransformer() { super(); transformerPool = new GenericObjectPool(new PooledXQueryTransformerFactory()); transformerPool.setMinIdle(MIN_IDLE_TRANSFORMERS); transformerPool.setMaxIdle(MAX_IDLE_TRANSFORMERS); transformerPool.setMaxActive(MAX_ACTIVE_TRANSFORMERS); registerSourceType(DataTypeFactory.STRING); registerSourceType(DataTypeFactory.BYTE_ARRAY); registerSourceType(DataTypeFactory.create(DocumentSource.class)); registerSourceType(DataTypeFactory.create(org.dom4j.Document.class)); registerSourceType(DataTypeFactory.create(Document.class)); registerSourceType(DataTypeFactory.create(Element.class)); registerSourceType(DataTypeFactory.INPUT_STREAM); setReturnDataType(DataTypeFactory.create(List.class)); }
protected void configureGenericObjectPool(GenericObjectPool<AbstractSyslogWriter> 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()); }
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()); }