commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1040968 - in /commons/proper/pool/trunk/src: java/org/apache/commons/pool2/impl/ test/org/apache/commons/pool2/impl/
Date Wed, 01 Dec 2010 11:58:42 GMT
Author: simonetripodi
Date: Wed Dec  1 11:58:42 2010
New Revision: 1040968

URL: http://svn.apache.org/viewvc?rev=1040968&view=rev
Log:
according to as discussed in ML, the public StackObjectPoolConfig ctor repeats the settings
available in the nested Builder, so ctor made private, it can be instantiated only via the
Builder

Modified:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolConfig.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolFactory.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java?rev=1040968&r1=1040967&r2=1040968&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java
Wed Dec  1 11:58:42 2010
@@ -77,7 +77,10 @@ public class StackKeyedObjectPoolFactory
      * @return a new StackKeyedObjectPool with the configured factory, maxSleeping and initialCapacity
      */
     public KeyedObjectPool<K,V> createPool() {
-        return new StackKeyedObjectPool<K,V>(_factory,new StackObjectPoolConfig(this.maxSleeping,
this.initIdleCapacity));
+        return new StackKeyedObjectPool<K,V>(_factory,new StackObjectPoolConfig.Builder()
+            .setMaxSleeping(this.maxSleeping)
+            .setInitIdleCapacity(this.initIdleCapacity)
+            .createConfig());
     }
 
     /** 

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolConfig.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolConfig.java?rev=1040968&r1=1040967&r2=1040968&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolConfig.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolConfig.java
Wed Dec  1 11:58:42 2010
@@ -59,7 +59,7 @@ public class StackObjectPoolConfig {
      * @param maxSleeping
      * @param initIdleCapacity
      */
-    public StackObjectPoolConfig(final int maxSleeping, final int initIdleCapacity) {
+    private StackObjectPoolConfig(final int maxSleeping, final int initIdleCapacity) {
         this.maxSleeping = (maxSleeping < 0 ? DEFAULT_MAX_SLEEPING : maxSleeping);
         this.initIdleCapacity = (initIdleCapacity < 1 ? DEFAULT_INIT_SLEEPING_CAPACITY
: initIdleCapacity);
     }

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolFactory.java?rev=1040968&r1=1040967&r2=1040968&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolFactory.java
(original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolFactory.java
Wed Dec  1 11:58:42 2010
@@ -76,7 +76,10 @@ public class StackObjectPoolFactory<T> i
      * @return a new StackObjectPool with the configured factory, maxIdle and initial capacity
settings
      */
     public ObjectPool<T> createPool() {
-        return new StackObjectPool<T>(_factory,new StackObjectPoolConfig(this.maxSleeping,
this.initIdleCapacity));
+        return new StackObjectPool<T>(_factory,new StackObjectPoolConfig.Builder()
+                .setMaxSleeping(this.maxSleeping)
+                .setInitIdleCapacity(this.initIdleCapacity)
+                .createConfig());
     }
 
     /**

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java?rev=1040968&r1=1040967&r2=1040968&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java
Wed Dec  1 11:58:42 2010
@@ -149,12 +149,18 @@ public class TestStackKeyedObjectPool ex
             assertNotNull(pool);
         }
         {
-            StackObjectPoolConfig config = new StackObjectPoolConfig(10, 5);
+            StackObjectPoolConfig config = new StackObjectPoolConfig.Builder()
+                .setMaxSleeping(10)
+                .setInitIdleCapacity(5)
+                .createConfig();
             StackKeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>(new
SimpleFactory(),config);
             assertNotNull(pool);
         }
         {
-            StackObjectPoolConfig config = new StackObjectPoolConfig(10, 5);
+            StackObjectPoolConfig config = new StackObjectPoolConfig.Builder()
+                .setMaxSleeping(10)
+                .setInitIdleCapacity(5)
+                .createConfig();
             StackKeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>(new
SimpleFactory(),config);
             assertNotNull(pool);
         }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java?rev=1040968&r1=1040967&r2=1040968&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java
Wed Dec  1 11:58:42 2010
@@ -52,7 +52,10 @@ public class TestStackKeyedObjectPoolFac
         assertEquals(1,pool.getMaxSleeping());
         pool.close();
 
-        config = new StackObjectPoolConfig(1, 2);
+        config = new StackObjectPoolConfig.Builder()
+            .setMaxSleeping(1)
+            .setInitIdleCapacity(2)
+            .createConfig();
         factory = new StackKeyedObjectPoolFactory<Object,Object>(createObjectFactory(),
config);
         pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1,pool.getMaxSleeping());

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java?rev=1040968&r1=1040967&r2=1040968&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
Wed Dec  1 11:58:42 2010
@@ -164,7 +164,10 @@ public class TestStackObjectPool extends
             assertNotNull(pool);
         }
         {
-            StackObjectPoolConfig config = new StackObjectPoolConfig(20, 5);
+            StackObjectPoolConfig config = new StackObjectPoolConfig.Builder()
+                .setMaxSleeping(20)
+                .setInitIdleCapacity(5)
+                .createConfig();
             StackObjectPool<Integer> pool = new StackObjectPool<Integer>(null,config);
             assertNotNull(pool);
         }
@@ -176,7 +179,10 @@ public class TestStackObjectPool extends
     @Test
     public void testMaxIdleInitCapacityOutOfRange() throws Exception {
         SimpleFactory factory = new SimpleFactory();
-        StackObjectPoolConfig config = new StackObjectPoolConfig(-1, 0);
+        StackObjectPoolConfig config = new StackObjectPoolConfig.Builder()
+            .setMaxSleeping(-1)
+            .setInitIdleCapacity(0)
+            .createConfig();
         StackObjectPool<Object> pool = new StackObjectPool<Object>(factory, config);
         assertEquals(pool.getMaxSleeping(), StackObjectPoolConfig.DEFAULT_MAX_SLEEPING);
         pool.addObject();
@@ -383,13 +389,19 @@ public class TestStackObjectPool extends
     @Test
     public void testInitIdleCapacityExceeded() throws Exception {
         PoolableObjectFactory<Object> factory = new SimpleFactory();
-        StackObjectPoolConfig config = new StackObjectPoolConfig(2, 1);
+        StackObjectPoolConfig config = new StackObjectPoolConfig.Builder()
+            .setMaxSleeping(2)
+            .setInitIdleCapacity(1)
+            .createConfig();
         ObjectPool<Object> pool = new StackObjectPool<Object>(factory, config);
         pool.addObject();
         pool.addObject();
         assertEquals(2, pool.getNumIdle());
         pool.close();
-        config = new StackObjectPoolConfig(1, 2);
+        config = new StackObjectPoolConfig.Builder()
+            .setMaxSleeping(1)
+            .setInitIdleCapacity(2)
+            .createConfig();
         pool = new StackObjectPool<Object>(factory, config);
         pool.addObject();
         pool.addObject();



Mime
View raw message