📄 poolutils.html
字号:
<A NAME="adapt(org.apache.commons.pool.PoolableObjectFactory)"><!-- --></A><H3>adapt</H3><PRE>public static <A HREF="../../../../org/apache/commons/pool/KeyedPoolableObjectFactory.html" title="interface in org.apache.commons.pool">KeyedPoolableObjectFactory</A> <B>adapt</B>(<A HREF="../../../../org/apache/commons/pool/PoolableObjectFactory.html" title="interface in org.apache.commons.pool">PoolableObjectFactory</A> factory) throws <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></PRE><DL><DD>Adapt a <code>PoolableObjectFactory</code> instance to work where a <code>KeyedPoolableObjectFactory</code> is needed. The key is ignored.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>factory</CODE> - the <A HREF="../../../../org/apache/commons/pool/PoolableObjectFactory.html" title="interface in org.apache.commons.pool"><CODE>PoolableObjectFactory</CODE></A> to delegate to.<DT><B>Returns:</B><DD>a <A HREF="../../../../org/apache/commons/pool/KeyedPoolableObjectFactory.html" title="interface in org.apache.commons.pool"><CODE>KeyedPoolableObjectFactory</CODE></A> that delegates to <code>factory</code> ignoring the key.<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - when <code>factory</code> is <code>null</code>.<DT><B>Since:</B></DT> <DD>Pool 1.3</DD></DL></DD></DL><HR><A NAME="adapt(org.apache.commons.pool.KeyedObjectPool)"><!-- --></A><H3>adapt</H3><PRE>public static <A HREF="../../../../org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool">ObjectPool</A> <B>adapt</B>(<A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool">KeyedObjectPool</A> keyedPool) throws <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></PRE><DL><DD>Adapt a <code>KeyedObjectPool</code> instance to work where an <code>ObjectPool</code> is needed. This is the equivalent of calling <A HREF="../../../../org/apache/commons/pool/PoolUtils.html#adapt(org.apache.commons.pool.KeyedObjectPool, java.lang.Object)"><CODE>PoolUtils.adapt(aKeyedObjectPool, new Object())</CODE></A>.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>keyedPool</CODE> - the <A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool"><CODE>KeyedObjectPool</CODE></A> to delegate to.<DT><B>Returns:</B><DD>an <A HREF="../../../../org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool"><CODE>ObjectPool</CODE></A> that delegates to <code>keyedPool</code> with an internal key.<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - when <code>keyedPool</code> is <code>null</code>.<DT><B>Since:</B></DT> <DD>Pool 1.3</DD><DT><B>See Also:</B><DD><A HREF="../../../../org/apache/commons/pool/PoolUtils.html#adapt(org.apache.commons.pool.KeyedObjectPool, java.lang.Object)"><CODE>adapt(KeyedObjectPool, Object)</CODE></A></DL></DD></DL><HR><A NAME="adapt(org.apache.commons.pool.KeyedObjectPool, java.lang.Object)"><!-- --></A><H3>adapt</H3><PRE>public static <A HREF="../../../../org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool">ObjectPool</A> <B>adapt</B>(<A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool">KeyedObjectPool</A> keyedPool, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> key) throws <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></PRE><DL><DD>Adapt a <code>KeyedObjectPool</code> instance to work where an <code>ObjectPool</code> is needed using the specified <code>key</code> when delegating.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>keyedPool</CODE> - the <A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool"><CODE>KeyedObjectPool</CODE></A> to delegate to.<DD><CODE>key</CODE> - the key to use when delegating.<DT><B>Returns:</B><DD>an <A HREF="../../../../org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool"><CODE>ObjectPool</CODE></A> that delegates to <code>keyedPool</code> with the specified key.<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - when <code>keyedPool</code> or <code>key</code> is <code>null</code>.<DT><B>Since:</B></DT> <DD>Pool 1.3</DD><DT><B>See Also:</B><DD><A HREF="../../../../org/apache/commons/pool/PoolUtils.html#adapt(org.apache.commons.pool.KeyedObjectPool)"><CODE>adapt(KeyedObjectPool)</CODE></A></DL></DD></DL><HR><A NAME="adapt(org.apache.commons.pool.ObjectPool)"><!-- --></A><H3>adapt</H3><PRE>public static <A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool">KeyedObjectPool</A> <B>adapt</B>(<A HREF="../../../../org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool">ObjectPool</A> pool) throws <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></PRE><DL><DD>Adapt an <code>ObjectPool</code> to work where an <code>KeyedObjectPool</code> is needed. The key is ignored.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>pool</CODE> - the <A HREF="../../../../org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool"><CODE>ObjectPool</CODE></A> to delegate to.<DT><B>Returns:</B><DD>a <A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool"><CODE>KeyedObjectPool</CODE></A> that delegates to <code>keyedPool</code> ignoring the key.<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - when <code>keyedPool</code> is <code>null</code>.<DT><B>Since:</B></DT> <DD>Pool 1.3</DD></DL></DD></DL><HR><A NAME="checkedPool(org.apache.commons.pool.ObjectPool, java.lang.Class)"><!-- --></A><H3>checkedPool</H3><PRE>public static <A HREF="../../../../org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool">ObjectPool</A> <B>checkedPool</B>(<A HREF="../../../../org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool">ObjectPool</A> pool, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A> type)</PRE><DL><DD>Wraps an <code>ObjectPool</code> and dynamically checks the type of objects borrowed and returned to the keyedPool. If an object is passed to the keyedPool that isn't of type <code>type</code> a <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/ClassCastException.html" title="class or interface in java.lang"><CODE>ClassCastException</CODE></A> will be thrown.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>pool</CODE> - the keyedPool to enforce type safety on<DT><B>Returns:</B><DD>an <code>ObjectPool</code> that will only allow objects of <code>type</code><DT><B>Since:</B></DT> <DD>Pool 1.3</DD></DL></DD></DL><HR><A NAME="checkedPool(org.apache.commons.pool.KeyedObjectPool, java.lang.Class)"><!-- --></A><H3>checkedPool</H3><PRE>public static <A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool">KeyedObjectPool</A> <B>checkedPool</B>(<A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool">KeyedObjectPool</A> keyedPool, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Class.html" title="class or interface in java.lang">Class</A> type)</PRE><DL><DD>Wraps an <code>KeyedObjectPool</code> and dynamically checks the type of objects borrowed and returned to the keyedPool. If an object is passed to the keyedPool that isn't of type <code>type</code> a <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/ClassCastException.html" title="class or interface in java.lang"><CODE>ClassCastException</CODE></A> will be thrown.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>keyedPool</CODE> - the keyedPool to enforce type safety on<DT><B>Returns:</B><DD>an <code>KeyedObjectPool</code> that will only allow objects of <code>type</code><DT><B>Since:</B></DT> <DD>Pool 1.3</DD></DL></DD></DL><HR><A NAME="checkMinIdle(org.apache.commons.pool.ObjectPool, int, long)"><!-- --></A><H3>checkMinIdle</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/TimerTask.html" title="class or interface in java.util">TimerTask</A> <B>checkMinIdle</B>(<A HREF="../../../../org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool">ObjectPool</A> pool, int minIdle, long period) throws <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></PRE><DL><DD>Periodically check the idle object count for the keyedPool. At most one idle object will be added per period. If there is an exception when calling <A HREF="../../../../org/apache/commons/pool/ObjectPool.html#addObject()"><CODE>ObjectPool.addObject()</CODE></A> then no more checks will be performed.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>pool</CODE> - the keyedPool to check periodically.<DD><CODE>minIdle</CODE> - if the <A HREF="../../../../org/apache/commons/pool/ObjectPool.html#getNumIdle()"><CODE>ObjectPool.getNumIdle()</CODE></A> is less than this then add an idle object.<DD><CODE>period</CODE> - the frequency to check the number of idle objects in a keyedPool, see <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Timer.html#schedule(java.util.TimerTask, long, long)" title="class or interface in java.util"><CODE>Timer.schedule(TimerTask, long, long)</CODE></A>.<DT><B>Returns:</B><DD>the <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/TimerTask.html" title="class or interface in java.util"><CODE>TimerTask</CODE></A> that will periodically check the pools idle object count.<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - when <code>keyedPool</code> is <code>null</code> or when <code>minIdle</code> is negative or when <code>period</code> isn't valid for <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Timer.html#schedule(java.util.TimerTask, long, long)" title="class or interface in java.util"><CODE>Timer.schedule(TimerTask, long, long)</CODE></A>.<DT><B>Since:</B></DT> <DD>Pool 1.3</DD></DL></DD></DL><HR><A NAME="checkMinIdle(org.apache.commons.pool.KeyedObjectPool, java.lang.Object, int, long)"><!-- --></A><H3>checkMinIdle</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/TimerTask.html" title="class or interface in java.util">TimerTask</A> <B>checkMinIdle</B>(<A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool">KeyedObjectPool</A> keyedPool, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> key, int minIdle, long period) throws <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></PRE><DL><DD>Periodically check the idle object count for the key in the keyedPool. At most one idle object will be added per period. If there is an exception when calling <A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html#addObject(java.lang.Object)"><CODE>KeyedObjectPool.addObject(Object)</CODE></A> then no more checks for that key will be performed.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>keyedPool</CODE> - the keyedPool to check periodically.<DD><CODE>key</CODE> - the key to check the idle count of.<DD><CODE>minIdle</CODE> - if the <A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html#getNumIdle(java.lang.Object)"><CODE>KeyedObjectPool.getNumIdle(Object)</CODE></A> is less than this then add an idle object.<DD><CODE>period</CODE> - the frequency to check the number of idle objects in a keyedPool, see <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Timer.html#schedule(java.util.TimerTask, long, long)" title="class or interface in java.util"><CODE>Timer.schedule(TimerTask, long, long)</CODE></A>.<DT><B>Returns:</B><DD>the <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/TimerTask.html" title="class or interface in java.util"><CODE>TimerTask</CODE></A> that will periodically check the pools idle object count.<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - when <code>keyedPool</code>, <code>key</code> is <code>null</code> or when <code>minIdle</code> is negative or when <code>period</code> isn't valid for <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Timer.html#schedule(java.util.TimerTask, long, long)" title="class or interface in java.util"><CODE>Timer.schedule(TimerTask, long, long)</CODE></A>.<DT><B>Since:</B></DT> <DD>Pool 1.3</DD></DL></DD></DL><HR><A NAME="checkMinIdle(org.apache.commons.pool.KeyedObjectPool, java.util.Collection, int, long)"><!-- --></A><H3>checkMinIdle</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Map.html" title="class or interface in java.util">Map</A> <B>checkMinIdle</B>(<A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html" title="interface in org.apache.commons.pool">KeyedObjectPool</A> keyedPool, <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A> keys, int minIdle, long period) throws <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></PRE><DL><DD>Periodically check the idle object count for each key in the <code>Collection</code> <code>keys</code> in the keyedPool. At most one idle object will be added per period.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>keyedPool</CODE> - the keyedPool to check periodically.<DD><CODE>keys</CODE> - a collection of keys to check the idle object count.<DD><CODE>minIdle</CODE> - if the <A HREF="../../../../org/apache/commons/pool/KeyedObjectPool.html#getNumIdle(java.lang.Object)"><CODE>KeyedObjectPool.getNumIdle(Object)</CODE></A> is less than this then add an idle object.<DD><CODE>period</CODE> - the frequency to check the number of idle objects in a keyedPool, see <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Timer.html#schedule(java.util.TimerTask, long, long)" title="class or interface in java.util"><CODE>Timer.schedule(TimerTask, long, long)</CODE></A>.<DT><B>Returns:</B><DD>a <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Map.html" title="class or interface in java.util"><CODE>Map</CODE></A> of key and <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/TimerTask.html" title="class or interface in java.util"><CODE>TimerTask</CODE></A> pairs that will periodically check the pools idle object count.<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - when <code>keyedPool</code>, <code>keys</code>, or any of the values in the collection is <code>null</code> or when <code>minIdle</code> is negative or when <code>period</code> isn't valid for <A HREF="http://java.sun.com/j2se/1.3/docs/api/java/util/Timer.html#schedule(java.util.TimerTask, long, long)" title="class or interface in java.util"><CODE>Timer.schedule(TimerTask, long, long)</CODE></A>.<DT><B>Since:</B></DT> <DD>Pool 1.3</DD><DT><B>See Also:</B><DD><A HREF="../../../../org/apache/commons/pool/PoolUtils.html#checkMinIdle(org.apache.commons.pool.KeyedObjectPool, java.lang.Object, int, long)"><CODE>checkMinIdle(KeyedObjectPool, Object, int, long)</CODE></A></DL></DD></DL><HR><A NAME="prefill(org.apache.commons.pool.ObjectPool, int)"><!-- --></A><H3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -