commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sandy...@apache.org
Subject svn commit: r389995 - in /jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite: CompositeKeyedObjectPool.java CompositeObjectPool.java CompositeObjectPoolFactory.java
Date Thu, 30 Mar 2006 05:42:46 GMT
Author: sandymac
Date: Wed Mar 29 21:42:45 2006
New Revision: 389995

URL: http://svn.apache.org/viewcvs?rev=389995&view=rev
Log:
Removed clone support from the CompositeObjectPools as it
didn't handle all corner cases and didn't provide any real benefit.

Modified:
    jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java
    jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java
    jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPoolFactory.java

Modified: jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java?rev=389995&r1=389994&r2=389995&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeKeyedObjectPool.java
Wed Mar 29 21:42:45 2006
@@ -440,28 +440,6 @@
     }
 
     /**
-     * Creates a new keyed object pool with the same settings as this one. The new instance
will not contian any
-     * existing idle objects nor should you return active objects to it.
-     *
-     * @return a new keyed object pool with the same settings.
-     */
-    public Object clone() throws CloneNotSupportedException {
-        if (!getClass().equals(CompositeKeyedObjectPool.class)) {
-            throw new CloneNotSupportedException("Subclasses must not call super.clone()");
-        }
-        if (poolFactory instanceof CompositeObjectPoolFactory) {
-            final PoolableObjectFactory pof = ((CompositeObjectPoolFactory)poolFactory).getFactory();
-            if (pof instanceof KeyedPoolableObjectFactoryAdapter) {
-                final KeyedPoolableObjectFactory kopf = ((KeyedPoolableObjectFactoryAdapter)pof).getDelegate();
-                final CompositeObjectPoolFactory opf = (CompositeObjectPoolFactory)((CompositeObjectPoolFactory)poolFactory).clone();
-                opf.setFactory(new KeyedPoolableObjectFactoryAdapter(kopf));
-                return new CompositeKeyedObjectPool(opf);
-            }
-        }
-        return new CompositeKeyedObjectPool(poolFactory);
-    }
-
-    /**
      * The {@link ThreadLocal} keys is not serializable and final, must create a new instance
for this to be correct.
      */
     private Object readResolve() throws ObjectStreamException {

Modified: jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java?rev=389995&r1=389994&r2=389995&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPool.java
Wed Mar 29 21:42:45 2006
@@ -441,17 +441,4 @@
         sb.append('}');
         return sb.toString();
     }
-
-    /**
-     * Create a new pool with the same settings. Active or Idle objects are not shared with
the new pool.
-     *
-     * @return a new {@link CompositeObjectPool} with the same configuration.
-     * @throws CloneNotSupportedException when this pool was contstucted without a factoryConfig.
-     */
-    public Object clone() throws CloneNotSupportedException {
-        if (factoryConfig == null) {
-            throw new CloneNotSupportedException("Cloning not supported without a factoryConfig.");
-        }
-        return CompositeObjectPoolFactory.createPool(factoryConfig);
-    }
 }

Modified: jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPoolFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPoolFactory.java?rev=389995&r1=389994&r2=389995&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPoolFactory.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/java/org/apache/commons/pool/composite/CompositeObjectPoolFactory.java
Wed Mar 29 21:42:45 2006
@@ -694,7 +694,13 @@
      * @throws CloneNotSupportedException if {@link Object#clone()} does.
      */
     public Object clone() throws CloneNotSupportedException {
-        return super.clone();
+        final CompositeObjectPoolFactory copf = (CompositeObjectPoolFactory)super.clone();
+        // Cannot share KeyedPoolableObjectFactoryAdapter between instances because of ThreadLocal
usage
+        if (copf.factory instanceof KeyedPoolableObjectFactoryAdapter) {
+            KeyedPoolableObjectFactoryAdapter kpofa = (KeyedPoolableObjectFactoryAdapter)copf.factory;
+            copf.factory = new KeyedPoolableObjectFactoryAdapter(kpofa.getDelegate());
+        }
+        return copf;
     }
 
     public String toString() {



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


Mime
View raw message