Return-Path:
X-Original-To: apmail-commons-commits-archive@minotaur.apache.org
Delivered-To: apmail-commons-commits-archive@minotaur.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id 251B610E7F
for ;
Mon, 23 Dec 2013 21:47:02 +0000 (UTC)
Received: (qmail 7969 invoked by uid 500); 23 Dec 2013 21:47:02 -0000
Delivered-To: apmail-commons-commits-archive@commons.apache.org
Received: (qmail 7902 invoked by uid 500); 23 Dec 2013 21:47:01 -0000
Mailing-List: contact commits-help@commons.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@commons.apache.org
Delivered-To: mailing list commits@commons.apache.org
Received: (qmail 7895 invoked by uid 99); 23 Dec 2013 21:47:01 -0000
Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Dec 2013 21:47:01 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=5.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Dec 2013 21:46:59 +0000
Received: from eris.apache.org (localhost [127.0.0.1])
by eris.apache.org (Postfix) with ESMTP id 635A42388993;
Mon, 23 Dec 2013 21:46:38 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
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 -0000
To: commits@commons.apache.org
From: psteitz@apache.org
X-Mailer: svnmailer-1.0.9
Message-Id: <20131223214638.635A42388993@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
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}
-
- Here is a simple example of pooling HashMap
instances.
- First create an {@link org.apache.commons.pool2.PoolableObjectFactory
- PoolableObjectFactory}
-
-
- 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();
- }
- }
-
-
- A class that makes frequent use of a Map could then use a pool
- as shown below:
-
-
- 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);
- }
- }
- ...
- }
- }
-
-
-
-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.
-