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 2012/04/24 16:36:57 UTC
svn commit: r1329744 - in
/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl:
GenericKeyedObjectPool.java GenericObjectPool.java
Author: markt
Date: Tue Apr 24 14:36:57 2012
New Revision: 1329744
URL: http://svn.apache.org/viewvc?rev=1329744&view=rev
Log:
More GOP GKOP alignment
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
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=1329744&r1=1329743&r2=1329744&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 Tue Apr 24 14:36:57 2012
@@ -211,8 +211,6 @@ import org.apache.commons.pool2.PoolUtil
public class GenericKeyedObjectPool<K,T> implements KeyedObjectPool<K,T>,
GenericKeyedObjectPoolMBean<K>, NotificationEmitter {
- //--- constructors -----------------------------------------------
-
/**
* Create a new <code>GenericKeyedObjectPool</code> using defaults.
*/
@@ -292,8 +290,6 @@ public class GenericKeyedObjectPool<K,T>
this.creationStackTrace = getStackTrace(new Exception());
}
- //--- configuration methods --------------------------------------
-
/**
* Returns the cap on the number of object instances allocated by the pool
* (checked out or idle), per key.
@@ -785,8 +781,6 @@ public class GenericKeyedObjectPool<K,T>
}
- //-- ObjectPool methods ------------------------------------------
-
/**
* <p>Borrows an object from the keyed pool associated with the given
* key.</p>
@@ -1758,6 +1752,30 @@ public class GenericKeyedObjectPool<K,T>
}
}
+ /**
+ * Create an object using the {@link KeyedPoolableObjectFactory#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} fails.
+ * @throws IllegalStateException when no factory has been set or after {@link #close} has been
+ * called on this pool.
+ */
+ @Override
+ public void addObject(K key) throws Exception {
+ assertOpen();
+ if (factory == null) {
+ throw new IllegalStateException("Cannot add objects without a factory.");
+ }
+ register(key);
+ try {
+ PooledObject<T> p = create(key);
+ addIdleObject(key, p);
+ } finally {
+ deregister(key);
+ }
+ }
/**
* <p>Adds an object to the keyed pool.</p>
@@ -1766,8 +1784,10 @@ public class GenericKeyedObjectPool<K,T>
* if validation or passivation fails, or maxIdle is set and there is no room in the pool, the instance
* is destroyed.</p>
*
- * <p>Calls {@link #allocate()} on successful completion</p>
+ * <p>Calls {@link #allocate()} on successful completion.</p>
*
+ * <p>Callers are responsible for registering and deregistering the key.</p>
+ *
* @param key pool key
* @param p instance to add to the keyed pool
* @throws Exception
@@ -1787,31 +1807,6 @@ public class GenericKeyedObjectPool<K,T>
}
/**
- * Create an object using the {@link KeyedPoolableObjectFactory#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} fails.
- * @throws IllegalStateException when no factory has been set or after {@link #close} has been
- * called on this pool.
- */
- @Override
- public void addObject(K key) throws Exception {
- assertOpen();
- if (factory == null) {
- throw new IllegalStateException("Cannot add objects without a factory.");
- }
- register(key);
- try {
- PooledObject<T> p = create(key);
- addIdleObject(key, p);
- } finally {
- deregister(key);
- }
- }
-
- /**
* Registers a key for pool control and ensures that {@link #getMinIdlePerKey()}
* idle instances are created.
*
@@ -1822,8 +1817,6 @@ public class GenericKeyedObjectPool<K,T>
ensureMinIdle(key);
}
- //--- non-public methods ----------------------------------------
-
/**
* Start the eviction thread or service, or when
* <code>delay</code> is non-positive, stop it
@@ -2201,6 +2194,7 @@ public class GenericKeyedObjectPool<K,T>
/**
* The idle object evictor {@link TimerTask}.
+ *
* @see GenericKeyedObjectPool#setTimeBetweenEvictionRunsMillis
*/
private class Evictor extends TimerTask {
@@ -2242,7 +2236,7 @@ public class GenericKeyedObjectPool<K,T>
}
}
- //--- attributes -----------------------------------------------------------
+ //--- private attributes ---------------------------------------------------
/**
* The cap on the number of idle instances per key.
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=1329744&r1=1329743&r2=1329744&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 Tue Apr 24 14:36:57 2012
@@ -178,8 +178,6 @@ import org.apache.commons.pool2.Poolable
public class GenericObjectPool<T> extends BaseObjectPool<T>
implements GenericObjectPoolMBean, NotificationEmitter {
- // --- constructors -----------------------------------------------
-
/**
* Create a new <code>GenericObjectPool</code> using default.
*/
@@ -259,8 +257,6 @@ public class GenericObjectPool<T> extend
this.creationStackTrace = getStackTrace(new Exception());
}
- // --- configuration methods --------------------------------------
-
/**
* Returns the maximum number of objects that can be allocated by the pool
* (checked out to clients, or idle awaiting checkout) at a given time. When
@@ -727,8 +723,6 @@ public class GenericObjectPool<T> extend
}
- // -- ObjectPool methods ------------------------------------------
-
/**
* <p>Borrows an object from the pool.</p>
*
@@ -1301,8 +1295,6 @@ public class GenericObjectPool<T> extend
addIdleObject(p);
}
- // --- non-public methods ----------------------------------------
-
private void addIdleObject(PooledObject<T> p) throws Exception {
if (p != null) {
factory.passivateObject(p.getObject());