org.apache.commons.pool.PoolableObjectFactory Java Examples
The following examples show how to use
org.apache.commons.pool.PoolableObjectFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceQueue.java From datawave with Apache License 2.0 | 6 votes |
/** * Constructor that accepts the type of pool, the connector, and the capacity * * @param capacity * @param cxn * @param type */ public ResourceQueue(int capacity, Connector cxn, byte type) { Preconditions.checkNotNull(cxn); Preconditions.checkArgument(capacity > 0); this.type = type; PoolableObjectFactory<AccumuloResource> factory = new AccumuloResourceFactory(cxn); this.scannerPool = new GenericObjectPool<AccumuloResource>(factory); // set the max capacity this.scannerPool.setMaxActive(capacity); // amount of time to wait for a connection this.scannerPool.setMaxWait(5000); // block this.scannerPool.setWhenExhaustedAction(type); }
Example #2
Source File: KeyedResourcePool.java From JVoiceXML with GNU Lesser General Public License v2.1 | 6 votes |
/** * Adds the given resource factory. * @param resourceFactory The {@link ResourceFactory} to add. * @exception Exception error populating the pool */ public void addResourceFactory( final ResourceFactory<T> resourceFactory) throws Exception { final PoolableObjectFactory<T> factory = new PoolableResourceFactory<T>(resourceFactory); final GenericObjectPool<T> pool = new GenericObjectPool<T>(factory); final int instances = resourceFactory.getInstances(); pool.setMinIdle(instances); pool.setMaxActive(instances); pool.setMaxIdle(instances); pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL); final String type = resourceFactory.getType(); pools.put(type, pool); LOGGER.info("loading " + instances + " instance(s) of type '" + type + "'"); for (int i = 0; i < instances; i++) { pool.addObject(); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("...resources loaded."); } }
Example #3
Source File: FTPClientPool.java From springboot-ureport with Apache License 2.0 | 4 votes |
/** * 需要一个工厂来制造池中的对象 */ @Override public void setFactory(PoolableObjectFactory<FTPClient> factory) throws IllegalStateException, UnsupportedOperationException { }
Example #4
Source File: FirefoxDriverObjectPool.java From Asqatasun with GNU Affero General Public License v3.0 | 4 votes |
@Autowired public FirefoxDriverObjectPool(PoolableObjectFactory pof) { super(pof); }
Example #5
Source File: Pool.java From navi-pbrpc with Apache License 2.0 | 2 votes |
/** * Creates a new instance of Pool. * * @param poolConfig * @param factory */ public Pool(final GenericObjectPool.Config poolConfig, PoolableObjectFactory factory) { this.internalPool = new GenericObjectPool(factory, poolConfig); }