You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2013/07/24 22:01:35 UTC

svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Author: markt
Date: Wed Jul 24 20:01:34 2013
New Revision: 1506685

URL: http://svn.apache.org/r1506685
Log:
Create two new factory interfaces that work with PooledObject instances rather than Object instances and switch Gop and GKOP to use them.

Added:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java   (with props)
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PooledObjectFactory.java   (with props)
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java   (with props)
Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java

Added: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java?rev=1506685&view=auto
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java (added)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java Wed Jul 24 20:01:34 2013
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.pool2;
+
+/**
+ * This interface extends {@link KeyedPoolableObjectFactory} to work with
+ * {@link PooledObject}s rather than {@link Object}s. This allows the factory to
+ * make use of state information from {@link PooledObject}.
+ */
+public interface KeyedPooledObjectFactory<K,V> extends
+        KeyedPoolableObjectFactory<K, PooledObject<V>> {
+}

Propchange: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/KeyedPooledObjectFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PooledObjectFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PooledObjectFactory.java?rev=1506685&view=auto
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PooledObjectFactory.java (added)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PooledObjectFactory.java Wed Jul 24 20:01:34 2013
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.pool2;
+
+/**
+ * This interface extends {@link PoolableObjectFactory} to work with
+ * {@link PooledObject}s rather than {@link Object}s. This allows the factory to
+ * make use of state information from {@link PooledObject}.
+ */
+public interface PooledObjectFactory<T>
+        extends PoolableObjectFactory<PooledObject<T>> {
+}

Propchange: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/PooledObjectFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1506685&r1=1506684&r2=1506685&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java Wed Jul 24 20:01:34 2013
@@ -33,7 +33,7 @@ import java.util.concurrent.locks.ReadWr
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.commons.pool2.KeyedObjectPool;
-import org.apache.commons.pool2.KeyedPoolableObjectFactory;
+import org.apache.commons.pool2.KeyedPooledObjectFactory;
 import org.apache.commons.pool2.PoolUtils;
 import org.apache.commons.pool2.PooledObject;
 import org.apache.commons.pool2.PooledObjectState;
@@ -41,7 +41,7 @@ import org.apache.commons.pool2.PooledOb
 /**
  * A configurable <code>KeyedObjectPool</code> implementation.
  * <p>
- * When coupled with the appropriate {@link KeyedPoolableObjectFactory},
+ * When coupled with the appropriate {@link KeyedPooledObjectFactory},
  * <code>GenericKeyedObjectPool</code> provides robust pooling functionality for
  * keyed objects. A <code>GenericKeyedObjectPool</code> can be viewed as a map
  * of sub-pools, keyed on the (unique) key values provided to the
@@ -81,7 +81,7 @@ public class GenericKeyedObjectPool<K,T>
      * {@link GenericKeyedObjectPoolConfig}.
      * @param factory the factory to be used to create entries
      */
-    public GenericKeyedObjectPool(KeyedPoolableObjectFactory<K,T> factory) {
+    public GenericKeyedObjectPool(KeyedPooledObjectFactory<K,T> factory) {
         this(factory, new GenericKeyedObjectPoolConfig());
     }
 
@@ -95,7 +95,7 @@ public class GenericKeyedObjectPool<K,T>
      *                  the configuration object will not be reflected in the
      *                  pool.
      */
-    public GenericKeyedObjectPool(KeyedPoolableObjectFactory<K,T> factory,
+    public GenericKeyedObjectPool(KeyedPooledObjectFactory<K,T> factory,
             GenericKeyedObjectPoolConfig config) {
 
         super(config, ONAME_BASE, config.getJmxNamePrefix());
@@ -260,7 +260,7 @@ public class GenericKeyedObjectPool<K,T>
      *
      * @return the factory
      */
-    public KeyedPoolableObjectFactory<K, T> getFactory() {
+    public KeyedPooledObjectFactory<K, T> getFactory() {
         return factory;
     }
 
@@ -382,7 +382,7 @@ public class GenericKeyedObjectPool<K,T>
 
                 if (p != null) {
                     try {
-                        factory.activateObject(key, p.getObject());
+                        factory.activateObject(key, p);
                     } catch (Exception e) {
                         try {
                             destroy(key, p, true);
@@ -401,7 +401,7 @@ public class GenericKeyedObjectPool<K,T>
                         boolean validate = false;
                         Throwable validationThrowable = null;
                         try {
-                            validate = factory.validateObject(key, p.getObject());
+                            validate = factory.validateObject(key, p);
                         } catch (Throwable t) {
                             PoolUtils.checkRethrow(t);
                             validationThrowable = t;
@@ -471,7 +471,7 @@ public class GenericKeyedObjectPool<K,T>
         long activeTime = p.getActiveTimeMillis();
 
         if (getTestOnReturn()) {
-            if (!factory.validateObject(key, obj)) {
+            if (!factory.validateObject(key, p)) {
                 try {
                     destroy(key, p, true);
                 } catch (Exception e) {
@@ -483,7 +483,7 @@ public class GenericKeyedObjectPool<K,T>
         }
 
         try {
-            factory.passivateObject(key, obj);
+            factory.passivateObject(key, p);
         } catch (Exception e1) {
             swallowException(e1);
             try {
@@ -562,7 +562,7 @@ public class GenericKeyedObjectPool<K,T>
      * Clears any objects sitting idle in the pool by removing them from the
      * idle instance sub-pools and then invoking the configured
      * PoolableObjectFactory's
-     * {@link KeyedPoolableObjectFactory#destroyObject(Object, Object)} method
+     * {@link KeyedPooledObjectFactory#destroyObject(Object, Object)} method
      * on each idle instance.
      * <p>
      * Implementation notes:
@@ -919,8 +919,7 @@ public class GenericKeyedObjectPool<K,T>
                     if (testWhileIdle) {
                         boolean active = false;
                         try {
-                            factory.activateObject(evictionKey,
-                                    underTest.getObject());
+                            factory.activateObject(evictionKey, underTest);
                             active = true;
                         } catch (Exception e) {
                             destroy(evictionKey, underTest, true);
@@ -928,13 +927,13 @@ public class GenericKeyedObjectPool<K,T>
                         }
                         if (active) {
                             if (!factory.validateObject(evictionKey,
-                                    underTest.getObject())) {
+                                    underTest)) {
                                 destroy(evictionKey, underTest, true);
                                 destroyedByEvictorCount.incrementAndGet();
                             } else {
                                 try {
                                     factory.passivateObject(evictionKey,
-                                            underTest.getObject());
+                                            underTest);
                                 } catch (Exception e) {
                                     destroy(evictionKey, underTest, true);
                                     destroyedByEvictorCount.incrementAndGet();
@@ -984,17 +983,20 @@ public class GenericKeyedObjectPool<K,T>
         }
 
 
-        T t = null;
+        PooledObject<T> p = null;
         try {
-            t = factory.makeObject(key);
+            p = factory.makeObject(key);
         } catch (Exception e) {
             numTotal.decrementAndGet();
             throw e;
         }
 
-        PooledObject<T> p = new PooledObjectImpl<T>(t);
+        if (p instanceof PooledObjectImpl) {
+            ((PooledObjectImpl<T> )p).setAbandonedLoqWriter(null);
+        }
+
         createdCount.incrementAndGet();
-        objectDeque.getAllObjects().put(t, p);
+        objectDeque.getAllObjects().put(p.getObject(), p);
         return p;
     }
 
@@ -1011,7 +1013,7 @@ public class GenericKeyedObjectPool<K,T>
                 toDestroy.invalidate();
 
                 try {
-                    factory.destroyObject(key, toDestroy.getObject());
+                    factory.destroyObject(key, toDestroy);
                 } finally {
                     objectDeque.getCreateCount().decrementAndGet();
                     destroyedCount.incrementAndGet();
@@ -1124,14 +1126,14 @@ public class GenericKeyedObjectPool<K,T>
     }
 
     /**
-     * Create an object using the {@link KeyedPoolableObjectFactory#makeObject
+     * Create an object using the {@link KeyedPooledObjectFactory#makeObject
      * factory}, passivate it, and then place it in the idle object pool.
      * <code>addObject</code> is useful for "pre-loading" a pool with idle
      * objects.
      *
      * @param key the key a new instance should be added to
      *
-     * @throws Exception when {@link KeyedPoolableObjectFactory#makeObject}
+     * @throws Exception when {@link KeyedPooledObjectFactory#makeObject}
      *                   fails.
      */
     @Override
@@ -1149,7 +1151,7 @@ public class GenericKeyedObjectPool<K,T>
     private void addIdleObject(K key, PooledObject<T> p) throws Exception {
 
         if (p != null) {
-            factory.passivateObject(key, p.getObject());
+            factory.passivateObject(key, p);
             LinkedBlockingDeque<PooledObject<T>> idleObjects =
                     poolMap.get(key).getIdleObjects();
             if (getLifo()) {
@@ -1346,7 +1348,7 @@ public class GenericKeyedObjectPool<K,T>
         GenericKeyedObjectPoolConfig.DEFAULT_MIN_IDLE_PER_KEY;
     private volatile int maxTotalPerKey =
         GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL_PER_KEY;
-    private final KeyedPoolableObjectFactory<K,T> factory;
+    private final KeyedPooledObjectFactory<K,T> factory;
 
 
     //--- internal attributes --------------------------------------------------

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java?rev=1506685&r1=1506684&r2=1506685&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericObjectPool.java Wed Jul 24 20:01:34 2013
@@ -26,15 +26,15 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.commons.pool2.ObjectPool;
 import org.apache.commons.pool2.PoolUtils;
-import org.apache.commons.pool2.PoolableObjectFactory;
 import org.apache.commons.pool2.PooledObject;
+import org.apache.commons.pool2.PooledObjectFactory;
 import org.apache.commons.pool2.PooledObjectState;
 import org.apache.commons.pool2.TrackedUse;
 
 /**
  * A configurable {@link ObjectPool} implementation.
  * <p>
- * When coupled with the appropriate {@link PoolableObjectFactory},
+ * When coupled with the appropriate {@link PooledObjectFactory},
  * <code>GenericObjectPool</code> provides robust pooling functionality for
  * arbitrary objects.</p>
  * <p>
@@ -79,7 +79,7 @@ public class GenericObjectPool<T> extend
      * Create a new <code>GenericObjectPool</code> using defaults from
      * {@link GenericObjectPoolConfig}.
      */
-    public GenericObjectPool(PoolableObjectFactory<T> factory) {
+    public GenericObjectPool(PooledObjectFactory<T> factory) {
         this(factory, new GenericObjectPoolConfig());
     }
 
@@ -92,7 +92,7 @@ public class GenericObjectPool<T> extend
      *                  the configuration object will not be reflected in the
      *                  pool.
      */
-    public GenericObjectPool(PoolableObjectFactory<T> factory,
+    public GenericObjectPool(PooledObjectFactory<T> factory,
             GenericObjectPoolConfig config) {
 
         super(config, ONAME_BASE, config.getJmxNamePrefix());
@@ -119,7 +119,7 @@ public class GenericObjectPool<T> extend
      * @param abandonedConfig  Configuration for abandoned object identification
      *                         and removal.  The configuration is used by value.
      */
-    public GenericObjectPool(PoolableObjectFactory<T> factory,
+    public GenericObjectPool(PooledObjectFactory<T> factory,
             GenericObjectPoolConfig config, AbandonedConfig abandonedConfig) {
         this(factory, config);
         setAbandonedConfig(abandonedConfig);
@@ -319,7 +319,7 @@ public class GenericObjectPool<T> extend
      *
      * @return the factory
      */
-    public PoolableObjectFactory<T> getFactory() {
+    public PooledObjectFactory<T> getFactory() {
         return factory;
     }
 
@@ -433,7 +433,7 @@ public class GenericObjectPool<T> extend
 
             if (p != null) {
                 try {
-                    factory.activateObject(p.getObject());
+                    factory.activateObject(p);
                 } catch (Exception e) {
                     try {
                         destroy(p);
@@ -452,7 +452,7 @@ public class GenericObjectPool<T> extend
                     boolean validate = false;
                     Throwable validationThrowable = null;
                     try {
-                        validate = factory.validateObject(p.getObject());
+                        validate = factory.validateObject(p);
                     } catch (Throwable t) {
                         PoolUtils.checkRethrow(t);
                         validationThrowable = t;
@@ -526,7 +526,7 @@ public class GenericObjectPool<T> extend
         long activeTime = p.getActiveTimeMillis();
 
         if (getTestOnReturn()) {
-            if (!factory.validateObject(obj)) {
+            if (!factory.validateObject(p)) {
                 try {
                     destroy(p);
                 } catch (Exception e) {
@@ -538,7 +538,7 @@ public class GenericObjectPool<T> extend
         }
 
         try {
-            factory.passivateObject(obj);
+            factory.passivateObject(p);
         } catch (Exception e1) {
             swallowException(e1);
             try {
@@ -603,7 +603,7 @@ public class GenericObjectPool<T> extend
     /**
      * Clears any objects sitting idle in the pool by removing them from the
      * idle instance pool and then invoking the configured
-     * {@link PoolableObjectFactory#destroyObject(Object)} method on each idle
+     * {@link PooledObjectFactory#destroyObject(Object)} method on each idle
      * instance.
      * <p>
      * Implementation notes:
@@ -740,19 +740,19 @@ public class GenericObjectPool<T> extend
                         if (testWhileIdle) {
                             boolean active = false;
                             try {
-                                factory.activateObject(underTest.getObject());
+                                factory.activateObject(underTest);
                                 active = true;
                             } catch (Exception e) {
                                 destroy(underTest);
                                 destroyedByEvictorCount.incrementAndGet();
                             }
                             if (active) {
-                                if (!factory.validateObject(underTest.getObject())) {
+                                if (!factory.validateObject(underTest)) {
                                     destroy(underTest);
                                     destroyedByEvictorCount.incrementAndGet();
                                 } else {
                                     try {
-                                        factory.passivateObject(underTest.getObject());
+                                        factory.passivateObject(underTest);
                                     } catch (Exception e) {
                                         destroy(underTest);
                                         destroyedByEvictorCount.incrementAndGet();
@@ -782,22 +782,25 @@ public class GenericObjectPool<T> extend
             return null;
         }
 
-        T t = null;
+        final PooledObject<T> p;
         try {
-            t = factory.makeObject();
+            p = factory.makeObject();
         } catch (Exception e) {
             createCount.decrementAndGet();
             throw e;
         }
 
-        final PooledObject<T> p;
-        if (isAbandonedConfig() && abandonedConfig.getLogAbandoned()) {
-            p = new PooledObjectImpl<T>(t, abandonedConfig.getLogWriter());
-        } else {
-            p = new PooledObjectImpl<T>(t);
+        if (p instanceof PooledObjectImpl) {
+            if (isAbandonedConfig() && abandonedConfig.getLogAbandoned()) {
+                ((PooledObjectImpl<T> )p).setAbandonedLoqWriter(
+                        abandonedConfig.getLogWriter());
+            } else {
+                ((PooledObjectImpl<T> )p).setAbandonedLoqWriter(null);
+            }
         }
+
         createdCount.incrementAndGet();
-        allObjects.put(t, p);
+        allObjects.put(p.getObject(), p);
         return p;
     }
 
@@ -806,7 +809,7 @@ public class GenericObjectPool<T> extend
         idleObjects.remove(toDestory);
         allObjects.remove(toDestory.getObject());
         try {
-            factory.destroyObject(toDestory.getObject());
+            factory.destroyObject(toDestory);
         } finally {
             destroyedCount.incrementAndGet();
             createCount.decrementAndGet();
@@ -852,7 +855,7 @@ public class GenericObjectPool<T> extend
 
     private void addIdleObject(PooledObject<T> p) throws Exception {
         if (p != null) {
-            factory.passivateObject(p.getObject());
+            factory.passivateObject(p);
             if (getLifo()) {
                 idleObjects.addFirst(p);
             } else {
@@ -929,7 +932,7 @@ public class GenericObjectPool<T> extend
 
     private volatile int maxIdle = GenericObjectPoolConfig.DEFAULT_MAX_IDLE;
     private volatile int minIdle = GenericObjectPoolConfig.DEFAULT_MIN_IDLE;
-    private final PoolableObjectFactory<T> factory;
+    private final PooledObjectFactory<T> factory;
 
 
     // --- internal attributes -------------------------------------------------

Added: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java?rev=1506685&view=auto
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java (added)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java Wed Jul 24 20:01:34 2013
@@ -0,0 +1,107 @@
+package org.apache.commons.pool2.impl;
+
+import org.apache.commons.pool2.KeyedPoolableObjectFactory;
+import org.apache.commons.pool2.KeyedPooledObjectFactory;
+import org.apache.commons.pool2.PoolableObjectFactory;
+import org.apache.commons.pool2.PooledObject;
+import org.apache.commons.pool2.PooledObjectFactory;
+
+/**
+ * Implementation specific utilities.
+ */
+public class PoolImplUtils {
+
+    /**
+     * Wraps a {@link PoolableObjectFactory} to convert it into a
+     * {@link PooledObjectFactory}.
+     */
+    public static <T> PooledObjectFactory<T> poolableToPooledObjectFactory(
+            PoolableObjectFactory<T> innerFactory) {
+        return new PoolableObjectFactoryWrapper<T>(innerFactory);
+    }
+
+
+    /**
+     * Wraps a {@link KeyedPoolableObjectFactory} to convert it into a
+     * {@link KeyedPooledObjectFactory}.
+     */
+    public static <K,V> KeyedPooledObjectFactory<K,V> poolableToKeyedPooledObjectFactory(
+            KeyedPoolableObjectFactory<K,V> innerFactory) {
+        return new KeyedPoolableObjectFactoryWrapper<K,V>(innerFactory);
+    }
+
+
+    private static class PoolableObjectFactoryWrapper<T>
+            implements PooledObjectFactory<T> {
+
+        private final PoolableObjectFactory<T> innerFactory;
+
+        public PoolableObjectFactoryWrapper(PoolableObjectFactory<T> innerFactory) {
+            this.innerFactory = innerFactory;
+        }
+
+        @Override
+        public PooledObject<T> makeObject() throws Exception {
+            return new PooledObjectImpl<T>(innerFactory.makeObject());
+        }
+
+        @Override
+        public void destroyObject(PooledObject<T> p) throws Exception {
+            innerFactory.destroyObject(p.getObject());
+        }
+
+        @Override
+        public boolean validateObject(PooledObject<T> p) {
+            return innerFactory.validateObject(p.getObject());
+        }
+
+        @Override
+        public void activateObject(PooledObject<T> p) throws Exception {
+            innerFactory.activateObject(p.getObject());
+        }
+
+        @Override
+        public void passivateObject(PooledObject<T> p) throws Exception {
+            innerFactory.passivateObject(p.getObject());
+        }
+    }
+
+
+    private static class KeyedPoolableObjectFactoryWrapper<K,V>
+            implements KeyedPooledObjectFactory<K,V> {
+
+        private final KeyedPoolableObjectFactory<K,V> innerFactory;
+
+        public KeyedPoolableObjectFactoryWrapper(
+                KeyedPoolableObjectFactory<K,V> innerFactory) {
+            this.innerFactory = innerFactory;
+        }
+
+        @Override
+        public PooledObject<V> makeObject(K key) throws Exception {
+            V obj = innerFactory.makeObject(key);
+            return new PooledObjectImpl<V>(obj);
+        }
+
+        @Override
+        public void destroyObject(K key, PooledObject<V> p) throws Exception {
+            innerFactory.destroyObject(key, p.getObject());
+        }
+
+        @Override
+        public boolean validateObject(K key, PooledObject<V> p) {
+            return innerFactory.validateObject(key, p.getObject());
+        }
+
+        @Override
+        public void activateObject(K key, PooledObject<V> p) throws Exception {
+            innerFactory.activateObject(key, p.getObject());
+        }
+
+        @Override
+        public void passivateObject(K key, PooledObject<V> p)
+                throws Exception {
+            innerFactory.passivateObject(key, p.getObject());
+        }
+    }
+}

Propchange: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PoolImplUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java?rev=1506685&r1=1506684&r2=1506685&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java (original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObjectImpl.java Wed Jul 24 20:01:34 2013
@@ -20,6 +20,7 @@ import java.io.PrintWriter;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Deque;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.commons.pool2.PooledObject;
 import org.apache.commons.pool2.PooledObjectState;
@@ -44,19 +45,12 @@ public class PooledObjectImpl<T> impleme
     private final long createTime = System.currentTimeMillis();
     private volatile long lastBorrowTime = createTime;
     private volatile long lastReturnTime = createTime;
-    private final Exception createdBy;
-    private final PrintWriter logWriter;
+    private AtomicBoolean abandonedLogConfigured = new AtomicBoolean(false);
+    private Exception createdBy = null;
+    private PrintWriter logWriter = null;
 
     public PooledObjectImpl(T object) {
         this.object = object;
-        createdBy = null;
-        logWriter = null;
-    }
-
-    public PooledObjectImpl(T object, PrintWriter logWriter) {
-        this.object = object;
-        this.logWriter = logWriter;
-        createdBy = new AbandonedObjectException();
     }
 
     /**
@@ -296,6 +290,19 @@ public class PooledObjectImpl<T> impleme
         state = PooledObjectState.RETURNING;
     }
 
+    /**
+     * Only has an effect on the first invocation. Subsequent invocations are
+     * ignored.
+     */
+    void setAbandonedLoqWriter(PrintWriter logWriter) {
+        if (abandonedLogConfigured.compareAndSet(false, true)) {
+            if (logWriter != null) {
+                this.logWriter = logWriter;
+                createdBy = new AbandonedObjectException();
+            }
+        }
+    }
+
     static class AbandonedObjectException extends Exception {
 
         private static final long serialVersionUID = 7398692158058772916L;

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java?rev=1506685&r1=1506684&r2=1506685&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/TestPoolUtils.java Wed Jul 24 20:01:34 2013
@@ -38,6 +38,7 @@ import junit.framework.AssertionFailedEr
 
 import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
 import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.PoolImplUtils;
 import org.junit.Test;
 
 /**
@@ -83,7 +84,8 @@ public class TestPoolUtils {
         // Test that the minIdle check doesn't add too many idle objects
         @SuppressWarnings("unchecked")
         final PoolableObjectFactory<Object> pof = createProxy(PoolableObjectFactory.class, calledMethods);
-        final ObjectPool<Object> op = new GenericObjectPool<Object>(pof);
+        final ObjectPool<Object> op = new GenericObjectPool<Object>(
+                PoolImplUtils.poolableToPooledObjectFactory(pof));
         PoolUtils.checkMinIdle(op, 2, 100);
         Thread.sleep(400);
         assertEquals(2, op.getNumIdle());
@@ -162,7 +164,8 @@ public class TestPoolUtils {
         final KeyedPoolableObjectFactory<Object,Object> kpof =
             createProxy(KeyedPoolableObjectFactory.class, calledMethods);
         final KeyedObjectPool<Object,Object> kop =
-            new GenericKeyedObjectPool<Object,Object>(kpof);
+                new GenericKeyedObjectPool<Object,Object>(
+                        PoolImplUtils.poolableToKeyedPooledObjectFactory(kpof));
         PoolUtils.checkMinIdle(kop, key, 2, 100);
         Thread.sleep(400);
         assertEquals(2, kop.getNumIdle(key));

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java?rev=1506685&r1=1506684&r2=1506685&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestAbandonedObjectPool.java Wed Jul 24 20:01:34 2013
@@ -50,7 +50,9 @@ public class TestAbandonedObjectPool ext
         abandonedConfig.setRemoveAbandonedOnBorrow(true);
         abandonedConfig.setRemoveAbandonedTimeout(1);
         pool = new GenericObjectPool<PooledTestObject>(
-               new SimpleFactory(), new GenericObjectPoolConfig(), abandonedConfig);
+                PoolImplUtils.poolableToPooledObjectFactory(new SimpleFactory()),
+               new GenericObjectPoolConfig(),
+               abandonedConfig);
     }
 
     @Override
@@ -137,7 +139,7 @@ public class TestAbandonedObjectPool ext
         abandonedConfig.setRemoveAbandonedTimeout(1);
         pool.close();  // Unregister pool created by setup
         pool = new GenericObjectPool<PooledTestObject>(
-                new SimpleFactory(200, 0),
+                PoolImplUtils.poolableToPooledObjectFactory(new SimpleFactory(200, 0)),
                 new GenericObjectPoolConfig(), abandonedConfig);
         final int n = 10;
         pool.setMaxTotal(n);
@@ -169,7 +171,8 @@ public class TestAbandonedObjectPool ext
         abandonedConfig.setRemoveAbandonedTimeout(1);
         pool.close();  // Unregister pool created by setup
         pool = new GenericObjectPool<PooledTestObject>(
-                new SimpleFactory(200, 0),  // destroys take 200 ms
+                // destroys take 200 ms
+                PoolImplUtils.poolableToPooledObjectFactory(new SimpleFactory(200, 0)),
                 new GenericObjectPoolConfig(), abandonedConfig);
         final int n = 10;
         pool.setMaxTotal(n);
@@ -196,7 +199,8 @@ public class TestAbandonedObjectPool ext
         abandonedConfig.setRemoveAbandonedTimeout(1);
         pool.close();  // Unregister pool created by setup
         pool = new GenericObjectPool<PooledTestObject>(
-                new SimpleFactory(0, 1000),  // validate takes 1 second
+             // validate takes 1 second
+                PoolImplUtils.poolableToPooledObjectFactory(new SimpleFactory(0, 1000)),
                 new GenericObjectPoolConfig(), abandonedConfig);
         final int n = 10;
         pool.setMaxTotal(n);

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1506685&r1=1506684&r2=1506685&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Wed Jul 24 20:01:34 2013
@@ -87,7 +87,8 @@ public class TestGenericKeyedObjectPool 
         };
 
         GenericKeyedObjectPool<Object,Object> pool =
-            new GenericKeyedObjectPool<Object,Object>(factory);
+            new GenericKeyedObjectPool<Object,Object>(
+                    PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         pool.setMaxTotalPerKey(mincapacity);
         pool.setMaxIdlePerKey(mincapacity);
         return pool;
@@ -96,7 +97,8 @@ public class TestGenericKeyedObjectPool 
     @Override
     protected KeyedObjectPool<Object,Object> makeEmptyPool(KeyedPoolableObjectFactory<Object,Object> factory) {
         GenericKeyedObjectPool<Object,Object> pool =
-            new GenericKeyedObjectPool<Object,Object>(factory);
+            new GenericKeyedObjectPool<Object,Object>(
+                    PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         return pool;
     }
 
@@ -119,7 +121,8 @@ public class TestGenericKeyedObjectPool 
     @Before
     public void setUp() throws Exception {
         factory = new SimpleFactory<String>();
-        pool = new GenericKeyedObjectPool<String,String>(factory);
+        pool = new GenericKeyedObjectPool<String,String>(
+                PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
     }
 
     @Override
@@ -746,7 +749,8 @@ public class TestGenericKeyedObjectPool 
     private void checkEvictionOrder(boolean lifo) throws Exception {
         SimpleFactory<Integer> factory = new SimpleFactory<Integer>();
         GenericKeyedObjectPool<Integer,String> pool =
-            new GenericKeyedObjectPool<Integer,String>(factory);
+            new GenericKeyedObjectPool<Integer,String>(
+                    PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(100);
         pool.setLifo(lifo);
@@ -870,7 +874,8 @@ public class TestGenericKeyedObjectPool 
     private void checkEvictorVisiting(boolean lifo) throws Exception {
         VisitTrackerFactory<Integer> factory = new VisitTrackerFactory<Integer>();
         GenericKeyedObjectPool<Integer,VisitTracker<Integer>> pool =
-            new GenericKeyedObjectPool<Integer,VisitTracker<Integer>>(factory);
+            new GenericKeyedObjectPool<Integer,VisitTracker<Integer>>(
+                    PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(-1);
         pool.setTestWhileIdle(true);
@@ -959,7 +964,7 @@ public class TestGenericKeyedObjectPool 
                 // a new pool
                 factory = new VisitTrackerFactory<Integer>();
                 pool = new GenericKeyedObjectPool<Integer,VisitTracker<Integer>>(
-                        factory);
+                        PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
                 pool.setMaxIdlePerKey(-1);
                 pool.setMaxTotalPerKey(-1);
                 pool.setNumTestsPerEvictionRun(smallPrimes[i]);
@@ -1062,7 +1067,8 @@ public class TestGenericKeyedObjectPool 
         };
 
         GenericKeyedObjectPool<Object,Object> pool =
-            new GenericKeyedObjectPool<Object,Object>(factory);
+                new GenericKeyedObjectPool<Object,Object>(
+                        PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL_PER_KEY, pool.getMaxTotalPerKey());
         assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MAX_IDLE_PER_KEY, pool.getMaxIdlePerKey());
         assertEquals(GenericKeyedObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS, pool.getMaxWaitMillis());
@@ -1100,7 +1106,8 @@ public class TestGenericKeyedObjectPool 
         config.setTestWhileIdle(testWhileIdle);
         config.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
         config.setBlockWhenExhausted(blockWhenExhausted);
-        pool = new GenericKeyedObjectPool<Object,Object>(factory, config);
+        pool = new GenericKeyedObjectPool<Object,Object>(
+                PoolImplUtils.poolableToKeyedPooledObjectFactory(factory), config);
         assertEquals(maxTotalPerKey, pool.getMaxTotalPerKey());
         assertEquals(maxIdle, pool.getMaxIdlePerKey());
         assertEquals(maxWait, pool.getMaxWaitMillis());
@@ -1131,7 +1138,8 @@ public class TestGenericKeyedObjectPool 
     public void testExceptionOnPassivateDuringReturn() throws Exception {
         SimpleFactory<String> factory = new SimpleFactory<String>();
         GenericKeyedObjectPool<String,String> pool =
-            new GenericKeyedObjectPool<String,String>(factory);
+                new GenericKeyedObjectPool<String,String>(
+                        PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         String obj = pool.borrowObject("one");
         factory.setThrowExceptionOnPassivate(true);
         pool.returnObject("one", obj);
@@ -1303,7 +1311,8 @@ public class TestGenericKeyedObjectPool 
         // TODO Fix this. Can't use local pool since runTestThreads uses the
         //      protected pool field
         GenericKeyedObjectPool<String,Waiter> pool =
-            new GenericKeyedObjectPool<String,Waiter>(factory);
+                new GenericKeyedObjectPool<String,Waiter>(
+                        PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         pool.setMaxTotalPerKey(5);
         pool.setMaxTotal(8);
         pool.setTestOnBorrow(true);
@@ -1321,7 +1330,8 @@ public class TestGenericKeyedObjectPool 
         // Make destroy have some latency so clearOldest takes some time
         WaiterFactory<String> factory = new WaiterFactory<String>(0, 20, 0, 0, 0, 0, 50, 5, 0);
         GenericKeyedObjectPool<String,Waiter> pool =
-            new GenericKeyedObjectPool<String,Waiter>(factory);
+                new GenericKeyedObjectPool<String,Waiter>(
+                        PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         pool.setMaxTotalPerKey(5);
         pool.setMaxTotal(50);
         pool.setLifo(false);
@@ -1380,7 +1390,8 @@ public class TestGenericKeyedObjectPool 
     public void testClear() throws Exception {
         SimpleFactory<String> factory = new SimpleFactory<String>();
         GenericKeyedObjectPool<String,String> pool =
-            new GenericKeyedObjectPool<String,String>(factory);
+                new GenericKeyedObjectPool<String,String>(
+                        PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         pool.setMaxTotal(2);
         pool.setMaxTotalPerKey(2);
         pool.setBlockWhenExhausted(false);
@@ -1409,7 +1420,8 @@ public class TestGenericKeyedObjectPool 
     public void testWhenExhaustedBlockClosePool() throws Exception {
         SimpleFactory<String> factory = new SimpleFactory<String>();
         GenericKeyedObjectPool<String,String> pool =
-            new GenericKeyedObjectPool<String,String>(factory);
+                new GenericKeyedObjectPool<String,String>(
+                        PoolImplUtils.poolableToKeyedPooledObjectFactory(factory));
         pool.setMaxTotalPerKey(1);
         pool.setBlockWhenExhausted(true);
         pool.setMaxWaitMillis(-1);

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1506685&r1=1506684&r2=1506685&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java Wed Jul 24 20:01:34 2013
@@ -57,7 +57,9 @@ public class TestGenericObjectPool exten
     @Override
     protected ObjectPool<Object> makeEmptyPool(int mincap) {
        GenericObjectPool<Object> pool =
-           new GenericObjectPool<Object>(new SimpleFactory());
+               new GenericObjectPool<Object>(
+                       PoolImplUtils.poolableToPooledObjectFactory(
+                               new SimpleFactory()));
        pool.setMaxTotal(mincap);
        pool.setMaxIdle(mincap);
        return pool;
@@ -66,7 +68,8 @@ public class TestGenericObjectPool exten
     @Override
     protected ObjectPool<Object> makeEmptyPool(
             final PoolableObjectFactory<Object> factory) {
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(
+                PoolImplUtils.poolableToPooledObjectFactory(factory));
         return pool;
     }
 
@@ -78,7 +81,8 @@ public class TestGenericObjectPool exten
     @Before
     public void setUp() throws Exception {
         factory = new SimpleFactory();
-        pool = new GenericObjectPool<Object>(factory);
+        pool = new GenericObjectPool<Object>(
+                PoolImplUtils.poolableToPooledObjectFactory(factory));
     }
 
     @After
@@ -140,7 +144,8 @@ public class TestGenericObjectPool exten
         };
 
         GenericObjectPool<Object> pool =
-            new GenericObjectPool<Object>(factory);
+                new GenericObjectPool<Object>(
+                        PoolImplUtils.poolableToPooledObjectFactory(factory));
         assertEquals(GenericObjectPoolConfig.DEFAULT_MAX_IDLE, pool.getMaxIdle());
         assertEquals(GenericObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS, pool.getMaxWaitMillis());
         assertEquals(GenericObjectPoolConfig.DEFAULT_MIN_IDLE, pool.getMinIdle());
@@ -176,7 +181,8 @@ public class TestGenericObjectPool exten
         config.setTestWhileIdle(testWhileIdle);
         config.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
         config.setBlockWhenExhausted(blockWhenExhausted);
-        pool = new GenericObjectPool<Object>(factory, config);
+        pool = new GenericObjectPool<Object>(
+                PoolImplUtils.poolableToPooledObjectFactory(factory), config);
         assertEquals(maxIdle, pool.getMaxIdle());
         assertEquals(maxWait, pool.getMaxWaitMillis());
         assertEquals(minIdle, pool.getMinIdle());
@@ -398,7 +404,8 @@ public class TestGenericObjectPool exten
     private void checkEvictorVisiting(boolean lifo) throws Exception {
         VisitTrackerFactory<Object> factory = new VisitTrackerFactory<Object>();
         GenericObjectPool<VisitTracker<Object>> pool =
-            new GenericObjectPool<VisitTracker<Object>>(factory);
+                new GenericObjectPool<VisitTracker<Object>>(
+                        PoolImplUtils.poolableToPooledObjectFactory(factory));
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(-1);
         pool.setTestWhileIdle(true);
@@ -431,7 +438,8 @@ public class TestGenericObjectPool exten
         pool.close();
 
         factory = new VisitTrackerFactory<Object>();
-        pool = new GenericObjectPool<VisitTracker<Object>>(factory);
+        pool = new GenericObjectPool<VisitTracker<Object>>(
+                PoolImplUtils.poolableToPooledObjectFactory(factory));
         pool.setNumTestsPerEvictionRun(3);
         pool.setMinEvictableIdleTimeMillis(-1);
         pool.setTestWhileIdle(true);
@@ -476,7 +484,8 @@ public class TestGenericObjectPool exten
         random.setSeed(System.currentTimeMillis());
         for (int i = 0; i < 4; i++) {
             for (int j = 0; j < 5; j++) {
-                pool = new GenericObjectPool<VisitTracker<Object>>(factory);
+                pool = new GenericObjectPool<VisitTracker<Object>>(
+                        PoolImplUtils.poolableToPooledObjectFactory(factory));
                 pool.setNumTestsPerEvictionRun(smallPrimes[i]);
                 pool.setMinEvictableIdleTimeMillis(-1);
                 pool.setTestWhileIdle(true);
@@ -1005,7 +1014,9 @@ public class TestGenericObjectPool exten
         }
 
         GenericObjectPool<TimeTest> pool =
-            new GenericObjectPool<TimeTest>(new TimeTest());
+                new GenericObjectPool<TimeTest>(
+                        PoolImplUtils.poolableToPooledObjectFactory(
+                                new TimeTest()));
 
         pool.setMaxIdle(5);
         pool.setMaxTotal(5);
@@ -1058,7 +1069,9 @@ public class TestGenericObjectPool exten
         }
 
         final GenericObjectPool<Object> pool =
-            new GenericObjectPool<Object>(new InvalidFactory());
+                new GenericObjectPool<Object>(
+                        PoolImplUtils.poolableToPooledObjectFactory(
+                                new InvalidFactory()));
 
         pool.setMaxIdle(1);
         pool.setMaxTotal(1);

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java?rev=1506685&r1=1506684&r2=1506685&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPoolClassLoaders.java Wed Jul 24 20:01:34 2013
@@ -39,7 +39,9 @@ public class TestGenericObjectPoolClassL
             Thread.currentThread().setContextClassLoader(cl1);
             CustomClassLoaderObjectFactory factory1 =
                     new CustomClassLoaderObjectFactory(1);
-            GenericObjectPool<URL> pool1 = new GenericObjectPool<URL>(factory1);
+            GenericObjectPool<URL> pool1 =
+                    new GenericObjectPool<URL>(
+                            PoolImplUtils.poolableToPooledObjectFactory(factory1));
             pool1.setMinIdle(1);
             pool1.setTimeBetweenEvictionRunsMillis(100);
             int counter = 0;
@@ -55,7 +57,9 @@ public class TestGenericObjectPoolClassL
             Thread.currentThread().setContextClassLoader(cl2);
             CustomClassLoaderObjectFactory factory2 =
                     new CustomClassLoaderObjectFactory(2);
-            GenericObjectPool<URL> pool2 = new GenericObjectPool<URL>(factory2);
+            GenericObjectPool<URL> pool2 =
+                    new GenericObjectPool<URL>(
+                            PoolImplUtils.poolableToPooledObjectFactory(factory2));
             pool2.setMinIdle(1);
 
             pool2.addObject();
@@ -64,7 +68,7 @@ public class TestGenericObjectPoolClassL
             pool2.clear();
 
             pool2.setTimeBetweenEvictionRunsMillis(100);
-            
+
             counter = 0;
             while (counter < 50 && pool2.getNumIdle() != 1) {
                 Thread.sleep(100);

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java?rev=1506685&r1=1506684&r2=1506685&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java (original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/performance/PerformanceTest.java Wed Jul 24 20:01:34 2013
@@ -26,6 +26,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
 import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.PoolImplUtils;
 
 /**
  * Multi-thread performance test
@@ -114,7 +115,8 @@ public class PerformanceTest {
 
         SleepingObjectFactory factory = new SleepingObjectFactory();
         if (logLevel >= 4) { factory.setDebug(true); }
-        pool = new GenericObjectPool<Integer>(factory);
+        pool = new GenericObjectPool<Integer>(
+                PoolImplUtils.poolableToPooledObjectFactory(factory));
         pool.setMaxTotal(maxTotal);
         pool.setMaxIdle(maxIdle);
         pool.setTestOnBorrow(true);



Re: [pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Phil Steitz <ph...@gmail.com>.
On 8/4/13 9:27 AM, Phil Steitz wrote:
> On 8/4/13 7:24 AM, Mark Thomas wrote:
>> On 03/08/2013 17:15, Phil Steitz wrote:
>>> On 7/30/13 9:16 AM, Phil Steitz wrote:
>>>> I have started working on this.  Should have something to commit at
>>>> least for GOP in the next day or two.
>>> I am stuck on SoftReferenceObectPool. 
>> :(
>>
>>> I have been able to handle
>>> everything else collapsing down to just Pooled(Keyed)ObjectFactory /
>>> Base(Keyed)ObjectPool.
>> Excellent.
>>
>>> To stick with (and get factory / monitoring
>>> benefits of) PooledObjectFactory / PooledObjects, I need to create a
>>> version of DefaultPooledObject that wraps SoftReferences and these
>>> have to be mutable - i.e., when an instance is returned a new soft
>>> reference is created and stored in the pool, but we want to maintain
>>> PooledObject state.  To do this, I need to be able to recognize the
>>> returning object.  I could do this by searching the pool, but that
>>> will cost something.  On the other hand, the lack of search now
>>> means returnObject is not idempotent (like it is in the rest of the
>>> 2.0 pools).  Multiple returns will put multiple soft references to
>>> the same object in the pool.
>>>
>>> So, I would appreciate some feedback on the following options:
>>>
>>> 1) Add a search for the returning object and create a
>>> PooledSoftReference subclass of DefaultPooledObject within
>>> SoftReferencePool to be stored in the pool.
>>>
>>> 2) Keep PoolableObjectFactory just for this pool and leave it alone,
>>> adding a warning to returnObject (not a new issue, just different
>>> from other 2.0 pools).
>> I think the benefits of the monitoring justify adding the search so my
>> preference is for option 1.
> Drat, I thought I was going to get away with 2) - he he.  I will
> plow ahead with 1 :)

OK, done now.  All tests pass.  I am just cleaning up javadoc and
will commit in next 24 hours.  I have not added JMX stuff to
SoftReferenceObjectPool, but will do that after committing the
initial refactoring.  I also did not clean up the complete sync and
spurious notifies in SoftReferenceObjectPool.  That can also be
looked at next.  More observations on this class to follow post-commit.

Phil
>
> Phil
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Phil Steitz <ph...@gmail.com>.
On 8/4/13 7:24 AM, Mark Thomas wrote:
> On 03/08/2013 17:15, Phil Steitz wrote:
>> On 7/30/13 9:16 AM, Phil Steitz wrote:
>>> I have started working on this.  Should have something to commit at
>>> least for GOP in the next day or two.
>> I am stuck on SoftReferenceObectPool. 
> :(
>
>> I have been able to handle
>> everything else collapsing down to just Pooled(Keyed)ObjectFactory /
>> Base(Keyed)ObjectPool.
> Excellent.
>
>> To stick with (and get factory / monitoring
>> benefits of) PooledObjectFactory / PooledObjects, I need to create a
>> version of DefaultPooledObject that wraps SoftReferences and these
>> have to be mutable - i.e., when an instance is returned a new soft
>> reference is created and stored in the pool, but we want to maintain
>> PooledObject state.  To do this, I need to be able to recognize the
>> returning object.  I could do this by searching the pool, but that
>> will cost something.  On the other hand, the lack of search now
>> means returnObject is not idempotent (like it is in the rest of the
>> 2.0 pools).  Multiple returns will put multiple soft references to
>> the same object in the pool.
>>
>> So, I would appreciate some feedback on the following options:
>>
>> 1) Add a search for the returning object and create a
>> PooledSoftReference subclass of DefaultPooledObject within
>> SoftReferencePool to be stored in the pool.
>>
>> 2) Keep PoolableObjectFactory just for this pool and leave it alone,
>> adding a warning to returnObject (not a new issue, just different
>> from other 2.0 pools).
> I think the benefits of the monitoring justify adding the search so my
> preference is for option 1.

Drat, I thought I was going to get away with 2) - he he.  I will
plow ahead with 1 :)

Phil
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Mark Thomas <ma...@apache.org>.
On 03/08/2013 17:15, Phil Steitz wrote:
> On 7/30/13 9:16 AM, Phil Steitz wrote:
>> I have started working on this.  Should have something to commit at
>> least for GOP in the next day or two.
> 
> I am stuck on SoftReferenceObectPool. 

:(

> I have been able to handle
> everything else collapsing down to just Pooled(Keyed)ObjectFactory /
> Base(Keyed)ObjectPool.

Excellent.

> To stick with (and get factory / monitoring
> benefits of) PooledObjectFactory / PooledObjects, I need to create a
> version of DefaultPooledObject that wraps SoftReferences and these
> have to be mutable - i.e., when an instance is returned a new soft
> reference is created and stored in the pool, but we want to maintain
> PooledObject state.  To do this, I need to be able to recognize the
> returning object.  I could do this by searching the pool, but that
> will cost something.  On the other hand, the lack of search now
> means returnObject is not idempotent (like it is in the rest of the
> 2.0 pools).  Multiple returns will put multiple soft references to
> the same object in the pool.
> 
> So, I would appreciate some feedback on the following options:
> 
> 1) Add a search for the returning object and create a
> PooledSoftReference subclass of DefaultPooledObject within
> SoftReferencePool to be stored in the pool.
> 
> 2) Keep PoolableObjectFactory just for this pool and leave it alone,
> adding a warning to returnObject (not a new issue, just different
> from other 2.0 pools).

I think the benefits of the monitoring justify adding the search so my
preference is for option 1.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Phil Steitz <ph...@gmail.com>.
On 7/30/13 9:16 AM, Phil Steitz wrote:
> I have started working on this.  Should have something to commit at
> least for GOP in the next day or two.

I am stuck on SoftReferenceObectPool.  I have been able to handle
everything else collapsing down to just Pooled(Keyed)ObjectFactory /
Base(Keyed)ObjectPool.  To stick with (and get factory / monitoring
benefits of) PooledObjectFactory / PooledObjects, I need to create a
version of DefaultPooledObject that wraps SoftReferences and these
have to be mutable - i.e., when an instance is returned a new soft
reference is created and stored in the pool, but we want to maintain
PooledObject state.  To do this, I need to be able to recognize the
returning object.  I could do this by searching the pool, but that
will cost something.  On the other hand, the lack of search now
means returnObject is not idempotent (like it is in the rest of the
2.0 pools).  Multiple returns will put multiple soft references to
the same object in the pool.

So, I would appreciate some feedback on the following options:

1) Add a search for the returning object and create a
PooledSoftReference subclass of DefaultPooledObject within
SoftReferencePool to be stored in the pool.

2) Keep PoolableObjectFactory just for this pool and leave it alone,
adding a warning to returnObject (not a new issue, just different
from other 2.0 pools).

Phil
>
> Phil
>
> On 7/29/13 10:56 AM, Phil Steitz wrote:
>> On 7/24/13 1:06 PM, Mark Thomas wrote:
>>> On 24/07/2013 21:01, markt@apache.org wrote:
>>>> Author: markt
>>>> Date: Wed Jul 24 20:01:34 2013
>>>> New Revision: 1506685
>>>>
>>>> URL: http://svn.apache.org/r1506685
>>>> Log:
>>>> Create two new factory interfaces that work with PooledObject instances rather than Object instances and switch Gop and GKOP to use them.
>>> One area I'd particularly like some comment on is PooledObject &
>>> PooledObjectImpl.
>>>
>>> I considered just having a single PooledObject implementation class in
>>> o.a.c.pool2 but decided that as implementation it belonged in
>>> o.a.c.pool2.impl. That lead to needing PoolImplUtils.
>>>
>>> I'm not completely happy with the current arrangement but neither have a
>>> found a better one. Thoughts?
>> I wonder if we really want / need to retain the original "dumb" (not
>> in the sense of bad design, but no tracking) pooling infrastructure
>> from 1.x.  Thinking about making it easy for users to grokk the
>> setup and get a GOP or GKOP working, I wonder if it might be better
>> to drop the base classes and just start with simple, refactored pool
>> and factory interfaces that create and manage PooledObjects
>> directly.  Users will still only absolutely *have* to implement
>> makeObject in their factories and the default code will take care of
>> everything else.  So you just end up with PoolableObjectFactories
>> sourcing and managing PooledObjects.  GOP, GKOP still return
>> unwrapped objects via borrow and there is an
>> AbstractPoolableObjectFactory with makeObject abstract and the rest
>> provided.  I have not played with this yet (hopefully will have some
>> time in the next couple of days), but I wonder if it might not be
>> better / simpler.  Also, adding methods to GOP, GKOP that return
>> PooledObject instances (maybe stripped down) might be useful to
>> clients.  Sorry if above is naive / old ground.  I just want to make
>> sure what we end up with is a simple as possible.
>>
>> Phil
>>> Mark
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>
>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Phil Steitz <ph...@gmail.com>.
I have started working on this.  Should have something to commit at
least for GOP in the next day or two.

Phil

On 7/29/13 10:56 AM, Phil Steitz wrote:
> On 7/24/13 1:06 PM, Mark Thomas wrote:
>> On 24/07/2013 21:01, markt@apache.org wrote:
>>> Author: markt
>>> Date: Wed Jul 24 20:01:34 2013
>>> New Revision: 1506685
>>>
>>> URL: http://svn.apache.org/r1506685
>>> Log:
>>> Create two new factory interfaces that work with PooledObject instances rather than Object instances and switch Gop and GKOP to use them.
>> One area I'd particularly like some comment on is PooledObject &
>> PooledObjectImpl.
>>
>> I considered just having a single PooledObject implementation class in
>> o.a.c.pool2 but decided that as implementation it belonged in
>> o.a.c.pool2.impl. That lead to needing PoolImplUtils.
>>
>> I'm not completely happy with the current arrangement but neither have a
>> found a better one. Thoughts?
> I wonder if we really want / need to retain the original "dumb" (not
> in the sense of bad design, but no tracking) pooling infrastructure
> from 1.x.  Thinking about making it easy for users to grokk the
> setup and get a GOP or GKOP working, I wonder if it might be better
> to drop the base classes and just start with simple, refactored pool
> and factory interfaces that create and manage PooledObjects
> directly.  Users will still only absolutely *have* to implement
> makeObject in their factories and the default code will take care of
> everything else.  So you just end up with PoolableObjectFactories
> sourcing and managing PooledObjects.  GOP, GKOP still return
> unwrapped objects via borrow and there is an
> AbstractPoolableObjectFactory with makeObject abstract and the rest
> provided.  I have not played with this yet (hopefully will have some
> time in the next couple of days), but I wonder if it might not be
> better / simpler.  Also, adding methods to GOP, GKOP that return
> PooledObject instances (maybe stripped down) might be useful to
> clients.  Sorry if above is naive / old ground.  I just want to make
> sure what we end up with is a simple as possible.
>
> Phil
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Phil Steitz <ph...@gmail.com>.
On 7/29/13 11:11 AM, Mark Thomas wrote:
> On 29/07/2013 19:56, Phil Steitz wrote:
>> On 7/24/13 1:06 PM, Mark Thomas wrote:
>>> On 24/07/2013 21:01, markt@apache.org wrote:
>>>> Author: markt
>>>> Date: Wed Jul 24 20:01:34 2013
>>>> New Revision: 1506685
>>>>
>>>> URL: http://svn.apache.org/r1506685
>>>> Log:
>>>> Create two new factory interfaces that work with PooledObject instances rather than Object instances and switch Gop and GKOP to use them.
>>> One area I'd particularly like some comment on is PooledObject &
>>> PooledObjectImpl.
>>>
>>> I considered just having a single PooledObject implementation class in
>>> o.a.c.pool2 but decided that as implementation it belonged in
>>> o.a.c.pool2.impl. That lead to needing PoolImplUtils.
>>>
>>> I'm not completely happy with the current arrangement but neither have a
>>> found a better one. Thoughts?
>> I wonder if we really want / need to retain the original "dumb" (not
>> in the sense of bad design, but no tracking) pooling infrastructure
>> from 1.x.  Thinking about making it easy for users to grokk the
>> setup and get a GOP or GKOP working, I wonder if it might be better
>> to drop the base classes and just start with simple, refactored pool
>> and factory interfaces that create and manage PooledObjects
>> directly.  Users will still only absolutely *have* to implement
>> makeObject in their factories and the default code will take care of
>> everything else.  So you just end up with PoolableObjectFactories
>> sourcing and managing PooledObjects.  GOP, GKOP still return
>> unwrapped objects via borrow and there is an
>> AbstractPoolableObjectFactory with makeObject abstract and the rest
>> provided.  I have not played with this yet (hopefully will have some
>> time in the next couple of days), but I wonder if it might not be
>> better / simpler.  Also, adding methods to GOP, GKOP that return
>> PooledObject instances (maybe stripped down) might be useful to
>> clients.  Sorry if above is naive / old ground.  I just want to make
>> sure what we end up with is a simple as possible.
> That is certainly do-able. The question is what does it mean for the
> various implementations like SoftReferenceObjectPool and those provided
> by PoolUtils.
>
> If there are implementations there are are no longer required or
> rendered obsolete by the Pool2 impl then a big +1 from me to removing them.

No reason the ones we keep could not be modified to use the new
setup.  I have not taken a close look at all of the aminals in the
PoolUtils zoo recently, but I bet a lot of them are obsolete in the
2.0 world.

Phil
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Mark Thomas <ma...@apache.org>.
On 29/07/2013 19:56, Phil Steitz wrote:
> On 7/24/13 1:06 PM, Mark Thomas wrote:
>> On 24/07/2013 21:01, markt@apache.org wrote:
>>> Author: markt
>>> Date: Wed Jul 24 20:01:34 2013
>>> New Revision: 1506685
>>>
>>> URL: http://svn.apache.org/r1506685
>>> Log:
>>> Create two new factory interfaces that work with PooledObject instances rather than Object instances and switch Gop and GKOP to use them.
>> One area I'd particularly like some comment on is PooledObject &
>> PooledObjectImpl.
>>
>> I considered just having a single PooledObject implementation class in
>> o.a.c.pool2 but decided that as implementation it belonged in
>> o.a.c.pool2.impl. That lead to needing PoolImplUtils.
>>
>> I'm not completely happy with the current arrangement but neither have a
>> found a better one. Thoughts?
> 
> I wonder if we really want / need to retain the original "dumb" (not
> in the sense of bad design, but no tracking) pooling infrastructure
> from 1.x.  Thinking about making it easy for users to grokk the
> setup and get a GOP or GKOP working, I wonder if it might be better
> to drop the base classes and just start with simple, refactored pool
> and factory interfaces that create and manage PooledObjects
> directly.  Users will still only absolutely *have* to implement
> makeObject in their factories and the default code will take care of
> everything else.  So you just end up with PoolableObjectFactories
> sourcing and managing PooledObjects.  GOP, GKOP still return
> unwrapped objects via borrow and there is an
> AbstractPoolableObjectFactory with makeObject abstract and the rest
> provided.  I have not played with this yet (hopefully will have some
> time in the next couple of days), but I wonder if it might not be
> better / simpler.  Also, adding methods to GOP, GKOP that return
> PooledObject instances (maybe stripped down) might be useful to
> clients.  Sorry if above is naive / old ground.  I just want to make
> sure what we end up with is a simple as possible.

That is certainly do-able. The question is what does it mean for the
various implementations like SoftReferenceObjectPool and those provided
by PoolUtils.

If there are implementations there are are no longer required or
rendered obsolete by the Pool2 impl then a big +1 from me to removing them.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by James Carman <ja...@carmanconsulting.com>.
I like the sound of that!


On Mon, Jul 29, 2013 at 2:42 PM, Gary Gregory <ga...@gmail.com> wrote:
> On Mon, Jul 29, 2013 at 1:56 PM, Phil Steitz <ph...@gmail.com> wrote:
>
>> On 7/24/13 1:06 PM, Mark Thomas wrote:
>> > On 24/07/2013 21:01, markt@apache.org wrote:
>> >> Author: markt
>> >> Date: Wed Jul 24 20:01:34 2013
>> >> New Revision: 1506685
>> >>
>> >> URL: http://svn.apache.org/r1506685
>> >> Log:
>> >> Create two new factory interfaces that work with PooledObject instances
>> rather than Object instances and switch Gop and GKOP to use them.
>> > One area I'd particularly like some comment on is PooledObject &
>> > PooledObjectImpl.
>> >
>> > I considered just having a single PooledObject implementation class in
>> > o.a.c.pool2 but decided that as implementation it belonged in
>> > o.a.c.pool2.impl. That lead to needing PoolImplUtils.
>> >
>> > I'm not completely happy with the current arrangement but neither have a
>> > found a better one. Thoughts?
>>
>> I wonder if we really want / need to retain the original "dumb" (not
>> in the sense of bad design, but no tracking) pooling infrastructure
>> from 1.x.  Thinking about making it easy for users to grokk the
>> setup and get a GOP or GKOP working, I wonder if it might be better
>> to drop the base classes and just start with simple, refactored pool
>> and factory interfaces that create and manage PooledObjects
>> directly.  Users will still only absolutely *have* to implement
>> makeObject in their factories and the default code will take care of
>> everything else.  So you just end up with PoolableObjectFactories
>> sourcing and managing PooledObjects.  GOP, GKOP still return
>> unwrapped objects via borrow and there is an
>> AbstractPoolableObjectFactory with makeObject abstract and the rest
>> provided.  I have not played with this yet (hopefully will have some
>> time in the next couple of days), but I wonder if it might not be
>> better / simpler.  Also, adding methods to GOP, GKOP that return
>> PooledObject instances (maybe stripped down) might be useful to
>> clients.  Sorry if above is naive / old ground.  I just want to make
>> sure what we end up with is a simple as possible.
>>
>
> This all sounds good at first glance.
>
> The less code I, as a user, have to understand and write, the better.
>
> If that takes care of 80% of user stories, great. For the rest, we can add
> bells and whistles, on top of what will likely be a simpler and cleaner
> base.
>
> Gary
>
>
>> Phil
>> >
>> > Mark
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> > For additional commands, e-mail: dev-help@commons.apache.org
>> >
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Gary Gregory <ga...@gmail.com>.
On Mon, Jul 29, 2013 at 1:56 PM, Phil Steitz <ph...@gmail.com> wrote:

> On 7/24/13 1:06 PM, Mark Thomas wrote:
> > On 24/07/2013 21:01, markt@apache.org wrote:
> >> Author: markt
> >> Date: Wed Jul 24 20:01:34 2013
> >> New Revision: 1506685
> >>
> >> URL: http://svn.apache.org/r1506685
> >> Log:
> >> Create two new factory interfaces that work with PooledObject instances
> rather than Object instances and switch Gop and GKOP to use them.
> > One area I'd particularly like some comment on is PooledObject &
> > PooledObjectImpl.
> >
> > I considered just having a single PooledObject implementation class in
> > o.a.c.pool2 but decided that as implementation it belonged in
> > o.a.c.pool2.impl. That lead to needing PoolImplUtils.
> >
> > I'm not completely happy with the current arrangement but neither have a
> > found a better one. Thoughts?
>
> I wonder if we really want / need to retain the original "dumb" (not
> in the sense of bad design, but no tracking) pooling infrastructure
> from 1.x.  Thinking about making it easy for users to grokk the
> setup and get a GOP or GKOP working, I wonder if it might be better
> to drop the base classes and just start with simple, refactored pool
> and factory interfaces that create and manage PooledObjects
> directly.  Users will still only absolutely *have* to implement
> makeObject in their factories and the default code will take care of
> everything else.  So you just end up with PoolableObjectFactories
> sourcing and managing PooledObjects.  GOP, GKOP still return
> unwrapped objects via borrow and there is an
> AbstractPoolableObjectFactory with makeObject abstract and the rest
> provided.  I have not played with this yet (hopefully will have some
> time in the next couple of days), but I wonder if it might not be
> better / simpler.  Also, adding methods to GOP, GKOP that return
> PooledObject instances (maybe stripped down) might be useful to
> clients.  Sorry if above is naive / old ground.  I just want to make
> sure what we end up with is a simple as possible.
>

This all sounds good at first glance.

The less code I, as a user, have to understand and write, the better.

If that takes care of 80% of user stories, great. For the rest, we can add
bells and whistles, on top of what will likely be a simpler and cleaner
base.

Gary


> Phil
> >
> > Mark
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

[pool] 2.0 factory interfaces WAS: Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Phil Steitz <ph...@gmail.com>.
On 7/24/13 1:06 PM, Mark Thomas wrote:
> On 24/07/2013 21:01, markt@apache.org wrote:
>> Author: markt
>> Date: Wed Jul 24 20:01:34 2013
>> New Revision: 1506685
>>
>> URL: http://svn.apache.org/r1506685
>> Log:
>> Create two new factory interfaces that work with PooledObject instances rather than Object instances and switch Gop and GKOP to use them.
> One area I'd particularly like some comment on is PooledObject &
> PooledObjectImpl.
>
> I considered just having a single PooledObject implementation class in
> o.a.c.pool2 but decided that as implementation it belonged in
> o.a.c.pool2.impl. That lead to needing PoolImplUtils.
>
> I'm not completely happy with the current arrangement but neither have a
> found a better one. Thoughts?

I wonder if we really want / need to retain the original "dumb" (not
in the sense of bad design, but no tracking) pooling infrastructure
from 1.x.  Thinking about making it easy for users to grokk the
setup and get a GOP or GKOP working, I wonder if it might be better
to drop the base classes and just start with simple, refactored pool
and factory interfaces that create and manage PooledObjects
directly.  Users will still only absolutely *have* to implement
makeObject in their factories and the default code will take care of
everything else.  So you just end up with PoolableObjectFactories
sourcing and managing PooledObjects.  GOP, GKOP still return
unwrapped objects via borrow and there is an
AbstractPoolableObjectFactory with makeObject abstract and the rest
provided.  I have not played with this yet (hopefully will have some
time in the next couple of days), but I wonder if it might not be
better / simpler.  Also, adding methods to GOP, GKOP that return
PooledObject instances (maybe stripped down) might be useful to
clients.  Sorry if above is naive / old ground.  I just want to make
sure what we end up with is a simple as possible.

Phil
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Benedikt Ritter <br...@apache.org>.
How about DefaultPooledObject? I like the Default* prefix more than the
*Impl postfix.

Benedikt


2013/7/24 Mark Thomas <ma...@apache.org>

> On 24/07/2013 21:01, markt@apache.org wrote:
> > Author: markt
> > Date: Wed Jul 24 20:01:34 2013
> > New Revision: 1506685
> >
> > URL: http://svn.apache.org/r1506685
> > Log:
> > Create two new factory interfaces that work with PooledObject instances
> rather than Object instances and switch Gop and GKOP to use them.
>
> One area I'd particularly like some comment on is PooledObject &
> PooledObjectImpl.
>
> I considered just having a single PooledObject implementation class in
> o.a.c.pool2 but decided that as implementation it belonged in
> o.a.c.pool2.impl. That lead to needing PoolImplUtils.
>
> I'm not completely happy with the current arrangement but neither have a
> found a better one. Thoughts?
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Re: svn commit: r1506685 - in /commons/proper/pool/trunk/src: main/java/org/apache/commons/pool2/ main/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/ test/java/org/apache/commons/pool2/impl/ test/java/org/apache/commons/pool2/perfo...

Posted by Mark Thomas <ma...@apache.org>.
On 24/07/2013 21:01, markt@apache.org wrote:
> Author: markt
> Date: Wed Jul 24 20:01:34 2013
> New Revision: 1506685
> 
> URL: http://svn.apache.org/r1506685
> Log:
> Create two new factory interfaces that work with PooledObject instances rather than Object instances and switch Gop and GKOP to use them.

One area I'd particularly like some comment on is PooledObject &
PooledObjectImpl.

I considered just having a single PooledObject implementation class in
o.a.c.pool2 but decided that as implementation it belonged in
o.a.c.pool2.impl. That lead to needing PoolImplUtils.

I'm not completely happy with the current arrangement but neither have a
found a better one. Thoughts?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org