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/12 19:19:37 UTC
svn commit: r1021848 - in /commons/proper/pool/trunk/src:
java/org/apache/commons/pool/impl/StackKeyedObjectPoolFactory.java
test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java
Author: simonetripodi
Date: Tue Oct 12 17:19:36 2010
New Revision: 1021848
URL: http://svn.apache.org/viewvc?rev=1021848&view=rev
Log:
removed deprecated constructors
properties made private
added missing syncronized setter(s)
updated related testcase
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPoolFactory.java
commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java
Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPoolFactory.java?rev=1021848&r1=1021847&r2=1021848&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool/impl/StackKeyedObjectPoolFactory.java Tue Oct 12 17:19:36 2010
@@ -35,37 +35,6 @@ public class StackKeyedObjectPoolFactory
/**
* Create a new StackKeyedObjectPoolFactory.
*
- * @see StackKeyedObjectPool#StackKeyedObjectPool()
- */
- public StackKeyedObjectPoolFactory() {
- this((KeyedPoolableObjectFactory<K,V>)null,StackKeyedObjectPool.DEFAULT_MAX_SLEEPING,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
- }
-
- /**
- * Create a new StackKeyedObjectPoolFactory.
- *
- * @param maxSleeping cap on the number of "sleeping" instances in the pool.
- * @see StackKeyedObjectPool#StackKeyedObjectPool(int)
- */
- public StackKeyedObjectPoolFactory(int maxSleeping) {
- this((KeyedPoolableObjectFactory<K,V>)null,maxSleeping,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
- }
-
- /**
- * Create a new StackKeyedObjectPoolFactory.
- *
- * @param maxSleeping cap on the number of "sleeping" instances in the pool.
- * @param initialCapacity initial size of the pool (this specifies the size of the container,
- * it does not cause the pool to be pre-populated.)
- * @see StackKeyedObjectPool#StackKeyedObjectPool(int, int)
- */
- public StackKeyedObjectPoolFactory(int maxSleeping, int initialCapacity) {
- this((KeyedPoolableObjectFactory<K,V>)null,maxSleeping,initialCapacity);
- }
-
- /**
- * Create a new StackKeyedObjectPoolFactory.
- *
* @param factory the KeyedPoolableObjectFactory used by created pools.
* @see StackKeyedObjectPool#StackKeyedObjectPool(KeyedPoolableObjectFactory)
*/
@@ -110,21 +79,18 @@ public class StackKeyedObjectPoolFactory
/**
* KeyedPoolableObjectFactory used by StackKeyedObjectPools created by this factory
- * @deprecated to be removed in pool 2.0
*/
- protected KeyedPoolableObjectFactory<K,V> _factory = null;
+ private final KeyedPoolableObjectFactory<K,V> _factory;
/**
* Maximum number of idle instances in each keyed pool for StackKeyedObjectPools created by this factory
- * @deprecated to be removed in pool 2.0
*/
- protected int _maxSleeping = StackKeyedObjectPool.DEFAULT_MAX_SLEEPING;
+ private int _maxSleeping = StackKeyedObjectPool.DEFAULT_MAX_SLEEPING;
/**
* Initial capacity of StackKeyedObjectPools created by this factory.
- * @deprecated to be removed in pool 2.0
*/
- protected int _initCapacity = StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY;
+ private int _initCapacity = StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY;
/**
* Returns the KeyedPoolableObjectFactory used by StackKeyedObjectPools created by this factory
@@ -132,7 +98,7 @@ public class StackKeyedObjectPoolFactory
* @return factory setting for created pools
* @since 1.5.5
*/
- public KeyedPoolableObjectFactory<K,V> getFactory() {
+ public synchronized KeyedPoolableObjectFactory<K,V> getFactory() {
return _factory;
}
@@ -142,17 +108,27 @@ public class StackKeyedObjectPoolFactory
* @return maxSleeping setting for created pools
* @since 1.5.5
*/
- public int getMaxSleeping() {
+ public synchronized int getMaxSleeping() {
return _maxSleeping;
}
/**
+ * Sets the maximum number of idle instances in each keyed pool for StackKeyedObjectPools created by this factory
+ *
+ * @param maxSleeping
+ * @since 2.0
+ */
+ public synchronized void setMaxSleeping(int maxSleeping) {
+ _maxSleeping = maxSleeping;
+ }
+
+ /**
* Returns the initial capacity of StackKeyedObjectPools created by this factory.
*
* @return initial capacity setting for created pools
* @since 1.5.5
*/
- public int getInitialCapacity() {
+ public synchronized int getInitialCapacity() {
return _initCapacity;
}
Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java?rev=1021848&r1=1021847&r2=1021848&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java Tue Oct 12 17:19:36 2010
@@ -38,33 +38,19 @@ public class TestStackKeyedObjectPoolFac
}
public void testConstructors() throws Exception {
- StackKeyedObjectPoolFactory<Object,Object> factory = new StackKeyedObjectPoolFactory<Object,Object>();
- factory.createPool().close();
-
- factory = new StackKeyedObjectPoolFactory<Object,Object>(1);
+ StackKeyedObjectPoolFactory<Object,Object> factory = new StackKeyedObjectPoolFactory<Object,Object>(createObjectFactory());
StackKeyedObjectPool<Object,Object> pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
- assertEquals(1,pool._maxSleeping);
- pool.close();
-
- factory = new StackKeyedObjectPoolFactory<Object,Object>(1, 2);
- pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
- assertEquals(1,pool._maxSleeping);
- assertEquals(2,pool._initSleepingCapacity);
- pool.close();
-
- factory = new StackKeyedObjectPoolFactory<Object,Object>(createObjectFactory());
- pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
pool.close();
factory = new StackKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1);
pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
- assertEquals(1,pool._maxSleeping);
+ assertEquals(1,pool.getMaxSleeping());
pool.close();
factory = new StackKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, 2);
pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
- assertEquals(1,pool._maxSleeping);
- assertEquals(2,pool._initSleepingCapacity);
+ assertEquals(1,pool.getMaxSleeping());
+ assertEquals(2,pool.getInitSleepingCapacity());
pool.close();
}