Author: psteitz Date: Mon Dec 23 21:46:38 2013 New Revision: 1553222 URL: http://svn.apache.org/r1553222 Log: Dropped obsolete example.
Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/overview.html Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/overview.html URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/overview.html?rev=1553222&r1=1553221&r2=1553222&view=diff ============================================================================== --- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/overview.html (original) +++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/overview.html Mon Dec 23 21:46:38 2013 @@ -46,76 +46,5 @@ {@link org.apache.commons.pool2.impl.GenericKeyedObjectPool GenericKeyedObjectPool} </p> - <p> - Here is a simple example of pooling <code>HashMap</code> instances. - First create an {@link org.apache.commons.pool2.PoolableObjectFactory - PoolableObjectFactory} - </p> -<pre> - public class HashMapFactory - extends {@link org.apache.commons.pool2.BasePoolableObjectFactory BasePoolableObjectFactory}<Map<Object,Object>> - { - /** - * Creates an instance that can be returned by the pool. - * @return an instance that can be returned by the pool. - */ - public Map<Object,Object> makeObject() - throws Exception - { - return new HashMap<Object,Object>(); - } - - /** - * Uninitialize an instance to be returned to the pool. - * @param obj the instance to be passivated - */ - public void passivateObject(Map<Object,Object> obj) - throws Exception - { - obj.clear(); - } - } -</pre> - <p> - A class that makes frequent use of a Map could then use a pool - as shown below: - </p> -<pre> - public class Foo - { - private {@link org.apache.commons.pool2.ObjectPool ObjectPool<Map<Object,Object>>} pool; - public Foo() - { - {@link org.apache.commons.pool2.PoolableObjectFactory PoolableObjectFactory<Map<Object,Object>>} factory = new HashMapFactory(); - pool = new {@link org.apache.commons.pool2.impl.GenericObjectPool GenericObjectPool}<Map<Object,Object>>(factory); - } - - public doSomething() - { - ... - Map<Object,Object> map = null; - try - { - map = pool.borrowObject(); - // use map - ... - } - finally - { - if (map != null) - { - pool.returnObject(map); - } - } - ... - } - } -</pre> - -<p> -The above example shows how one would use an -{@link org.apache.commons.pool2.ObjectPool ObjectPool}. The other supplied -implementations or another special purpose pool would be used similarly. -</p> </body> </html> \ No newline at end of file