Apache Commons PoolThe Apache Commons Pool open source software library provides an object-pooling API and a number of object pool implementations. Version 2 of Apache Commons Pool contains a completely re-written pooling implementation compared to the 1.x series. In addition to performance and scalability improvements, version 2 includes robust instance tracking and pool monitoring.
ReleasesSee the downloads page for information on obtaining releases. FeaturesThe org.apache.commons.pool2 package defines a handful of pooling interfaces and some base classes that may be useful when creating new pool implementations. PooledObjectFactory
public interface PooledObjectFactory<T> { activateObject(PooledObject<T>) destroyObject(PooledObject<T>) destroyObject(PooledObject<T>, DestroyMode) makeObject() passivateObject(PooledObject<T>) validateObject(PooledObject<T>) }
Users of 1.x versions of Commons Pool will notice that while the @Override public PooledObject<Foo> wrap(Foo foo) { return new DefaultPooledObject<Foo>(foo); } Foo is the type of the objects being pooled (the return type of create() ).
public interface KeyedPooledObjectFactory<K,V> { PooledObject<V> makeObject(K key); void activateObject(K key, PooledObject<V> obj); void passivateObject(K key, PooledObject<V> obj); boolean validateObject(K key, PooledObject<V> obj); void destroyObject(K key, PooledObject<V> obj); }
The org.apache.commons.pool2.impl package provides some Pool implementations. GenericObjectPool
SoftReferenceObjectPool
Migrating from Pool 2.x to Pool 2.yClient code that uses a Pool 2.x release should require no code changes to work with a later Pool 2.x release.
New Pool 2.x releases may include support for new configuration
attributes. These will be listed in the change log. Note that the
MBean interfaces (those with names ending in MXBean or MBean) such as
Migrating from Pool 1.x to Pool 2.x
The migration from Apache Commons Pool 1.x to 2.x will require some
code changes. The most significant changes are the changes in package
name from
The key implementation classes ( |