commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1051663 - /commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/
Date Tue, 21 Dec 2010 21:42:43 GMT
Author: simonetripodi
Date: Tue Dec 21 21:42:42 2010
New Revision: 1051663

URL: http://svn.apache.org/viewvc?rev=1051663&view=rev
Log:
stated JMX support adding pools MBean interfaces

Added:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java   (with props)
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolMBean.java   (with props)
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolMBean.java   (with props)
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolMBean.java   (with props)
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/GenericObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.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=1051663&r1=1051662&r2=1051663&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 Tue Dec 21 21:42:42 2010
@@ -199,7 +199,7 @@ import org.apache.commons.pool2.PoolUtil
  * @version $Revision$ $Date$
  * @since Pool 1.0
  */
-public class GenericKeyedObjectPool<K,V> extends BaseKeyedObjectPool<K,V> implements KeyedObjectPool<K,V> {
+public class GenericKeyedObjectPool<K,V> extends BaseKeyedObjectPool<K,V> implements KeyedObjectPool<K,V>, GenericKeyedObjectPoolMBean<K> {
 
     //--- constructors -----------------------------------------------
 
@@ -251,29 +251,14 @@ public class GenericKeyedObjectPool<K,V>
     //--- configuration methods --------------------------------------
 
     /**
-     * Returns the cap on the number of object instances allocated by the pool
-     * (checked out or idle),  per key.
-     * A negative value indicates no limit.
-     *
-     * @return the cap on the number of active instances per key.
-     * @see #setMaxTotalPerKey
-     * @since 2.0
+     * {@inheritDoc}
      */
     public synchronized int getMaxTotalPerKey() {
         return this.maxTotalPerKey;
     }
 
     /**
-     * Sets the cap on the total number of instances from all pools combined.
-     * When <code>maxTotal</code> is set to a
-     * positive value and {@link #borrowObject borrowObject} is invoked
-     * when at the limit with no idle instances available, an attempt is made to
-     * create room by clearing the oldest 15% of the elements from the keyed
-     * pools.
-     *
-     * @param maxTotal The cap on the total number of instances across pools.
-     * Use a negative value for no limit.
-     * @see #getMaxTotal
+     * {@inheritDoc}
      */
     public synchronized void setMaxTotalPerKey(int maxTotalPerKey) {
         this.maxTotalPerKey = maxTotalPerKey;
@@ -281,26 +266,14 @@ public class GenericKeyedObjectPool<K,V>
     }
 
     /**
-     * Returns the overall maximum number of objects (across pools) that can
-     * exist at one time. A negative value indicates no limit.
-     * @return the maximum number of instances in circulation at one time.
-     * @see #setMaxTotal
+     * {@inheritDoc}
      */
     public synchronized int getMaxTotal() {
         return this.maxTotal;
     }
 
     /**
-     * Sets the cap on the total number of instances from all pools combined.
-     * When <code>maxTotal</code> is set to a
-     * positive value and {@link #borrowObject borrowObject} is invoked
-     * when at the limit with no idle instances available, an attempt is made to
-     * create room by clearing the oldest 15% of the elements from the keyed
-     * pools.
-     *
-     * @param maxTotal The cap on the total number of instances across pools.
-     * Use a negative value for no limit.
-     * @see #getMaxTotal
+     * {@inheritDoc}
      */
     public synchronized void setMaxTotal(int maxTotal) {
         this.maxTotal = maxTotal;
@@ -308,25 +281,14 @@ public class GenericKeyedObjectPool<K,V>
     }
 
     /**
-     * Returns the action to take when the {@link #borrowObject} method
-     * is invoked when the pool is exhausted (the maximum number
-     * of "active" objects has been reached).
-     *
-     * @return one of {@link WhenExhaustedAction#BLOCK},
-     * {@link WhenExhaustedAction#FAIL} or {@link WhenExhaustedAction#GROW}
-     * @see #setWhenExhaustedAction
+     * {@inheritDoc}
      */
     public synchronized WhenExhaustedAction getWhenExhaustedAction() {
         return this.whenExhaustedAction;
     }
 
     /**
-     * Sets the action to take when the {@link #borrowObject} method
-     * is invoked when the pool is exhausted (the maximum number
-     * of "active" objects has been reached).
-     *
-     * @param whenExhaustedAction the action code
-     * @see #getWhenExhaustedAction
+     * {@inheritDoc}
      */
     public synchronized void setWhenExhaustedAction(WhenExhaustedAction whenExhaustedAction) {
         this.whenExhaustedAction = whenExhaustedAction;
@@ -335,70 +297,28 @@ public class GenericKeyedObjectPool<K,V>
 
 
     /**
-     * Returns the maximum amount of time (in milliseconds) the
-     * {@link #borrowObject} method should block before throwing
-     * an exception when the pool is exhausted and the
-     * {@link #setWhenExhaustedAction "when exhausted" action} is
-     * {@link WhenExhaustedAction#BLOCK}.
-     *
-     * When less than or equal to 0, the {@link #borrowObject} method
-     * may block indefinitely.
-     *
-     * @return the maximum number of milliseconds borrowObject will block.
-     * @see #setMaxWait
-     * @see #setWhenExhaustedAction
-     * @see WhenExhaustedAction#BLOCK
+     * {@inheritDoc}
      */
     public synchronized long getMaxWait() {
         return this.maxWait;
     }
 
     /**
-     * Sets the maximum amount of time (in milliseconds) the
-     * {@link #borrowObject} method should block before throwing
-     * an exception when the pool is exhausted and the
-     * {@link #setWhenExhaustedAction "when exhausted" action} is
-     * {@link WhenExhaustedAction#BLOCK}.
-     *
-     * When less than or equal to 0, the {@link #borrowObject} method
-     * may block indefinitely.
-     *
-     * @param maxWait the maximum number of milliseconds borrowObject will block or negative for indefinitely.
-     * @see #getMaxWait
-     * @see #setWhenExhaustedAction
-     * @see WhenExhaustedAction#BLOCK
+     * {@inheritDoc}
      */
     public synchronized void setMaxWait(long maxWait) {
         this.maxWait = maxWait;
     }
 
     /**
-     * Returns the cap on the number of "idle" instances per key.
-     * @return the maximum number of "idle" instances that can be held
-     * in a given keyed pool.
-     * @see #setMaxIdle
-     *
-     * @since 2.0
+     * {@inheritDoc}
      */
     public synchronized int getMaxIdlePerKey() {
         return this.maxIdlePerKey;
     }
 
     /**
-     * Sets the cap on the number of "idle" instances in the pool.
-     * If maxIdle is set too low on heavily loaded systems it is possible you
-     * will see objects being destroyed and almost immediately new objects
-     * being created. This is a result of the active threads momentarily
-     * returning objects faster than they are requesting them them, causing the
-     * number of idle objects to rise above maxIdle. The best value for maxIdle
-     * for heavily loaded system will vary but the default is a good starting
-     * point.
-     * @param maxIdlePerKey the maximum number of "idle" instances that can be held
-     * in a given keyed pool. Use a negative value for no limit.
-     * @see #getMaxIdle
-     * @see #DEFAULT_MAX_IDLE_PER_KEY
-     *
-     * @since 2.0
+     * {@inheritDoc}
      */
     public synchronized void setMaxIdlePerKey(int maxIdlePerKey) {
         this.maxIdlePerKey = maxIdlePerKey;
@@ -406,115 +326,56 @@ public class GenericKeyedObjectPool<K,V>
     }
 
     /**
-     * Sets the minimum number of idle objects to maintain in each of the keyed
-     * pools. This setting has no effect unless
-     * <code>timeBetweenEvictionRunsMillis > 0</code> and attempts to ensure
-     * that each pool has the required minimum number of instances are only
-     * made during idle object eviction runs.
-     * @param minIdlePerKey - The minimum size of the each keyed pool
-     * @since Pool 1.3
-     * @see #getMinIdle
-     * @see #setTimeBetweenEvictionRunsMillis
-     *
-     * @since 2.0
+     * {@inheritDoc}
      */
     public synchronized void setMinIdle(int minIdlePerKey) {
         this.minIdlePerKey = minIdlePerKey;
     }
 
     /**
-     * Returns the minimum number of idle objects to maintain in each of the keyed
-     * pools. This setting has no effect unless
-     * <code>timeBetweenEvictionRunsMillis > 0</code> and attempts to ensure
-     * that each pool has the required minimum number of instances are only
-     * made during idle object eviction runs.
-     * @return minimum size of the each keyed pool
-     * @since Pool 1.3
-     * @see #setTimeBetweenEvictionRunsMillis
-     *
-     * @since 2.0
+     * {@inheritDoc}
      */
     public synchronized int getMinIdlePerKey() {
         return this.minIdlePerKey;
     }
 
     /**
-     * When <code>true</code>, objects will be
-     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
-     * before being returned by the {@link #borrowObject}
-     * method.  If the object fails to validate,
-     * it will be dropped from the pool, and we will attempt
-     * to borrow another.
-     *
-     * @return <code>true</code> if objects are validated before being borrowed.
-     * @see #setTestOnBorrow
+     * {@inheritDoc}
      */
     public synchronized boolean getTestOnBorrow() {
         return this.testOnBorrow;
     }
 
     /**
-     * When <code>true</code>, objects will be
-     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
-     * before being returned by the {@link #borrowObject}
-     * method.  If the object fails to validate,
-     * it will be dropped from the pool, and we will attempt
-     * to borrow another.
-     *
-     * @param testOnBorrow whether object should be validated before being returned by borrowObject.
-     * @see #getTestOnBorrow
+     * {@inheritDoc}
      */
     public synchronized void setTestOnBorrow(boolean testOnBorrow) {
         this.testOnBorrow = testOnBorrow;
     }
 
     /**
-     * When <code>true</code>, objects will be
-     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
-     * before being returned to the pool within the
-     * {@link #returnObject}.
-     *
-     * @return <code>true</code> when objects will be validated before being returned.
-     * @see #setTestOnReturn
+     * {@inheritDoc}
      */
     public synchronized boolean getTestOnReturn() {
         return this.testOnReturn;
     }
 
     /**
-     * When <code>true</code>, objects will be
-     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
-     * before being returned to the pool within the
-     * {@link #returnObject}.
-     *
-     * @param testOnReturn <code>true</code> so objects will be validated before being returned.
-     * @see #getTestOnReturn
+     * {@inheritDoc}
      */
     public synchronized void setTestOnReturn(boolean testOnReturn) {
         this.testOnReturn = testOnReturn;
     }
 
     /**
-     * Returns the number of milliseconds to sleep between runs of the
-     * idle object evictor thread.
-     * When non-positive, no idle object evictor thread will be
-     * run.
-     *
-     * @return milliseconds to sleep between evictor runs.
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized long getTimeBetweenEvictionRunsMillis() {
         return this.timeBetweenEvictionRunsMillis;
     }
 
     /**
-     * Sets the number of milliseconds to sleep between runs of the
-     * idle object evictor thread.
-     * When non-positive, no idle object evictor thread will be
-     * run.
-     *
-     * @param timeBetweenEvictionRunsMillis milliseconds to sleep between evictor runs.
-     * @see #getTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
         this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
@@ -522,120 +383,60 @@ public class GenericKeyedObjectPool<K,V>
     }
 
     /**
-     * Returns the max number of objects to examine during each run of the
-     * idle object evictor thread (if any).
-     *
-     * @return number of objects to examine each eviction run.
-     * @see #setNumTestsPerEvictionRun
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized int getNumTestsPerEvictionRun() {
         return this.numTestsPerEvictionRun;
     }
 
     /**
-     * Sets the max number of objects to examine during each run of the
-     * idle object evictor thread (if any).
-     * <p>
-     * When a negative value is supplied, 
-     * <code>ceil({@link #getNumIdle()})/abs({@link #getNumTestsPerEvictionRun})</code>
-     * tests will be run.  I.e., when the value is <code>-n</code>, roughly one <code>n</code>th of the
-     * idle objects will be tested per run.  When the value is positive, the number of tests
-     * actually performed in each run will be the minimum of this value and the number of instances
-     * idle in the pools.
-     *
-     * @param numTestsPerEvictionRun number of objects to examine each eviction run.
-     * @see #setNumTestsPerEvictionRun
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
         this.numTestsPerEvictionRun = numTestsPerEvictionRun;
     }
 
     /**
-     * Returns the minimum amount of time an object may sit idle in the pool
-     * before it is eligible for eviction by the idle object evictor
-     * (if any).
-     *
-     * @return minimum amount of time an object may sit idle in the pool before it is eligible for eviction.
-     * @see #setMinEvictableIdleTimeMillis
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized long getMinEvictableIdleTimeMillis() {
         return this.minEvictableIdleTimeMillis;
     }
 
     /**
-     * Sets the minimum amount of time an object may sit idle in the pool
-     * before it is eligible for eviction by the idle object evictor
-     * (if any).
-     * When non-positive, no objects will be evicted from the pool
-     * due to idle time alone.
-     *
-     * @param minEvictableIdleTimeMillis minimum amount of time an object may sit idle in the pool before
-     * it is eligible for eviction.
-     * @see #getMinEvictableIdleTimeMillis
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
         this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
     }
 
     /**
-     * When <code>true</code>, objects will be
-     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
-     * by the idle object evictor (if any).  If an object
-     * fails to validate, it will be dropped from the pool.
-     *
-     * @return <code>true</code> when objects are validated when borrowed.
-     * @see #setTestWhileIdle
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized boolean getTestWhileIdle() {
         return this.testWhileIdle;
     }
 
     /**
-     * When <code>true</code>, objects will be
-     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
-     * by the idle object evictor (if any).  If an object
-     * fails to validate, it will be dropped from the pool.
-     *
-     * @param testWhileIdle <code>true</code> so objects are validated when borrowed.
-     * @see #getTestWhileIdle
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized void setTestWhileIdle(boolean testWhileIdle) {
         this.testWhileIdle = testWhileIdle;
     }
 
     /**
-     * Whether or not the idle object pools act as LIFO queues. True means
-     * that borrowObject returns the most recently used ("last in") idle object
-     * in a pool (if there are idle instances available).  False means that
-     * the pools behave as FIFO queues - objects are taken from idle object
-     * pools in the order that they are returned.
-     *
-     * @return <code>true</code> if the pools are configured to act as LIFO queues
-     * @since 1.4
-     */
-     public synchronized boolean getLifo() {
-         return this.lifo;
-     }
-
-     /**
-      * Sets the LIFO property of the pools. True means that borrowObject returns
-      * the most recently used ("last in") idle object in a pool (if there are
-      * idle instances available).  False means that the pools behave as FIFO
-      * queues - objects are taken from idle object pools in the order that
-      * they are returned.
-      *
-      * @param lifo the new value for the lifo property
-      * @since 1.4
-      */
-     public synchronized void setLifo(boolean lifo) {
-         this.lifo = lifo;
-     }
+     * {@inheritDoc}
+     */
+    public synchronized boolean getLifo() {
+        return this.lifo;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public synchronized void setLifo(boolean lifo) {
+        this.lifo = lifo;
+    }
 
     //-- ObjectPool methods ------------------------------------------
 
@@ -1071,9 +872,7 @@ public class GenericKeyedObjectPool<K,V>
     }
 
     /**
-     * Returns the total number of instances current borrowed from this pool but not yet returned.
-     *
-     * @return the total number of instances currently borrowed from this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumActive() {
@@ -1081,9 +880,7 @@ public class GenericKeyedObjectPool<K,V>
     }
 
     /**
-     * Returns the total number of instances currently idle in this pool.
-     *
-     * @return the total number of instances currently idle in this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumIdle() {
@@ -1091,11 +888,7 @@ public class GenericKeyedObjectPool<K,V>
     }
 
     /**
-     * Returns the number of instances currently borrowed from but not yet returned
-     * to the pool corresponding to the given <code>key</code>.
-     *
-     * @param key the key to query
-     * @return the number of instances corresponding to the given <code>key</code> currently borrowed in this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumActive(K key) {
@@ -1104,10 +897,7 @@ public class GenericKeyedObjectPool<K,V>
     }
 
     /**
-     * Returns the number of instances corresponding to the given <code>key</code> currently idle in this pool.
-     *
-     * @param key the key to query
-     * @return the number of instances corresponding to the given <code>key</code> currently idle in this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumIdle(K key) {

Added: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java?rev=1051663&view=auto
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java (added)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java Tue Dec 21 21:42:42 2010
@@ -0,0 +1,387 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.pool2.impl;
+
+/**
+ * The <code>GenericKeyedObjectPool</code> JMX interface.
+ *
+ * @version $Revision$ $Date$
+ * @since 2.0
+ */
+public interface GenericKeyedObjectPoolMBean<K> {
+
+    /**
+     * Returns the cap on the number of object instances allocated by the pool
+     * (checked out or idle),  per key.
+     * A negative value indicates no limit.
+     *
+     * @return the cap on the number of active instances per key.
+     * @see #setMaxTotalPerKey
+     * @since 2.0
+     */
+    int getMaxTotalPerKey();
+
+    /**
+     * Sets the cap on the total number of instances from all pools combined.
+     * When <code>maxTotal</code> is set to a
+     * positive value and {@link #borrowObject borrowObject} is invoked
+     * when at the limit with no idle instances available, an attempt is made to
+     * create room by clearing the oldest 15% of the elements from the keyed
+     * pools.
+     *
+     * @param maxTotal The cap on the total number of instances across pools.
+     * Use a negative value for no limit.
+     * @see #getMaxTotal
+     */
+    void setMaxTotalPerKey(int maxTotalPerKey);
+
+    /**
+     * Returns the overall maximum number of objects (across pools) that can
+     * exist at one time. A negative value indicates no limit.
+     * @return the maximum number of instances in circulation at one time.
+     * @see #setMaxTotal
+     */
+    int getMaxTotal();
+
+    /**
+     * Sets the cap on the total number of instances from all pools combined.
+     * When <code>maxTotal</code> is set to a
+     * positive value and {@link #borrowObject borrowObject} is invoked
+     * when at the limit with no idle instances available, an attempt is made to
+     * create room by clearing the oldest 15% of the elements from the keyed
+     * pools.
+     *
+     * @param maxTotal The cap on the total number of instances across pools.
+     * Use a negative value for no limit.
+     * @see #getMaxTotal
+     */
+    void setMaxTotal(int maxTotal);
+
+    /**
+     * Returns the action to take when the {@link #borrowObject} method
+     * is invoked when the pool is exhausted (the maximum number
+     * of "active" objects has been reached).
+     *
+     * @return one of {@link WhenExhaustedAction#BLOCK},
+     * {@link WhenExhaustedAction#FAIL} or {@link WhenExhaustedAction#GROW}
+     * @see #setWhenExhaustedAction
+     */
+    WhenExhaustedAction getWhenExhaustedAction();
+
+    /**
+     * Sets the action to take when the {@link #borrowObject} method
+     * is invoked when the pool is exhausted (the maximum number
+     * of "active" objects has been reached).
+     *
+     * @param whenExhaustedAction the action code
+     * @see #getWhenExhaustedAction
+     */
+    void setWhenExhaustedAction(WhenExhaustedAction whenExhaustedAction);
+
+    /**
+     * Returns the maximum amount of time (in milliseconds) the
+     * {@link #borrowObject} method should block before throwing
+     * an exception when the pool is exhausted and the
+     * {@link #setWhenExhaustedAction "when exhausted" action} is
+     * {@link WhenExhaustedAction#BLOCK}.
+     *
+     * When less than or equal to 0, the {@link #borrowObject} method
+     * may block indefinitely.
+     *
+     * @return the maximum number of milliseconds borrowObject will block.
+     * @see #setMaxWait
+     * @see #setWhenExhaustedAction
+     * @see WhenExhaustedAction#BLOCK
+     */
+    long getMaxWait();
+
+    /**
+     * Sets the maximum amount of time (in milliseconds) the
+     * {@link #borrowObject} method should block before throwing
+     * an exception when the pool is exhausted and the
+     * {@link #setWhenExhaustedAction "when exhausted" action} is
+     * {@link WhenExhaustedAction#BLOCK}.
+     *
+     * When less than or equal to 0, the {@link #borrowObject} method
+     * may block indefinitely.
+     *
+     * @param maxWait the maximum number of milliseconds borrowObject will block or negative for indefinitely.
+     * @see #getMaxWait
+     * @see #setWhenExhaustedAction
+     * @see WhenExhaustedAction#BLOCK
+     */
+    void setMaxWait(long maxWait);
+
+    /**
+     * Returns the cap on the number of "idle" instances per key.
+     * @return the maximum number of "idle" instances that can be held
+     * in a given keyed pool.
+     * @see #setMaxIdle
+     *
+     * @since 2.0
+     */
+    int getMaxIdlePerKey();
+
+    /**
+     * Sets the cap on the number of "idle" instances in the pool.
+     * If maxIdle is set too low on heavily loaded systems it is possible you
+     * will see objects being destroyed and almost immediately new objects
+     * being created. This is a result of the active threads momentarily
+     * returning objects faster than they are requesting them them, causing the
+     * number of idle objects to rise above maxIdle. The best value for maxIdle
+     * for heavily loaded system will vary but the default is a good starting
+     * point.
+     * @param maxIdlePerKey the maximum number of "idle" instances that can be held
+     * in a given keyed pool. Use a negative value for no limit.
+     * @see #getMaxIdle
+     * @see #DEFAULT_MAX_IDLE_PER_KEY
+     *
+     * @since 2.0
+     */
+    void setMaxIdlePerKey(int maxIdlePerKey);
+
+    /**
+     * Sets the minimum number of idle objects to maintain in each of the keyed
+     * pools. This setting has no effect unless
+     * <code>timeBetweenEvictionRunsMillis > 0</code> and attempts to ensure
+     * that each pool has the required minimum number of instances are only
+     * made during idle object eviction runs.
+     * @param minIdlePerKey - The minimum size of the each keyed pool
+     * @since Pool 1.3
+     * @see #getMinIdle
+     * @see #setTimeBetweenEvictionRunsMillis
+     *
+     * @since 2.0
+     */
+    void setMinIdle(int minIdlePerKey);
+
+    /**
+     * Returns the minimum number of idle objects to maintain in each of the keyed
+     * pools. This setting has no effect unless
+     * <code>timeBetweenEvictionRunsMillis > 0</code> and attempts to ensure
+     * that each pool has the required minimum number of instances are only
+     * made during idle object eviction runs.
+     * @return minimum size of the each keyed pool
+     * @since Pool 1.3
+     * @see #setTimeBetweenEvictionRunsMillis
+     *
+     * @since 2.0
+     */
+    int getMinIdlePerKey();
+
+    /**
+     * When <code>true</code>, objects will be
+     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
+     * before being returned by the {@link #borrowObject}
+     * method.  If the object fails to validate,
+     * it will be dropped from the pool, and we will attempt
+     * to borrow another.
+     *
+     * @return <code>true</code> if objects are validated before being borrowed.
+     * @see #setTestOnBorrow
+     */
+    boolean getTestOnBorrow();
+
+    /**
+     * When <code>true</code>, objects will be
+     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
+     * before being returned by the {@link #borrowObject}
+     * method.  If the object fails to validate,
+     * it will be dropped from the pool, and we will attempt
+     * to borrow another.
+     *
+     * @param testOnBorrow whether object should be validated before being returned by borrowObject.
+     * @see #getTestOnBorrow
+     */
+    void setTestOnBorrow(boolean testOnBorrow);
+
+    /**
+     * When <code>true</code>, objects will be
+     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
+     * before being returned to the pool within the
+     * {@link #returnObject}.
+     *
+     * @return <code>true</code> when objects will be validated before being returned.
+     * @see #setTestOnReturn
+     */
+    boolean getTestOnReturn();
+
+    /**
+     * When <code>true</code>, objects will be
+     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
+     * before being returned to the pool within the
+     * {@link #returnObject}.
+     *
+     * @param testOnReturn <code>true</code> so objects will be validated before being returned.
+     * @see #getTestOnReturn
+     */
+    void setTestOnReturn(boolean testOnReturn);
+
+    /**
+     * Returns the number of milliseconds to sleep between runs of the
+     * idle object evictor thread.
+     * When non-positive, no idle object evictor thread will be
+     * run.
+     *
+     * @return milliseconds to sleep between evictor runs.
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    long getTimeBetweenEvictionRunsMillis();
+
+    /**
+     * Sets the number of milliseconds to sleep between runs of the
+     * idle object evictor thread.
+     * When non-positive, no idle object evictor thread will be
+     * run.
+     *
+     * @param timeBetweenEvictionRunsMillis milliseconds to sleep between evictor runs.
+     * @see #getTimeBetweenEvictionRunsMillis
+     */
+    void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis);
+
+    /**
+     * Returns the max number of objects to examine during each run of the
+     * idle object evictor thread (if any).
+     *
+     * @return number of objects to examine each eviction run.
+     * @see #setNumTestsPerEvictionRun
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    int getNumTestsPerEvictionRun();
+
+    /**
+     * Sets the max number of objects to examine during each run of the
+     * idle object evictor thread (if any).
+     * <p>
+     * When a negative value is supplied, 
+     * <code>ceil({@link #getNumIdle()})/abs({@link #getNumTestsPerEvictionRun})</code>
+     * tests will be run.  I.e., when the value is <code>-n</code>, roughly one <code>n</code>th of the
+     * idle objects will be tested per run.  When the value is positive, the number of tests
+     * actually performed in each run will be the minimum of this value and the number of instances
+     * idle in the pools.
+     *
+     * @param numTestsPerEvictionRun number of objects to examine each eviction run.
+     * @see #setNumTestsPerEvictionRun
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    void setNumTestsPerEvictionRun(int numTestsPerEvictionRun);
+
+    /**
+     * Returns the minimum amount of time an object may sit idle in the pool
+     * before it is eligible for eviction by the idle object evictor
+     * (if any).
+     *
+     * @return minimum amount of time an object may sit idle in the pool before it is eligible for eviction.
+     * @see #setMinEvictableIdleTimeMillis
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    long getMinEvictableIdleTimeMillis();
+
+    /**
+     * Sets the minimum amount of time an object may sit idle in the pool
+     * before it is eligible for eviction by the idle object evictor
+     * (if any).
+     * When non-positive, no objects will be evicted from the pool
+     * due to idle time alone.
+     *
+     * @param minEvictableIdleTimeMillis minimum amount of time an object may sit idle in the pool before
+     * it is eligible for eviction.
+     * @see #getMinEvictableIdleTimeMillis
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis);
+
+    /**
+     * When <code>true</code>, objects will be
+     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
+     * by the idle object evictor (if any).  If an object
+     * fails to validate, it will be dropped from the pool.
+     *
+     * @return <code>true</code> when objects are validated when borrowed.
+     * @see #setTestWhileIdle
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    boolean getTestWhileIdle();
+
+    /**
+     * When <code>true</code>, objects will be
+     * {@link org.apache.commons.pool2.PoolableObjectFactory#validateObject validated}
+     * by the idle object evictor (if any).  If an object
+     * fails to validate, it will be dropped from the pool.
+     *
+     * @param testWhileIdle <code>true</code> so objects are validated when borrowed.
+     * @see #getTestWhileIdle
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    void setTestWhileIdle(boolean testWhileIdle);
+
+    /**
+     * Whether or not the idle object pools act as LIFO queues. True means
+     * that borrowObject returns the most recently used ("last in") idle object
+     * in a pool (if there are idle instances available).  False means that
+     * the pools behave as FIFO queues - objects are taken from idle object
+     * pools in the order that they are returned.
+     *
+     * @return <code>true</code> if the pools are configured to act as LIFO queues
+     * @since 1.4
+     */
+    boolean getLifo();
+
+    /**
+     * Sets the LIFO property of the pools. True means that borrowObject returns
+     * the most recently used ("last in") idle object in a pool (if there are
+     * idle instances available).  False means that the pools behave as FIFO
+     * queues - objects are taken from idle object pools in the order that
+     * they are returned.
+     *
+     * @param lifo the new value for the lifo property
+     * @since 1.4
+     */
+    void setLifo(boolean lifo);
+
+    /**
+     * Returns the total number of instances current borrowed from this pool but not yet returned.
+     *
+     * @return the total number of instances currently borrowed from this pool
+     */
+    int getNumActive();
+
+    /**
+     * Returns the total number of instances currently idle in this pool.
+     *
+     * @return the total number of instances currently idle in this pool
+     */
+    int getNumIdle();
+
+    /**
+     * Returns the number of instances currently borrowed from but not yet returned
+     * to the pool corresponding to the given <code>key</code>.
+     *
+     * @param key the key to query
+     * @return the number of instances corresponding to the given <code>key</code> currently borrowed in this pool
+     */
+    int getNumActive(K key);
+
+    /**
+     * Returns the number of instances corresponding to the given <code>key</code> currently idle in this pool.
+     *
+     * @param key the key to query
+     * @return the number of instances corresponding to the given <code>key</code> currently idle in this pool
+     */
+    int getNumIdle(K key);
+
+}

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java?rev=1051663&r1=1051662&r2=1051663&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java Tue Dec 21 21:42:42 2010
@@ -185,7 +185,7 @@ import org.apache.commons.pool2.impl.Gen
  * @version $Revision$ $Date$
  * @since Pool 1.0
  */
-public class GenericObjectPool<T> extends BaseObjectPool<T> implements ObjectPool<T> {
+public class GenericObjectPool<T> extends BaseObjectPool<T> implements ObjectPool<T>, GenericObjectPoolMBean<T> {
 
     //--- constructors -----------------------------------------------
 
@@ -233,28 +233,14 @@ public class GenericObjectPool<T> extend
     //--- 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 non-positive, there is no limit to the number of objects that can
-     * be managed by the pool at one time.
-     *
-     * @return the cap on the total number of object instances managed by the pool.
-     * @see #expected
-     * @since 2.0
+     * {@inheritDoc}
      */
     public synchronized int getMaxTotal() {
         return this.maxTotal;
     }
 
     /**
-     * Sets the cap on the number of objects that can be allocated by the pool
-     * (checked out to clients, or idle awaiting checkout) at a given time. Use
-     * a negative value for no limit.
-     *
-     * @param maxTotal The cap on the total number of object instances managed by the pool.
-     * Negative values mean that there is no limit to the number of objects allocated
-     * by the pool.
-     * @see #getMaxTotal
+     * {@inheritDoc}
      */
     public synchronized void setMaxTotal(int maxTotal) {
         this.maxTotal = maxTotal;
@@ -262,26 +248,14 @@ public class GenericObjectPool<T> extend
     }
 
     /**
-     * Returns the action to take when the {@link #borrowObject} method
-     * is invoked when the pool is exhausted (the maximum number
-     * of "active" objects has been reached).
-     *
-     * @return one of {@link WhenExhaustedAction#BLOCK}, {@link WhenExhaustedAction#FAIL} or {@link WhenExhaustedAction#GROW}
-     * @see #setWhenExhaustedAction
+     * {@inheritDoc}
      */
     public synchronized WhenExhaustedAction getWhenExhaustedAction() {
         return this.whenExhaustedAction;
     }
 
     /**
-     * Sets the action to take when the {@link #borrowObject} method
-     * is invoked when the pool is exhausted (the maximum number
-     * of "active" objects has been reached).
-     *
-     * @param whenExhaustedAction the action code, which must be one of
-     *        {@link WhenExhaustedAction#BLOCK}, {@link WhenExhaustedAction#FAIL},
-     *        or {@link WhenExhaustedAction#GROW}
-     * @see #getWhenExhaustedAction
+     * {@inheritDoc}
      */
     public synchronized void setWhenExhaustedAction(WhenExhaustedAction whenExhaustedAction) {
         this.whenExhaustedAction = whenExhaustedAction;
@@ -290,38 +264,14 @@ public class GenericObjectPool<T> extend
 
 
     /**
-     * Returns the maximum amount of time (in milliseconds) the
-     * {@link #borrowObject} method should block before throwing
-     * an exception when the pool is exhausted and the
-     * {@link #setWhenExhaustedAction "when exhausted" action} is
-     * {@link WhenExhaustedAction#BLOCK}.
-     *
-     * When less than or equal to 0, the {@link #borrowObject} method
-     * may block indefinitely.
-     *
-     * @return maximum number of milliseconds to block when borrowing an object.
-     * @see #setMaxWait
-     * @see #setWhenExhaustedAction
-     * @see WhenExhaustedAction#BLOCK
+     * {@inheritDoc}
      */
     public synchronized long getMaxWait() {
         return this.maxWait;
     }
 
     /**
-     * Sets the maximum amount of time (in milliseconds) the
-     * {@link #borrowObject} method should block before throwing
-     * an exception when the pool is exhausted and the
-     * {@link #setWhenExhaustedAction "when exhausted" action} is
-     * {@link WhenExhaustedAction#BLOCK}.
-     *
-     * When less than or equal to 0, the {@link #borrowObject} method
-     * may block indefinitely.
-     *
-     * @param maxWait maximum number of milliseconds to block when borrowing an object.
-     * @see #getMaxWait
-     * @see #setWhenExhaustedAction
-     * @see WhenExhaustedAction#BLOCK
+     * {@inheritDoc}
      */
     public synchronized void setMaxWait(long maxWait) {
         this.maxWait = maxWait;
@@ -329,26 +279,14 @@ public class GenericObjectPool<T> extend
     }
 
     /**
-     * Returns the cap on the number of "idle" instances in the pool.
-     * @return the cap on the number of "idle" instances in the pool.
-     * @see #setMaxIdle
+     * {@inheritDoc}
      */
     public synchronized int getMaxIdle() {
         return this.maxIdle;
     }
 
     /**
-     * Sets the cap on the number of "idle" instances in the pool.
-     * If maxIdle is set too low on heavily loaded systems it is possible you
-     * will see objects being destroyed and almost immediately new objects
-     * being created. This is a result of the active threads momentarily
-     * returning objects faster than they are requesting them them, causing the
-     * number of idle objects to rise above maxIdle. The best value for maxIdle
-     * for heavily loaded system will vary but the default is a good starting
-     * point.
-     * @param maxIdle The cap on the number of "idle" instances in the pool.
-     * Use a negative value to indicate an unlimited number of idle instances.
-     * @see #getMaxIdle
+     * {@inheritDoc}
      */
     public synchronized void setMaxIdle(int maxIdle) {
         this.maxIdle = maxIdle;
@@ -356,16 +294,7 @@ public class GenericObjectPool<T> extend
     }
 
     /**
-     * Sets the minimum number of objects allowed in the pool
-     * before the evictor thread (if active) spawns new objects.
-     * Note that no objects are created when
-     * <code>numActive + numIdle >= maxActive.</code>
-     * This setting has no effect if the idle object evictor is disabled
-     * (i.e. if <code>timeBetweenEvictionRunsMillis <= 0</code>).
-     *
-     * @param minIdle The minimum number of objects.
-     * @see #getMinIdle
-     * @see #getTimeBetweenEvictionRunsMillis()
+     * {@inheritDoc}
      */
     public synchronized void setMinIdle(int minIdle) {
         this.minIdle = minIdle;
@@ -373,94 +302,49 @@ public class GenericObjectPool<T> extend
     }
 
     /**
-     * Returns the minimum number of objects allowed in the pool
-     * before the evictor thread (if active) spawns new objects.
-     * (Note no objects are created when: numActive + numIdle >= maxActive)
-     *
-     * @return The minimum number of objects.
-     * @see #setMinIdle
+     * {@inheritDoc}
      */
     public synchronized int getMinIdle() {
         return this.minIdle;
     }
 
     /**
-     * When <tt>true</tt>, objects will be
-     * {@link PoolableObjectFactory#validateObject validated}
-     * before being returned by the {@link #borrowObject}
-     * method.  If the object fails to validate,
-     * it will be dropped from the pool, and we will attempt
-     * to borrow another.
-     *
-     * @return <code>true</code> if objects are validated before being borrowed.
-     * @see #setTestOnBorrow
+     * {@inheritDoc}
      */
     public synchronized boolean getTestOnBorrow() {
         return this.testOnBorrow;
     }
 
     /**
-     * When <tt>true</tt>, objects will be
-     * {@link PoolableObjectFactory#validateObject validated}
-     * before being returned by the {@link #borrowObject}
-     * method.  If the object fails to validate,
-     * it will be dropped from the pool, and we will attempt
-     * to borrow another.
-     *
-     * @param testOnBorrow <code>true</code> if objects should be validated before being borrowed.
-     * @see #getTestOnBorrow
+     * {@inheritDoc}
      */
     public synchronized void setTestOnBorrow(boolean testOnBorrow) {
         this.testOnBorrow = testOnBorrow;
     }
 
     /**
-     * When <tt>true</tt>, objects will be
-     * {@link PoolableObjectFactory#validateObject validated}
-     * before being returned to the pool within the
-     * {@link #returnObject}.
-     *
-     * @return <code>true</code> when objects will be validated after returned to {@link #returnObject}.
-     * @see #setTestOnReturn
+     * {@inheritDoc}
      */
     public synchronized boolean getTestOnReturn() {
         return this.testOnReturn;
     }
 
     /**
-     * When <tt>true</tt>, objects will be
-     * {@link PoolableObjectFactory#validateObject validated}
-     * before being returned to the pool within the
-     * {@link #returnObject}.
-     *
-     * @param testOnReturn <code>true</code> so objects will be validated after returned to {@link #returnObject}.
-     * @see #getTestOnReturn
+     * {@inheritDoc}
      */
     public synchronized void setTestOnReturn(boolean testOnReturn) {
         this.testOnReturn = testOnReturn;
     }
 
     /**
-     * Returns the number of milliseconds to sleep between runs of the
-     * idle object evictor thread.
-     * When non-positive, no idle object evictor thread will be
-     * run.
-     *
-     * @return number of milliseconds to sleep between evictor runs.
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized long getTimeBetweenEvictionRunsMillis() {
         return this.timeBetweenEvictionRunsMillis;
     }
 
     /**
-     * Sets the number of milliseconds to sleep between runs of the
-     * idle object evictor thread.
-     * When non-positive, no idle object evictor thread will be
-     * run.
-     *
-     * @param timeBetweenEvictionRunsMillis number of milliseconds to sleep between evictor runs.
-     * @see #getTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
         this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
@@ -468,149 +352,74 @@ public class GenericObjectPool<T> extend
     }
 
     /**
-     * Returns the max number of objects to examine during each run of the
-     * idle object evictor thread (if any).
-     *
-     * @return max number of objects to examine during each evictor run.
-     * @see #setNumTestsPerEvictionRun
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized int getNumTestsPerEvictionRun() {
         return this.numTestsPerEvictionRun;
     }
 
     /**
-     * Sets the max number of objects to examine during each run of the
-     * idle object evictor thread (if any).
-     * <p>
-     * When a negative value is supplied, <tt>ceil({@link #getNumIdle})/abs({@link #getNumTestsPerEvictionRun})</tt>
-     * tests will be run.  That is, when the value is <i>-n</i>, roughly one <i>n</i>th of the
-     * idle objects will be tested per run. When the value is positive, the number of tests
-     * actually performed in each run will be the minimum of this value and the number of instances
-     * idle in the pool.
-     *
-     * @param numTestsPerEvictionRun max number of objects to examine during each evictor run.
-     * @see #getNumTestsPerEvictionRun
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
         this.numTestsPerEvictionRun = numTestsPerEvictionRun;
     }
 
     /**
-     * Returns the minimum amount of time an object may sit idle in the pool
-     * before it is eligible for eviction by the idle object evictor
-     * (if any).
-     *
-     * @return minimum amount of time an object may sit idle in the pool before it is eligible for eviction.
-     * @see #setMinEvictableIdleTimeMillis
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized long getMinEvictableIdleTimeMillis() {
         return this.minEvictableIdleTimeMillis;
     }
 
     /**
-     * Sets the minimum amount of time an object may sit idle in the pool
-     * before it is eligible for eviction by the idle object evictor
-     * (if any).
-     * When non-positive, no objects will be evicted from the pool
-     * due to idle time alone.
-     * @param minEvictableIdleTimeMillis minimum amount of time an object may sit idle in the pool before
-     * it is eligible for eviction.
-     * @see #getMinEvictableIdleTimeMillis
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
         this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
     }
 
     /**
-     * Returns the minimum amount of time an object may sit idle in the pool
-     * before it is eligible for eviction by the idle object evictor
-     * (if any), with the extra condition that at least
-     * "minIdle" amount of object remain in the pool.
-     *
-     * @return minimum amount of time an object may sit idle in the pool before it is eligible for eviction.
-     * @since Pool 1.3
-     * @see #setSoftMinEvictableIdleTimeMillis
+     * {@inheritDoc}
      */
     public synchronized long getSoftMinEvictableIdleTimeMillis() {
         return this.softMinEvictableIdleTimeMillis;
     }
 
     /**
-     * Sets the minimum amount of time an object may sit idle in the pool
-     * before it is eligible for eviction by the idle object evictor
-     * (if any), with the extra condition that at least
-     * "minIdle" object instances remain in the pool.
-     * When non-positive, no objects will be evicted from the pool
-     * due to idle time alone.
-     *
-     * @param softMinEvictableIdleTimeMillis minimum amount of time an object may sit idle in the pool before
-     * it is eligible for eviction.
-     * @since Pool 1.3
-     * @see #getSoftMinEvictableIdleTimeMillis
+     * {@inheritDoc}
      */
     public synchronized void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis) {
         this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
     }
 
     /**
-     * When <tt>true</tt>, objects will be
-     * {@link PoolableObjectFactory#validateObject validated}
-     * by the idle object evictor (if any).  If an object
-     * fails to validate, it will be dropped from the pool.
-     *
-     * @return <code>true</code> when objects will be validated by the evictor.
-     * @see #setTestWhileIdle
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized boolean getTestWhileIdle() {
         return this.testWhileIdle;
     }
 
     /**
-     * When <tt>true</tt>, objects will be
-     * {@link PoolableObjectFactory#validateObject validated}
-     * by the idle object evictor (if any).  If an object
-     * fails to validate, it will be dropped from the pool.
-     *
-     * @param testWhileIdle <code>true</code> so objects will be validated by the evictor.
-     * @see #getTestWhileIdle
-     * @see #setTimeBetweenEvictionRunsMillis
+     * {@inheritDoc}
      */
     public synchronized void setTestWhileIdle(boolean testWhileIdle) {
         this.testWhileIdle = testWhileIdle;
     }
 
     /**
-     * Whether or not the idle object pool acts as a LIFO queue. True means
-     * that borrowObject returns the most recently used ("last in") idle object
-     * in the pool (if there are idle instances available).  False means that
-     * the pool behaves as a FIFO queue - objects are taken from the idle object
-     * pool in the order that they are returned to the pool.
-     *
-     * @return <code>true</true> if the pool is configured to act as a LIFO queue
-     * @since 1.4
+     * {@inheritDoc}
+     */
+    public synchronized boolean getLifo() {
+        return this.lifo;
+    }
+
+    /**
+     * {@inheritDoc}
      */
-     public synchronized boolean getLifo() {
-         return this.lifo;
-     }
-
-     /**
-      * Sets the LIFO property of the pool. True means that borrowObject returns
-      * the most recently used ("last in") idle object in the pool (if there are
-      * idle instances available).  False means that the pool behaves as a FIFO
-      * queue - objects are taken from the idle object pool in the order that
-      * they are returned to the pool.
-      *
-      * @param lifo the new value for the LIFO property
-      * @since 1.4
-      */
-     public synchronized void setLifo(boolean lifo) {
-         this.lifo = lifo;
-     }
+    public synchronized void setLifo(boolean lifo) {
+        this.lifo = lifo;
+    }
 
     //-- ObjectPool methods ------------------------------------------
 
@@ -918,9 +727,7 @@ public class GenericObjectPool<T> extend
     }
 
     /**
-     * Return the number of instances currently borrowed from this pool.
-     *
-     * @return the number of instances currently borrowed from this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumActive() {
@@ -928,9 +735,7 @@ public class GenericObjectPool<T> extend
     }
 
     /**
-     * Return the number of instances currently idle in this pool.
-     *
-     * @return the number of instances currently idle in this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumIdle() {

Added: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolMBean.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolMBean.java?rev=1051663&view=auto
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolMBean.java (added)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolMBean.java Tue Dec 21 21:42:42 2010
@@ -0,0 +1,364 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.pool2.impl;
+
+import org.apache.commons.pool2.PoolableObjectFactory;
+
+/**
+ * The <code>GenericObjectPool</code> JMX interface.
+ *
+ * @version $Revision$ $Date$
+ * @since 2.0
+ */
+public interface GenericObjectPoolMBean<T> {
+
+    /**
+     * 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 non-positive, there is no limit to the number of objects that can
+     * be managed by the pool at one time.
+     *
+     * @return the cap on the total number of object instances managed by the pool.
+     * @see #expected
+     * @since 2.0
+     */
+    int getMaxTotal();
+
+    /**
+     * Sets the cap on the number of objects that can be allocated by the pool
+     * (checked out to clients, or idle awaiting checkout) at a given time. Use
+     * a negative value for no limit.
+     *
+     * @param maxTotal The cap on the total number of object instances managed by the pool.
+     * Negative values mean that there is no limit to the number of objects allocated
+     * by the pool.
+     * @see #getMaxTotal
+     */
+    void setMaxTotal(int maxTotal);
+
+    /**
+     * Returns the action to take when the {@link #borrowObject} method
+     * is invoked when the pool is exhausted (the maximum number
+     * of "active" objects has been reached).
+     *
+     * @return one of {@link WhenExhaustedAction#BLOCK}, {@link WhenExhaustedAction#FAIL} or {@link WhenExhaustedAction#GROW}
+     * @see #setWhenExhaustedAction
+     */
+    WhenExhaustedAction getWhenExhaustedAction();
+
+    /**
+     * Sets the action to take when the {@link #borrowObject} method
+     * is invoked when the pool is exhausted (the maximum number
+     * of "active" objects has been reached).
+     *
+     * @param whenExhaustedAction the action code, which must be one of
+     *        {@link WhenExhaustedAction#BLOCK}, {@link WhenExhaustedAction#FAIL},
+     *        or {@link WhenExhaustedAction#GROW}
+     * @see #getWhenExhaustedAction
+     */
+    void setWhenExhaustedAction(WhenExhaustedAction whenExhaustedAction);
+
+    /**
+     * Returns the maximum amount of time (in milliseconds) the
+     * {@link #borrowObject} method should block before throwing
+     * an exception when the pool is exhausted and the
+     * {@link #setWhenExhaustedAction "when exhausted" action} is
+     * {@link WhenExhaustedAction#BLOCK}.
+     *
+     * When less than or equal to 0, the {@link #borrowObject} method
+     * may block indefinitely.
+     *
+     * @return maximum number of milliseconds to block when borrowing an object.
+     * @see #setMaxWait
+     * @see #setWhenExhaustedAction
+     * @see WhenExhaustedAction#BLOCK
+     */
+    long getMaxWait();
+
+    /**
+     * Sets the maximum amount of time (in milliseconds) the
+     * {@link #borrowObject} method should block before throwing
+     * an exception when the pool is exhausted and the
+     * {@link #setWhenExhaustedAction "when exhausted" action} is
+     * {@link WhenExhaustedAction#BLOCK}.
+     *
+     * When less than or equal to 0, the {@link #borrowObject} method
+     * may block indefinitely.
+     *
+     * @param maxWait maximum number of milliseconds to block when borrowing an object.
+     * @see #getMaxWait
+     * @see #setWhenExhaustedAction
+     * @see WhenExhaustedAction#BLOCK
+     */
+    void setMaxWait(long maxWait);
+
+    /**
+     * Returns the cap on the number of "idle" instances in the pool.
+     * @return the cap on the number of "idle" instances in the pool.
+     * @see #setMaxIdle
+     */
+    int getMaxIdle();
+
+    /**
+     * Sets the cap on the number of "idle" instances in the pool.
+     * If maxIdle is set too low on heavily loaded systems it is possible you
+     * will see objects being destroyed and almost immediately new objects
+     * being created. This is a result of the active threads momentarily
+     * returning objects faster than they are requesting them them, causing the
+     * number of idle objects to rise above maxIdle. The best value for maxIdle
+     * for heavily loaded system will vary but the default is a good starting
+     * point.
+     * @param maxIdle The cap on the number of "idle" instances in the pool.
+     * Use a negative value to indicate an unlimited number of idle instances.
+     * @see #getMaxIdle
+     */
+    void setMaxIdle(int maxIdle);
+
+    /**
+     * Sets the minimum number of objects allowed in the pool
+     * before the evictor thread (if active) spawns new objects.
+     * Note that no objects are created when
+     * <code>numActive + numIdle >= maxActive.</code>
+     * This setting has no effect if the idle object evictor is disabled
+     * (i.e. if <code>timeBetweenEvictionRunsMillis <= 0</code>).
+     *
+     * @param minIdle The minimum number of objects.
+     * @see #getMinIdle
+     * @see #getTimeBetweenEvictionRunsMillis()
+     */
+    void setMinIdle(int minIdle);
+
+    /**
+     * Returns the minimum number of objects allowed in the pool
+     * before the evictor thread (if active) spawns new objects.
+     * (Note no objects are created when: numActive + numIdle >= maxActive)
+     *
+     * @return The minimum number of objects.
+     * @see #setMinIdle
+     */
+    int getMinIdle();
+
+    /**
+     * When <tt>true</tt>, objects will be
+     * {@link PoolableObjectFactory#validateObject validated}
+     * before being returned by the {@link #borrowObject}
+     * method.  If the object fails to validate,
+     * it will be dropped from the pool, and we will attempt
+     * to borrow another.
+     *
+     * @return <code>true</code> if objects are validated before being borrowed.
+     * @see #setTestOnBorrow
+     */
+    boolean getTestOnBorrow();
+
+    /**
+     * When <tt>true</tt>, objects will be
+     * {@link PoolableObjectFactory#validateObject validated}
+     * before being returned by the {@link #borrowObject}
+     * method.  If the object fails to validate,
+     * it will be dropped from the pool, and we will attempt
+     * to borrow another.
+     *
+     * @param testOnBorrow <code>true</code> if objects should be validated before being borrowed.
+     * @see #getTestOnBorrow
+     */
+    void setTestOnBorrow(boolean testOnBorrow);
+
+    /**
+     * When <tt>true</tt>, objects will be
+     * {@link PoolableObjectFactory#validateObject validated}
+     * before being returned to the pool within the
+     * {@link #returnObject}.
+     *
+     * @return <code>true</code> when objects will be validated after returned to {@link #returnObject}.
+     * @see #setTestOnReturn
+     */
+    boolean getTestOnReturn();
+
+    /**
+     * When <tt>true</tt>, objects will be
+     * {@link PoolableObjectFactory#validateObject validated}
+     * before being returned to the pool within the
+     * {@link #returnObject}.
+     *
+     * @param testOnReturn <code>true</code> so objects will be validated after returned to {@link #returnObject}.
+     * @see #getTestOnReturn
+     */
+    void setTestOnReturn(boolean testOnReturn);
+
+    /**
+     * Returns the number of milliseconds to sleep between runs of the
+     * idle object evictor thread.
+     * When non-positive, no idle object evictor thread will be
+     * run.
+     *
+     * @return number of milliseconds to sleep between evictor runs.
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    long getTimeBetweenEvictionRunsMillis();
+
+    /**
+     * Sets the number of milliseconds to sleep between runs of the
+     * idle object evictor thread.
+     * When non-positive, no idle object evictor thread will be
+     * run.
+     *
+     * @param timeBetweenEvictionRunsMillis number of milliseconds to sleep between evictor runs.
+     * @see #getTimeBetweenEvictionRunsMillis
+     */
+    void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis);
+
+    /**
+     * Returns the max number of objects to examine during each run of the
+     * idle object evictor thread (if any).
+     *
+     * @return max number of objects to examine during each evictor run.
+     * @see #setNumTestsPerEvictionRun
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    int getNumTestsPerEvictionRun();
+
+    /**
+     * Sets the max number of objects to examine during each run of the
+     * idle object evictor thread (if any).
+     * <p>
+     * When a negative value is supplied, <tt>ceil({@link #getNumIdle})/abs({@link #getNumTestsPerEvictionRun})</tt>
+     * tests will be run.  That is, when the value is <i>-n</i>, roughly one <i>n</i>th of the
+     * idle objects will be tested per run. When the value is positive, the number of tests
+     * actually performed in each run will be the minimum of this value and the number of instances
+     * idle in the pool.
+     *
+     * @param numTestsPerEvictionRun max number of objects to examine during each evictor run.
+     * @see #getNumTestsPerEvictionRun
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    void setNumTestsPerEvictionRun(int numTestsPerEvictionRun);
+
+    /**
+     * Returns the minimum amount of time an object may sit idle in the pool
+     * before it is eligible for eviction by the idle object evictor
+     * (if any).
+     *
+     * @return minimum amount of time an object may sit idle in the pool before it is eligible for eviction.
+     * @see #setMinEvictableIdleTimeMillis
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    long getMinEvictableIdleTimeMillis();
+
+    /**
+     * Sets the minimum amount of time an object may sit idle in the pool
+     * before it is eligible for eviction by the idle object evictor
+     * (if any).
+     * When non-positive, no objects will be evicted from the pool
+     * due to idle time alone.
+     * @param minEvictableIdleTimeMillis minimum amount of time an object may sit idle in the pool before
+     * it is eligible for eviction.
+     * @see #getMinEvictableIdleTimeMillis
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis);
+
+    /**
+     * Returns the minimum amount of time an object may sit idle in the pool
+     * before it is eligible for eviction by the idle object evictor
+     * (if any), with the extra condition that at least
+     * "minIdle" amount of object remain in the pool.
+     *
+     * @return minimum amount of time an object may sit idle in the pool before it is eligible for eviction.
+     * @since Pool 1.3
+     * @see #setSoftMinEvictableIdleTimeMillis
+     */
+    long getSoftMinEvictableIdleTimeMillis();
+
+    /**
+     * Sets the minimum amount of time an object may sit idle in the pool
+     * before it is eligible for eviction by the idle object evictor
+     * (if any), with the extra condition that at least
+     * "minIdle" object instances remain in the pool.
+     * When non-positive, no objects will be evicted from the pool
+     * due to idle time alone.
+     *
+     * @param softMinEvictableIdleTimeMillis minimum amount of time an object may sit idle in the pool before
+     * it is eligible for eviction.
+     * @since Pool 1.3
+     * @see #getSoftMinEvictableIdleTimeMillis
+     */
+    void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis);
+
+    /**
+     * When <tt>true</tt>, objects will be
+     * {@link PoolableObjectFactory#validateObject validated}
+     * by the idle object evictor (if any).  If an object
+     * fails to validate, it will be dropped from the pool.
+     *
+     * @return <code>true</code> when objects will be validated by the evictor.
+     * @see #setTestWhileIdle
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    boolean getTestWhileIdle();
+
+    /**
+     * When <tt>true</tt>, objects will be
+     * {@link PoolableObjectFactory#validateObject validated}
+     * by the idle object evictor (if any).  If an object
+     * fails to validate, it will be dropped from the pool.
+     *
+     * @param testWhileIdle <code>true</code> so objects will be validated by the evictor.
+     * @see #getTestWhileIdle
+     * @see #setTimeBetweenEvictionRunsMillis
+     */
+    void setTestWhileIdle(boolean testWhileIdle);
+
+    /**
+     * Whether or not the idle object pool acts as a LIFO queue. True means
+     * that borrowObject returns the most recently used ("last in") idle object
+     * in the pool (if there are idle instances available).  False means that
+     * the pool behaves as a FIFO queue - objects are taken from the idle object
+     * pool in the order that they are returned to the pool.
+     *
+     * @return <code>true</true> if the pool is configured to act as a LIFO queue
+     * @since 1.4
+     */
+    boolean getLifo();
+
+    /**
+     * Sets the LIFO property of the pool. True means that borrowObject returns
+     * the most recently used ("last in") idle object in the pool (if there are
+     * idle instances available).  False means that the pool behaves as a FIFO
+     * queue - objects are taken from the idle object pool in the order that
+     * they are returned to the pool.
+     *
+     * @param lifo the new value for the LIFO property
+     * @since 1.4
+     */
+    void setLifo(boolean lifo);
+
+    /**
+     * Return the number of instances currently borrowed from this pool.
+     *
+     * @return the number of instances currently borrowed from this pool
+     */
+    int getNumActive();
+
+    /**
+     * Return the number of instances currently idle in this pool.
+     *
+     * @return the number of instances currently idle in this pool
+     */
+    int getNumIdle();
+
+}

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPool.java?rev=1051663&r1=1051662&r2=1051663&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPool.java Tue Dec 21 21:42:42 2010
@@ -46,7 +46,7 @@ import org.apache.commons.pool2.PoolUtil
  * @see Stack
  * @since Pool 1.0
  */
-public class StackKeyedObjectPool<K,V> extends BaseKeyedObjectPool<K,V> implements KeyedObjectPool<K,V> {
+public class StackKeyedObjectPool<K,V> extends BaseKeyedObjectPool<K,V> implements KeyedObjectPool<K,V>, StackKeyedObjectPoolMBean<K> {
     /**
      * Create a new <code>SimpleKeyedObjectPool</code> using
      * the specified <code>factory</code> to create new instances
@@ -258,9 +258,7 @@ public class StackKeyedObjectPool<K,V> e
     }
 
     /**
-     * Returns the total number of instances currently idle in this pool.
-     *
-     * @return the total number of instances currently idle in this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumIdle() {
@@ -268,9 +266,7 @@ public class StackKeyedObjectPool<K,V> e
     }
 
     /**
-     * Returns the total number of instances current borrowed from this pool but not yet returned.
-     *
-     * @return the total number of instances currently borrowed from this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumActive() {
@@ -278,11 +274,7 @@ public class StackKeyedObjectPool<K,V> e
     }
 
     /**
-     * Returns the number of instances currently borrowed from but not yet returned
-     * to the pool corresponding to the given <code>key</code>.
-     *
-     * @param key the key to query
-     * @return the number of instances corresponding to the given <code>key</code> currently borrowed in this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumActive(K key) {
@@ -290,10 +282,7 @@ public class StackKeyedObjectPool<K,V> e
     }
 
     /**
-     * Returns the number of instances corresponding to the given <code>key</code> currently idle in this pool.
-     *
-     * @param key the key to query
-     * @return the number of instances corresponding to the given <code>key</code> currently idle in this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumIdle(K key) {
@@ -454,48 +443,42 @@ public class StackKeyedObjectPool<K,V> e
     }
 
     /**
-     * @return the cap on the number of "sleeping" instances in <code>each</code> pool.
-     * @since 1.5.5
+     * {@inheritDoc}
      */
     public synchronized int getMaxSleeping() {
         return this.maxSleeping;
     }
 
     /**
-     * Sets the cap on the number of "sleeping" instances in <code>each</code> pool.
-     *
-     * @param maxSleeping
-     * @since 2.0
+     * {@inheritDoc}
      */
     public synchronized void setMaxSleeping(int maxSleeping) {
         this.maxSleeping = maxSleeping;
     }
 
     /**
-     * @return the initial capacity of each pool.
-     * @since 1.5.5
+     * {@inheritDoc}
      */
     public synchronized int getInitSleepingCapacity() {
         return this.initIdleCapacity;
     }
 
     /**
-     * @return the _totActive
+     * {@inheritDoc}
      */
     public synchronized int getTotActive() {
         return _totActive;
     }
 
     /**
-     * @return the _totIdle
+     * {@inheritDoc}
      */
     public synchronized int getTotIdle() {
         return _totIdle;
     }
 
     /**
-     * @return the _activeCount
-     * @since 1.5.5
+     * {@inheritDoc}
      */
     public synchronized Map<K,Integer> getActiveCount() {
         return _activeCount;

Added: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolMBean.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolMBean.java?rev=1051663&view=auto
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolMBean.java (added)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolMBean.java Tue Dec 21 21:42:42 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.pool2.impl;
+
+import java.util.Map;
+
+/**
+ * The <code>Stack</code>-based <code>KeyedObjectPool</code> JMX interface.
+ *
+ * @version $Revision$ $Date$
+ * @since 2.0
+ */
+public interface StackKeyedObjectPoolMBean<K> extends StackObjectPoolMBean {
+
+    /**
+     * Returns the number of instances currently borrowed from but not yet returned
+     * to the pool corresponding to the given <code>key</code>.
+     *
+     * @param key the key to query
+     * @return the number of instances corresponding to the given <code>key</code> currently borrowed in this pool
+     */
+    int getNumActive(K key);
+
+    /**
+     * Returns the number of instances corresponding to the given <code>key</code> currently idle in this pool.
+     *
+     * @param key the key to query
+     * @return the number of instances corresponding to the given <code>key</code> currently idle in this pool
+     */
+    int getNumIdle(K key);
+
+    /**
+     * @return the initial capacity of each pool.
+     * @since 1.5.5
+     */
+    int getInitSleepingCapacity();
+
+    /**
+     * @return the _totActive
+     */
+    int getTotActive();
+
+    /**
+     * @return the _totIdle
+     */
+    int getTotIdle();
+
+    /**
+     * @return the _activeCount
+     * @since 1.5.5
+     */
+    Map<K, Integer> getActiveCount();
+
+}

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.java?rev=1051663&r1=1051662&r2=1051663&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPool.java Tue Dec 21 21:42:42 2010
@@ -43,7 +43,7 @@ import org.apache.commons.pool2.Poolable
  * @version $Revision$ $Date$
  * @since Pool 1.0
  */
-public class StackObjectPool<T> extends BaseObjectPool<T> implements ObjectPool<T> {
+public class StackObjectPool<T> extends BaseObjectPool<T> implements ObjectPool<T>, StackObjectPoolMBean {
     /**
      * Create a new <tt>StackObjectPool</tt> using the specified <i>factory</i> to create new instances
      * with the default configuration.
@@ -210,10 +210,7 @@ public class StackObjectPool<T> extends 
     }
 
     /**
-     * Return the number of instances
-     * currently idle in this pool.
-     *
-     * @return the number of instances currently idle in this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumIdle() {
@@ -221,9 +218,7 @@ public class StackObjectPool<T> extends 
     }
 
     /**
-     * Return the number of instances currently borrowed from this pool.
-     *
-     * @return the number of instances currently borrowed from this pool
+     * {@inheritDoc}
      */
     @Override
     public synchronized int getNumActive() {
@@ -350,22 +345,16 @@ public class StackObjectPool<T> extends 
     }
 
     /**
-     * Returns the maximum number of idle instances in the pool.
-     * 
-     * @return maxSleeping
-     * @since 1.5.5
+     * {@inheritDoc}
      */
     public synchronized int getMaxSleeping() {
         return this.maxSleeping;
     }
 
     /**
-     * Sets the maximum number of idle instances in the pool.
-     *
-     * @param maxSleeping
-     * @since 2.0
+     * {@inheritDoc}
      */
-   public synchronized void setMaxSleeping(int maxSleeping) {
-       this.maxSleeping = maxSleeping;
-   }
+    public synchronized void setMaxSleeping(int maxSleeping) {
+        this.maxSleeping = maxSleeping;
+    }
 }

Added: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolMBean.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolMBean.java?rev=1051663&view=auto
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolMBean.java (added)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolMBean.java Tue Dec 21 21:42:42 2010
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.pool2.impl;
+
+/**
+ * The <code>Stack</code>-based <code>ObjectPool</code> JMX interface.
+ *
+ * @version $Revision$ $Date$
+ * @since 2.0
+ */
+public interface StackObjectPoolMBean {
+
+    /**
+     * Return the number of instances
+     * currently idle in this pool.
+     *
+     * @return the number of instances currently idle in this pool
+     */
+    int getNumIdle();
+
+    /**
+     * Return the number of instances currently borrowed from this pool.
+     *
+     * @return the number of instances currently borrowed from this pool
+     */
+    int getNumActive();
+
+    /**
+     * Returns the maximum number of idle instances in the pool.
+     * 
+     * @return maxSleeping
+     * @since 1.5.5
+     */
+    int getMaxSleeping();
+
+    /**
+     * Sets the maximum number of idle instances in the pool.
+     *
+     * @param maxSleeping
+     * @since 2.0
+     */
+    void setMaxSleeping(int maxSleeping);
+
+}

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackObjectPoolMBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message