commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1553222 - /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/overview.html
Date Mon, 23 Dec 2013 21:46:38 GMT
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}&lt;Map&lt;Object,Object&gt;&gt;
-    {
-        /**
-         * Creates an instance that can be returned by the pool.
-         * @return an instance that can be returned by the pool.
-         */
-        public Map&lt;Object,Object&gt; makeObject()
-            throws Exception
-        {
-            return new HashMap&lt;Object,Object&gt;();
-        }
-
-        /**
-         * Uninitialize an instance to be returned to the pool.
-         * @param obj the instance to be passivated
-         */
-        public void passivateObject(Map&lt;Object,Object&gt; 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&lt;Map&lt;Object,Object&gt;&gt;}
pool;
-        public Foo()
-        {
-            {@link org.apache.commons.pool2.PoolableObjectFactory PoolableObjectFactory&lt;Map&lt;Object,Object&gt;&gt;}
factory = new HashMapFactory();
-            pool = new {@link org.apache.commons.pool2.impl.GenericObjectPool GenericObjectPool}&lt;Map&lt;Object,Object&gt;&gt;(factory);
-        }
-
-        public doSomething()
-        {
-            ...
-            Map&lt;Object,Object&gt; 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



Mime
View raw message