You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2010/10/20 08:12:05 UTC

svn commit: r1024534 - in /commons/proper/pool/trunk/src: java/org/apache/commons/pool2/impl/ test/org/apache/commons/pool2/impl/

Author: simonetripodi
Date: Wed Oct 20 06:12:05 2010
New Revision: 1024534

URL: http://svn.apache.org/viewvc?rev=1024534&view=rev
Log:
GenericKeyedObjectPool.Config class converted to a POJO, no more direct access to fields
TODO add missing getters/setters javadoc comments

Modified:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolFactory.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1024534&r1=1024533&r2=1024534&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java Wed Oct 20 06:12:05 2010
@@ -2213,60 +2213,163 @@ public class GenericKeyedObjectPool<K,V>
      * @see GenericKeyedObjectPool#setConfig
      */
     public static class Config {
-        //CHECKSTYLE: stop VisibilityModifier
         /**
          * @see GenericKeyedObjectPool#setMaxIdle
          */
-        public int maxIdle = GenericKeyedObjectPool.DEFAULT_MAX_IDLE;
+        private int maxIdle = GenericKeyedObjectPool.DEFAULT_MAX_IDLE;
         /**
          * @see GenericKeyedObjectPool#setMaxActive
          */
-        public int maxActive = GenericKeyedObjectPool.DEFAULT_MAX_ACTIVE;
+        private int maxActive = GenericKeyedObjectPool.DEFAULT_MAX_ACTIVE;
         /**
          * @see GenericKeyedObjectPool#setMaxTotal
          */
-        public int maxTotal = GenericKeyedObjectPool.DEFAULT_MAX_TOTAL;
+        private int maxTotal = GenericKeyedObjectPool.DEFAULT_MAX_TOTAL;
         /**
          * @see GenericKeyedObjectPool#setMinIdle
          */
-        public int minIdle = GenericKeyedObjectPool.DEFAULT_MIN_IDLE;
+        private int minIdle = GenericKeyedObjectPool.DEFAULT_MIN_IDLE;
         /**
          * @see GenericKeyedObjectPool#setMaxWait
          */
-        public long maxWait = GenericKeyedObjectPool.DEFAULT_MAX_WAIT;
+        private long maxWait = GenericKeyedObjectPool.DEFAULT_MAX_WAIT;
         /**
          * @see GenericKeyedObjectPool#setWhenExhaustedAction
          */
-        public WhenExhaustedAction whenExhaustedAction = GenericKeyedObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION;
+        private WhenExhaustedAction whenExhaustedAction = GenericKeyedObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION;
         /**
          * @see GenericKeyedObjectPool#setTestOnBorrow
          */
-        public boolean testOnBorrow = GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW;
+        private boolean testOnBorrow = GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW;
         /**
          * @see GenericKeyedObjectPool#setTestOnReturn
          */
-        public boolean testOnReturn = GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN;
+        private boolean testOnReturn = GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN;
         /**
          * @see GenericKeyedObjectPool#setTestWhileIdle
          */
-        public boolean testWhileIdle = GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE;
+        private boolean testWhileIdle = GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE;
         /**
          * @see GenericKeyedObjectPool#setTimeBetweenEvictionRunsMillis
          */
-        public long timeBetweenEvictionRunsMillis = GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
+        private long timeBetweenEvictionRunsMillis = GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
         /**
          * @see GenericKeyedObjectPool#setNumTestsPerEvictionRun
          */
-        public int numTestsPerEvictionRun =  GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
+        private int numTestsPerEvictionRun =  GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
         /**
          * @see GenericKeyedObjectPool#setMinEvictableIdleTimeMillis
          */
-        public long minEvictableIdleTimeMillis = GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
+        private long minEvictableIdleTimeMillis = GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
         /**
          * @see GenericKeyedObjectPool#setLifo
          */
-        public boolean lifo = GenericKeyedObjectPool.DEFAULT_LIFO;
-        //CHECKSTYLE: resume VisibilityModifier
+        private boolean lifo = GenericKeyedObjectPool.DEFAULT_LIFO;
+
+        public int getMaxIdle() {
+            return maxIdle;
+        }
+
+        public void setMaxIdle(int maxIdle) {
+            this.maxIdle = maxIdle;
+        }
+
+        public int getMaxActive() {
+            return maxActive;
+        }
+
+        public void setMaxActive(int maxActive) {
+            this.maxActive = maxActive;
+        }
+
+        public int getMaxTotal() {
+            return maxTotal;
+        }
+
+        public void setMaxTotal(int maxTotal) {
+            this.maxTotal = maxTotal;
+        }
+
+        public int getMinIdle() {
+            return minIdle;
+        }
+
+        public void setMinIdle(int minIdle) {
+            this.minIdle = minIdle;
+        }
+
+        public long getMaxWait() {
+            return maxWait;
+        }
+
+        public void setMaxWait(long maxWait) {
+            this.maxWait = maxWait;
+        }
+
+        public WhenExhaustedAction getWhenExhaustedAction() {
+            return whenExhaustedAction;
+        }
+
+        public void setWhenExhaustedAction(WhenExhaustedAction whenExhaustedAction) {
+            this.whenExhaustedAction = whenExhaustedAction;
+        }
+
+        public boolean getTestOnBorrow() {
+            return testOnBorrow;
+        }
+
+        public void setTestOnBorrow(boolean testOnBorrow) {
+            this.testOnBorrow = testOnBorrow;
+        }
+
+        public boolean getTestOnReturn() {
+            return testOnReturn;
+        }
+
+        public void setTestOnReturn(boolean testOnReturn) {
+            this.testOnReturn = testOnReturn;
+        }
+
+        public boolean getTestWhileIdle() {
+            return testWhileIdle;
+        }
+
+        public void setTestWhileIdle(boolean testWhileIdle) {
+            this.testWhileIdle = testWhileIdle;
+        }
+
+        public long getTimeBetweenEvictionRunsMillis() {
+            return timeBetweenEvictionRunsMillis;
+        }
+
+        public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
+            this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
+        }
+
+        public int getNumTestsPerEvictionRun() {
+            return numTestsPerEvictionRun;
+        }
+
+        public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
+            this.numTestsPerEvictionRun = numTestsPerEvictionRun;
+        }
+
+        public long getMinEvictableIdleTimeMillis() {
+            return minEvictableIdleTimeMillis;
+        }
+
+        public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
+            this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
+        }
+
+        public boolean getLifo() {
+            return lifo;
+        }
+
+        public void setLifo(boolean lifo) {
+            this.lifo = lifo;
+        }
+
     }
 
     /**

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolFactory.java?rev=1024534&r1=1024533&r2=1024534&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolFactory.java Wed Oct 20 06:12:05 2010
@@ -52,7 +52,7 @@ public class GenericKeyedObjectPoolFacto
      * @throws NullPointerException when config is <code>null</code>.
      */
     public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K,V> factory, GenericKeyedObjectPool.Config config) throws NullPointerException {
-        this(factory,config.maxActive,config.whenExhaustedAction,config.maxWait,config.maxIdle,config.maxTotal,config.minIdle,config.testOnBorrow,config.testOnReturn,config.timeBetweenEvictionRunsMillis,config.numTestsPerEvictionRun,config.minEvictableIdleTimeMillis,config.testWhileIdle,config.lifo);
+        this(factory,config.getMaxActive(),config.getWhenExhaustedAction(),config.getMaxWait(),config.getMaxIdle(),config.getMaxTotal(),config.getMinIdle(),config.getTestOnBorrow(),config.getTestOnReturn(),config.getTimeBetweenEvictionRunsMillis(),config.getNumTestsPerEvictionRun(),config.getMinEvictableIdleTimeMillis(),config.getTestWhileIdle(),config.getLifo());
     }
 
     /**

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1024534&r1=1024533&r2=1024534&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Wed Oct 20 06:12:05 2010
@@ -1042,19 +1042,19 @@ public class TestGenericKeyedObjectPool 
         assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo());
         
         GenericKeyedObjectPool.Config config = new GenericKeyedObjectPool.Config();
-        config.lifo = lifo;
-        config.maxActive = maxActive;
-        config.maxIdle = maxIdle;
-        config.minIdle = minIdle;
-        config.maxTotal = maxTotal;
-        config.maxWait = maxWait;
-        config.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
-        config.numTestsPerEvictionRun = numTestsPerEvictionRun;
-        config.testOnBorrow = testOnBorrow;
-        config.testOnReturn = testOnReturn;
-        config.testWhileIdle = testWhileIdle;
-        config.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
-        config.whenExhaustedAction = whenExhaustedAction;
+        config.setLifo(lifo);
+        config.setMaxActive(maxActive);
+        config.setMaxIdle(maxIdle);
+        config.setMinIdle(minIdle);
+        config.setMaxTotal(maxTotal);
+        config.setMaxWait(maxWait);
+        config.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
+        config.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
+        config.setTestOnBorrow(testOnBorrow);
+        config.setTestOnReturn(testOnReturn);
+        config.setTestWhileIdle(testWhileIdle);
+        config.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
+        config.setWhenExhaustedAction(whenExhaustedAction);
         pool = new GenericKeyedObjectPool<Object,Object>(factory, config);
         assertEquals(maxActive, pool.getMaxActive());
         assertEquals(maxIdle, pool.getMaxIdle());

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java?rev=1024534&r1=1024533&r2=1024534&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java Wed Oct 20 06:12:05 2010
@@ -47,18 +47,18 @@ public class TestGenericKeyedObjectPoolF
 
 
         final GenericKeyedObjectPool.Config config = new GenericKeyedObjectPool.Config();
-        config.maxActive = 1;
-        config.maxIdle = 2;
-        config.maxWait = 3;
-        config.minIdle = 4;
-        config.minEvictableIdleTimeMillis = 5;
-        config.numTestsPerEvictionRun = 6;
-        config.testOnBorrow = true;
-        config.testOnReturn = false;
-        config.testWhileIdle = true;
-        config.timeBetweenEvictionRunsMillis = 8;
-        config.whenExhaustedAction = WhenExhaustedAction.GROW;
-        config.lifo = false;
+        config.setMaxActive(1);
+        config.setMaxIdle(2);
+        config.setMaxWait(3);
+        config.setMinIdle(4);
+        config.setMinEvictableIdleTimeMillis(5);
+        config.setNumTestsPerEvictionRun(6);
+        config.setTestOnBorrow(true);
+        config.setTestOnReturn(false);
+        config.setTestWhileIdle(true);
+        config.setTimeBetweenEvictionRunsMillis(8);
+        config.setWhenExhaustedAction(WhenExhaustedAction.GROW);
+        config.setLifo(false);
         factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), config);
         pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());