📄 genericobjectpool.html
字号:
<a name="254" href="#254">254</a> <strong>public</strong> <strong>static</strong> <strong>final</strong> <strong>long</strong> DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 1000L * 60L * 30L;<a name="255" href="#255">255</a> <a name="256" href="#256">256</a> <em>/**<em>*</em></em><a name="257" href="#257">257</a> <em> * The default value for {@link #getSoftMinEvictableIdleTimeMillis}.</em><a name="258" href="#258">258</a> <em> * @see #getSoftMinEvictableIdleTimeMillis</em><a name="259" href="#259">259</a> <em> * @see #setSoftMinEvictableIdleTimeMillis</em><a name="260" href="#260">260</a> <em> */</em><a name="261" href="#261">261</a> <strong>public</strong> <strong>static</strong> <strong>final</strong> <strong>long</strong> DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS = -1;<a name="262" href="#262">262</a> <a name="263" href="#263">263</a> <em class="comment">//--- package constants -------------------------------------------</em><a name="264" href="#264">264</a> <a name="265" href="#265">265</a> <em>/**<em>*</em></em><a name="266" href="#266">266</a> <em> * Idle object evition Timer. Shared between all {@link GenericObjectPool}s and {@link GenericKeyedObjectPool} s.</em><a name="267" href="#267">267</a> <em> */</em><a name="268" href="#268">268</a> <strong>static</strong> <strong>final</strong> Timer EVICTION_TIMER = <strong>new</strong> Timer(<strong>true</strong>);<a name="269" href="#269">269</a> <a name="270" href="#270">270</a> <em class="comment">//--- constructors -----------------------------------------------</em><a name="271" href="#271">271</a> <a name="272" href="#272">272</a> <em>/**<em>*</em></em><a name="273" href="#273">273</a> <em> * Create a new <tt>GenericObjectPool</tt>.</em><a name="274" href="#274">274</a> <em> */</em><a name="275" href="#275">275</a> <strong>public</strong> <a href="../../../../../org/apache/commons/pool/impl/GenericObjectPool.html">GenericObjectPool</a>() {<a name="276" href="#276">276</a> <strong>this</strong>(<strong>null</strong>,DEFAULT_MAX_ACTIVE,DEFAULT_WHEN_EXHAUSTED_ACTION,DEFAULT_MAX_WAIT,DEFAULT_MAX_IDLE,DEFAULT_MIN_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);<a name="277" href="#277">277</a> }<a name="278" href="#278">278</a> <a name="279" href="#279">279</a> <em>/**<em>*</em></em><a name="280" href="#280">280</a> <em> * Create a new <tt>GenericObjectPool</tt> using the specified values.</em><a name="281" href="#281">281</a> <em> * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects</em><a name="282" href="#282">282</a> <em> */</em><a name="283" href="#283">283</a> <strong>public</strong> <a href="../../../../../org/apache/commons/pool/impl/GenericObjectPool.html">GenericObjectPool</a>(PoolableObjectFactory factory) {<a name="284" href="#284">284</a> <strong>this</strong>(factory,DEFAULT_MAX_ACTIVE,DEFAULT_WHEN_EXHAUSTED_ACTION,DEFAULT_MAX_WAIT,DEFAULT_MAX_IDLE,DEFAULT_MIN_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);<a name="285" href="#285">285</a> }<a name="286" href="#286">286</a> <a name="287" href="#287">287</a> <em>/**<em>*</em></em><a name="288" href="#288">288</a> <em> * Create a new <tt>GenericObjectPool</tt> using the specified values.</em><a name="289" href="#289">289</a> <em> * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects</em><a name="290" href="#290">290</a> <em> * @param config a non-<tt>null</tt> {@link GenericObjectPool.Config} describing my configuration</em><a name="291" href="#291">291</a> <em> */</em><a name="292" href="#292">292</a> <strong>public</strong> <a href="../../../../../org/apache/commons/pool/impl/GenericObjectPool.html">GenericObjectPool</a>(PoolableObjectFactory factory, GenericObjectPool.Config config) {<a name="293" href="#293">293</a> <strong>this</strong>(factory,config.maxActive,config.whenExhaustedAction,config.maxWait,config.maxIdle,config.minIdle,config.testOnBorrow,config.testOnReturn,config.timeBetweenEvictionRunsMillis,config.numTestsPerEvictionRun,config.minEvictableIdleTimeMillis,config.testWhileIdle);<a name="294" href="#294">294</a> }<a name="295" href="#295">295</a> <a name="296" href="#296">296</a> <em>/**<em>*</em></em><a name="297" href="#297">297</a> <em> * Create a new <tt>GenericObjectPool</tt> using the specified values.</em><a name="298" href="#298">298</a> <em> * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects</em><a name="299" href="#299">299</a> <em> * @param maxActive the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})</em><a name="300" href="#300">300</a> <em> */</em><a name="301" href="#301">301</a> <strong>public</strong> <a href="../../../../../org/apache/commons/pool/impl/GenericObjectPool.html">GenericObjectPool</a>(PoolableObjectFactory factory, <strong>int</strong> maxActive) {<a name="302" href="#302">302</a> <strong>this</strong>(factory,maxActive,DEFAULT_WHEN_EXHAUSTED_ACTION,DEFAULT_MAX_WAIT,DEFAULT_MAX_IDLE,DEFAULT_MIN_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);<a name="303" href="#303">303</a> }<a name="304" href="#304">304</a> <a name="305" href="#305">305</a> <em>/**<em>*</em></em><a name="306" href="#306">306</a> <em> * Create a new <tt>GenericObjectPool</tt> using the specified values.</em><a name="307" href="#307">307</a> <em> * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects</em><a name="308" href="#308">308</a> <em> * @param maxActive the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})</em><a name="309" href="#309">309</a> <em> * @param whenExhaustedAction the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})</em><a name="310" href="#310">310</a> <em> * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and <i>whenExhaustedAction</i> is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})</em><a name="311" href="#311">311</a> <em> */</em><a name="312" href="#312">312</a> <strong>public</strong> <a href="../../../../../org/apache/commons/pool/impl/GenericObjectPool.html">GenericObjectPool</a>(PoolableObjectFactory factory, <strong>int</strong> maxActive, byte whenExhaustedAction, <strong>long</strong> maxWait) {<a name="313" href="#313">313</a> <strong>this</strong>(factory,maxActive,whenExhaustedAction,maxWait,DEFAULT_MAX_IDLE,DEFAULT_MIN_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);<a name="314" href="#314">314</a> }<a name="315" href="#315">315</a> <a name="316" href="#316">316</a> <em>/**<em>*</em></em><a name="317" href="#317">317</a> <em> * Create a new <tt>GenericObjectPool</tt> using the specified values.</em><a name="318" href="#318">318</a> <em> * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects</em><a name="319" href="#319">319</a> <em> * @param maxActive the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})</em><a name="320" href="#320">320</a> <em> * @param whenExhaustedAction the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})</em><a name="321" href="#321">321</a> <em> * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and <i>whenExhaustedAction</i> is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})</em><a name="322" href="#322">322</a> <em> * @param testOnBorrow whether or not to validate objects before they are returned by the {@link #borrowObject} method (see {@link #getTestOnBorrow})</em><a name="323" href="#323">323</a> <em> * @param testOnReturn whether or not to validate objects after they are returned to the {@link #returnObject} method (see {@link #getTestOnReturn})</em><a name="324" href="#324">324</a> <em> */</em><a name="325" href="#325">325</a> <strong>public</strong> <a href="../../../../../org/apache/commons/pool/impl/GenericObjectPool.html">GenericObjectPool</a>(PoolableObjectFactory factory, <strong>int</strong> maxActive, byte whenExhaustedAction, <strong>long</strong> maxWait, <strong>boolean</strong> testOnBorrow, <strong>boolean</strong> testOnReturn) {<a name="326" href="#326">326</a> <strong>this</strong>(factory,maxActive,whenExhaustedAction,maxWait,DEFAULT_MAX_IDLE,DEFAULT_MIN_IDLE,testOnBorrow,testOnReturn,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);<a name="327" href="#327">327</a> }<a name="328" href="#328">328</a> <a name="329" href="#329">329</a> <em>/**<em>*</em></em><a name="330" href="#330">330</a> <em> * Create a new <tt>GenericObjectPool</tt> using the specified values.</em><a name="331" href="#331">331</a> <em> * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects</em><a name="332" href="#332">332</a> <em> * @param maxActive the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})</em><a name="333" href="#333">333</a> <em> * @param whenExhaustedAction the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})</em><a name="334" href="#334">334</a> <em> * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and <i>whenExhaustedAction</i> is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})</em><a name="335" href="#335">335</a> <em> * @param maxIdle the maximum number of idle objects in my pool (see {@link #getMaxIdle})</em><a name="336" href="#336">336</a> <em> */</em><a name="337" href="#337">337</a> <strong>public</strong> <a href="../../../../../org/apache/commons/pool/impl/GenericObjectPool.html">GenericObjectPool</a>(PoolableObjectFactory factory, <strong>int</strong> maxActive, byte whenExhaustedAction, <strong>long</strong> maxWait, <strong>int</strong> maxIdle) {<a name="338" href="#338">338</a> <strong>this</strong>(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,DEFAULT_MIN_IDLE,DEFAULT_TEST_ON_BORROW,DEFAULT_TEST_ON_RETURN,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);<a name="339" href="#339">339</a> }<a name="340" href="#340">340</a> <a name="341" href="#341">341</a> <em>/**<em>*</em></em><a name="342" href="#342">342</a> <em> * Create a new <tt>GenericObjectPool</tt> using the specified values.</em><a name="343" href="#343">343</a> <em> * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects</em><a name="344" href="#344">344</a> <em> * @param maxActive the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})</em><a name="345" href="#345">345</a> <em> * @param whenExhaustedAction the action to take when the pool is exhausted (see {@link #getWhenExhaustedAction})</em><a name="346" href="#346">346</a> <em> * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and <i>whenExhaustedAction</i> is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #getMaxWait})</em><a name="347" href="#347">347</a> <em> * @param maxIdle the maximum number of idle objects in my pool (see {@link #getMaxIdle})</em><a name="348" href="#348">348</a> <em> * @param testOnBorrow whether or not to validate objects before they are returned by the {@link #borrowObject} method (see {@link #getTestOnBorrow})</em><a name="349" href="#349">349</a> <em> * @param testOnReturn whether or not to validate objects after they are returned to the {@link #returnObject} method (see {@link #getTestOnReturn})</em><a name="350" href="#350">350</a> <em> */</em><a name="351" href="#351">351</a> <strong>public</strong> <a href="../../../../../org/apache/commons/pool/impl/GenericObjectPool.html">GenericObjectPool</a>(PoolableObjectFactory factory, <strong>int</strong> maxActive, byte whenExhaustedAction, <strong>long</strong> maxWait, <strong>int</strong> maxIdle, <strong>boolean</strong> testOnBorrow, <strong>boolean</strong> testOnReturn) {<a name="352" href="#352">352</a> <strong>this</strong>(factory,maxActive,whenExhaustedAction,maxWait,maxIdle,DEFAULT_MIN_IDLE,testOnBorrow,testOnReturn,DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,DEFAULT_NUM_TESTS_PER_EVICTION_RUN,DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,DEFAULT_TEST_WHILE_IDLE);<a name="353" href="#353">353</a> }<a name="354" href="#354">354</a> <a name="355" href="#355">355</a> <em>/**<em>*</em></em><a name="356" href="#356">356</a> <em> * Create a new <tt>GenericObjectPool</tt> using the specified values.</em><a name="357" href="#357">357</a> <em> * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects</em><a name="358" href="#358">358</a> <em> * @param maxActive the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})</em><a name="359" href="#359">359</a> <em> * @param whenExhaustedAction the action to take when the pool is exhausted (see {@link #setWhenExhaustedAction})</em><a name="360" href="#360">360</a> <em> * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and <i>whenExhaustedAction</i> is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #setMaxWait})</em><a name="361" href="#361">361</a> <em> * @param maxIdle the maximum number of idle objects in my pool (see {@link #setMaxIdle})</em><a name="362" href="#362">362</a> <em> * @param testOnBorrow whether or not to validate objects before they are returned by the {@link #borrowObject} method (see {@link #setTestOnBorrow})</em><a name="363" href="#363">363</a> <em> * @param testOnReturn whether or not to validate objects after they are returned to the {@link #returnObject} method (see {@link #setTestOnReturn})</em><a name="364" href="#364">364</a> <em> * @param timeBetweenEvictionRunsMillis the amount of time (in milliseconds) to sleep between examining idle objects for eviction (see {@link #setTimeBetweenEvictionRunsMillis})</em><a name="365" href="#365">365</a> <em> * @param numTestsPerEvictionRun the number of idle objects to examine per run within the idle object eviction thread (if any) (see {@link #setNumTestsPerEvictionRun})</em><a name="366" href="#366">366</a> <em> * @param minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligable for evcition (see {@link #setMinEvictableIdleTimeMillis})</em><a name="367" href="#367">367</a> <em> * @param testWhileIdle whether or not to validate objects in the idle object eviction thread, if any (see {@link #setTestWhileIdle})</em><a name="368" href="#368">368</a> <em> */</em><a name="369" href="#369">369</a> <strong>public</strong> <a href="../../../../../org/apache/commons/pool/impl/GenericObjectPool.html">GenericObjectPool</a>(PoolableObjectFactory factory, <strong>int</strong> maxActive, byte whenExhaustedAction, <strong>long</strong> maxWait, <strong>int</strong> maxIdle, <strong>boolean</strong> testOnBorrow, <strong>boolean</strong> testOnReturn, <strong>long</strong> timeBetweenEvictionRunsMillis, <strong>int</strong> numTestsPerEvictionRun, <strong>long</strong> minEvictableIdleTimeMillis, <strong>boolean</strong> testWhileIdle) {<a name="370" href="#370">370</a> <strong>this</strong>(factory, maxActive, whenExhaustedAction, maxWait, maxIdle, DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle);<a name="371" href="#371">371</a> }<a name="372" href="#372">372</a> <a name="373" href="#373">373</a> <em>/**<em>*</em></em><a name="374" href="#374">374</a> <em> * Create a new <tt>GenericObjectPool</tt> using the specified values.</em><a name="375" href="#375">375</a> <em> * @param factory the (possibly <tt>null</tt>)PoolableObjectFactory to use to create, validate and destroy objects</em><a name="376" href="#376">376</a> <em> * @param maxActive the maximum number of objects that can be borrowed from me at one time (see {@link #setMaxActive})</em><a name="377" href="#377">377</a> <em> * @param whenExhaustedAction the action to take when the pool is exhausted (see {@link #setWhenExhaustedAction})</em><a name="378" href="#378">378</a> <em> * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and <i>whenExhaustedAction</i> is {@link #WHEN_EXHAUSTED_BLOCK} (otherwise ignored) (see {@link #setMaxWait})</em><a name="379" href="#379">379</a> <em> * @param maxIdle the maximum number of idle objects in my pool (see {@link #setMaxIdle})</em><a name="380" href="#380">380</a> <em> * @param minIdle the minimum number of idle objects in my pool (see {@link #setMinIdle})</em><a name="381" href="#381">381</a> <em> * @param testOnBorrow whether or not to validate objects before they are returned by the {@link #borrowObject} method (see {@link #setTestOnBorrow})</em><a name="382" href="#382">382</a> <em> * @param testOnReturn whether or not to validate objects after they are returned to the {@link #returnObject} method (see {@link #setTestOnReturn})</em><a name="383" href="#383">383</a> <em> * @param timeBetweenEvictionRunsMillis the amount of time (in milliseconds) to sleep between examining idle objects for eviction (see {@link #setTimeBetweenEvictionRunsMillis})</em><a name="384" href="#384">384</a> <em> * @param numTestsPerEvictionRun the number of idle objects to examine per run within the idle object eviction thread (if any) (see {@link #setNumTestsPerEvictionRun})</em>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -