You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/10/08 13:49:31 UTC
[commons-pool] branch master updated: Sort methods.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-pool.git
The following commit(s) were added to refs/heads/master by this push:
new f3984f8 Sort methods.
f3984f8 is described below
commit f3984f8f9fcf6ba92d9fce6001d3bcd813345e35
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Oct 8 09:49:25 2019 -0400
Sort methods.
---
.../java/org/apache/commons/pool2/ObjectPool.java | 122 ++++++++++-----------
1 file changed, 61 insertions(+), 61 deletions(-)
diff --git a/src/main/java/org/apache/commons/pool2/ObjectPool.java b/src/main/java/org/apache/commons/pool2/ObjectPool.java
index b23de7a..101de01 100644
--- a/src/main/java/org/apache/commons/pool2/ObjectPool.java
+++ b/src/main/java/org/apache/commons/pool2/ObjectPool.java
@@ -60,6 +60,22 @@ import java.util.NoSuchElementException;
public interface ObjectPool<T> extends Closeable {
/**
+ * Creates an object using the {@link PooledObjectFactory factory} or other
+ * implementation dependent mechanism, passivate it, and then place it in
+ * the idle object pool. <code>addObject</code> is useful for "pre-loading"
+ * a pool with idle objects. (Optional operation).
+ *
+ * @throws Exception
+ * when {@link PooledObjectFactory#makeObject} fails.
+ * @throws IllegalStateException
+ * after {@link #close} has been called on this pool.
+ * @throws UnsupportedOperationException
+ * when this pool cannot add new idle objects.
+ */
+ void addObject() throws Exception, IllegalStateException,
+ UnsupportedOperationException;
+
+ /**
* Obtains an instance from this pool.
* <p>
* Instances returned from this method will have been either newly created
@@ -94,56 +110,36 @@ public interface ObjectPool<T> extends Closeable {
IllegalStateException;
/**
- * Returns an instance to the pool. By contract, <code>obj</code>
- * <strong>must</strong> have been obtained using {@link #borrowObject()} or
- * a related method as defined in an implementation or sub-interface.
- *
- * @param obj a {@link #borrowObject borrowed} instance to be returned.
+ * Clears any objects sitting idle in the pool, releasing any associated
+ * resources (optional operation). Idle objects cleared must be
+ * {@link PooledObjectFactory#destroyObject(PooledObject)}.
*
- * @throws IllegalStateException
- * if an attempt is made to return an object to the pool that
- * is in any state other than allocated (i.e. borrowed).
- * Attempting to return an object more than once or attempting
- * to return an object that was never borrowed from the pool
- * will trigger this exception.
+ * @throws UnsupportedOperationException
+ * if this implementation does not support the operation
*
- * @throws Exception if an instance cannot be returned to the pool
+ * @throws Exception if the pool cannot be cleared
*/
- void returnObject(T obj) throws Exception;
+ void clear() throws Exception, UnsupportedOperationException;
/**
- * Invalidates an object from the pool.
+ * Closes this pool, and free any resources associated with it.
* <p>
- * By contract, <code>obj</code> <strong>must</strong> have been obtained
- * using {@link #borrowObject} or a related method as defined in an
- * implementation or sub-interface.
+ * Calling {@link #addObject} or {@link #borrowObject} after invoking this
+ * method on a pool will cause them to throw an {@link IllegalStateException}.
* </p>
* <p>
- * This method should be used when an object that has been borrowed is
- * determined (due to an exception or other problem) to be invalid.
+ * Implementations should silently fail if not all resources can be freed.
* </p>
- *
- * @param obj a {@link #borrowObject borrowed} instance to be disposed.
- *
- * @throws Exception if the instance cannot be invalidated
*/
- void invalidateObject(T obj) throws Exception;
+ @Override
+ void close();
/**
- * Creates an object using the {@link PooledObjectFactory factory} or other
- * implementation dependent mechanism, passivate it, and then place it in
- * the idle object pool. <code>addObject</code> is useful for "pre-loading"
- * a pool with idle objects. (Optional operation).
- *
- * @throws Exception
- * when {@link PooledObjectFactory#makeObject} fails.
- * @throws IllegalStateException
- * after {@link #close} has been called on this pool.
- * @throws UnsupportedOperationException
- * when this pool cannot add new idle objects.
+ * Returns the number of instances currently borrowed from this pool. Returns
+ * a negative value if this information is not available.
+ * @return the number of instances currently borrowed from this pool.
*/
- void addObject() throws Exception, IllegalStateException,
- UnsupportedOperationException;
+ int getNumActive();
/**
* Returns the number of instances currently idle in this pool. This may be
@@ -155,34 +151,38 @@ public interface ObjectPool<T> extends Closeable {
int getNumIdle();
/**
- * Returns the number of instances currently borrowed from this pool. Returns
- * a negative value if this information is not available.
- * @return the number of instances currently borrowed from this pool.
- */
- int getNumActive();
-
- /**
- * Clears any objects sitting idle in the pool, releasing any associated
- * resources (optional operation). Idle objects cleared must be
- * {@link PooledObjectFactory#destroyObject(PooledObject)}.
+ * Invalidates an object from the pool.
+ * <p>
+ * By contract, <code>obj</code> <strong>must</strong> have been obtained
+ * using {@link #borrowObject} or a related method as defined in an
+ * implementation or sub-interface.
+ * </p>
+ * <p>
+ * This method should be used when an object that has been borrowed is
+ * determined (due to an exception or other problem) to be invalid.
+ * </p>
*
- * @throws UnsupportedOperationException
- * if this implementation does not support the operation
+ * @param obj a {@link #borrowObject borrowed} instance to be disposed.
*
- * @throws Exception if the pool cannot be cleared
+ * @throws Exception if the instance cannot be invalidated
*/
- void clear() throws Exception, UnsupportedOperationException;
+ void invalidateObject(T obj) throws Exception;
/**
- * Closes this pool, and free any resources associated with it.
- * <p>
- * Calling {@link #addObject} or {@link #borrowObject} after invoking this
- * method on a pool will cause them to throw an {@link IllegalStateException}.
- * </p>
- * <p>
- * Implementations should silently fail if not all resources can be freed.
- * </p>
+ * Returns an instance to the pool. By contract, <code>obj</code>
+ * <strong>must</strong> have been obtained using {@link #borrowObject()} or
+ * a related method as defined in an implementation or sub-interface.
+ *
+ * @param obj a {@link #borrowObject borrowed} instance to be returned.
+ *
+ * @throws IllegalStateException
+ * if an attempt is made to return an object to the pool that
+ * is in any state other than allocated (i.e. borrowed).
+ * Attempting to return an object more than once or attempting
+ * to return an object that was never borrowed from the pool
+ * will trigger this exception.
+ *
+ * @throws Exception if an instance cannot be returned to the pool
*/
- @Override
- void close();
+ void returnObject(T obj) throws Exception;
}