001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.commons.pool.impl;
019
020 import org.apache.commons.pool.KeyedObjectPool;
021 import org.apache.commons.pool.KeyedObjectPoolFactory;
022 import org.apache.commons.pool.KeyedPoolableObjectFactory;
023
024 /**
025 * A factory for creating {@link GenericKeyedObjectPool} instances.
026 *
027 * @param <K> the type of keys in this pool
028 * @param <V> the type of objects held in this pool
029 *
030 * @see GenericKeyedObjectPool
031 * @see KeyedObjectPoolFactory
032 *
033 * @author Rodney Waldhoff
034 * @author Dirk Verbeeck
035 * @version $Revision: 1222396 $ $Date: 2011-12-22 14:02:25 -0500 (Thu, 22 Dec 2011) $
036 * @since Pool 1.0
037 */
038 public class GenericKeyedObjectPoolFactory<K, V> implements KeyedObjectPoolFactory<K, V> {
039 /**
040 * Create a new GenericKeyedObjectPoolFactory.
041 *
042 * @param factory the KeyedPoolableObjectFactory to used by created pools.
043 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory)
044 */
045 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory) {
046 this(factory,GenericKeyedObjectPool.DEFAULT_MAX_ACTIVE,GenericKeyedObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,GenericKeyedObjectPool.DEFAULT_MAX_WAIT,GenericKeyedObjectPool.DEFAULT_MAX_IDLE,GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW,GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN,GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE);
047 }
048
049 /**
050 * Create a new GenericKeyedObjectPoolFactory.
051 *
052 * @param factory the KeyedPoolableObjectFactory to used by created pools.
053 * @param config a non-null GenericKeyedObjectPool.Config describing the configuration.
054 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, GenericKeyedObjectPool.Config)
055 * @throws NullPointerException when config is <code>null</code>.
056 */
057 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, GenericKeyedObjectPool.Config config) throws NullPointerException {
058 this(factory,config.maxActive,config.whenExhaustedAction,config.maxWait,config.maxIdle,config.maxTotal,config.minIdle,config.testOnBorrow,config.testOnReturn,config.timeBetweenEvictionRunsMillis,config.numTestsPerEvictionRun,config.minEvictableIdleTimeMillis,config.testWhileIdle,config.lifo);
059 }
060
061 /**
062 * Create a new GenericKeyedObjectPoolFactory.
063 *
064 * @param factory the KeyedPoolableObjectFactory to used by created pools.
065 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
066 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int)
067 */
068 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive) {
069 this(factory,maxActive,GenericKeyedObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,GenericKeyedObjectPool.DEFAULT_MAX_WAIT,GenericKeyedObjectPool.DEFAULT_MAX_IDLE, GenericKeyedObjectPool.DEFAULT_MAX_TOTAL,GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW,GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN,GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE);
070 }
071
072 /**
073 * Create a new GenericKeyedObjectPoolFactory.
074 *
075 * @param factory the KeyedPoolableObjectFactory to used by created pools.
076 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
077 * @param whenExhaustedAction the action to take when the pool is exhausted.
078 * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
079 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long)
080 */
081 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait) {
082 this(factory,maxActive,whenExhaustedAction,maxWait,GenericKeyedObjectPool.DEFAULT_MAX_IDLE, GenericKeyedObjectPool.DEFAULT_MAX_TOTAL,GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW,GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN,GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE);
083 }
084
085 /**
086 * Create a new GenericKeyedObjectPoolFactory.
087 *
088 * @param factory the KeyedPoolableObjectFactory to used by created pools.
089 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
090 * @param whenExhaustedAction the action to take when the pool is exhausted.
091 * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
092 * @param testOnBorrow whether to validate objects before they are returned by borrowObject.
093 * @param testOnReturn whether to validate objects after they are returned to returnObject.
094 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, boolean, boolean)
095 */
096 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, boolean testOnBorrow, boolean testOnReturn) {
097 this(factory,maxActive,whenExhaustedAction,maxWait,GenericKeyedObjectPool.DEFAULT_MAX_IDLE, GenericKeyedObjectPool.DEFAULT_MAX_TOTAL,testOnBorrow,testOnReturn,GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE);
098 }
099
100 /**
101 * Create a new GenericKeyedObjectPoolFactory.
102 *
103 * @param factory the KeyedPoolableObjectFactory to used by created pools.
104 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
105 * @param whenExhaustedAction the action to take when the pool is exhausted.
106 * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
107 * @param maxIdle the maximum number of idle objects in the pools.
108 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int)
109 */
110 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle) {
111 this(factory,maxActive,whenExhaustedAction,maxWait,maxIdle, GenericKeyedObjectPool.DEFAULT_MAX_TOTAL,GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW,GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN,GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE);
112 }
113
114 /**
115 * Create a new GenericKeyedObjectPoolFactory.
116 *
117 * @param factory the KeyedPoolableObjectFactory to used by created pools.
118 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
119 * @param whenExhaustedAction the action to take when the pool is exhausted.
120 * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
121 * @param maxIdle the maximum number of idle objects in the pools.
122 * @param maxTotal the maximum number of objects that can exists at one time.
123 */
124 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal) {
125 this(factory,maxActive,whenExhaustedAction,maxWait,maxIdle, maxTotal, GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW,GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN,GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE);
126 }
127
128 /**
129 * Create a new GenericKeyedObjectPoolFactory.
130 *
131 * @param factory the KeyedPoolableObjectFactory to used by created pools.
132 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
133 * @param whenExhaustedAction the action to take when the pool is exhausted.
134 * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
135 * @param maxIdle the maximum number of idle objects in the pools.
136 * @param testOnBorrow whether to validate objects before they are returned by borrowObject.
137 * @param testOnReturn whether to validate objects after they are returned to returnObject.
138 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, boolean, boolean)
139 */
140 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn) {
141 this(factory,maxActive,whenExhaustedAction,maxWait,maxIdle, GenericKeyedObjectPool.DEFAULT_MAX_TOTAL,testOnBorrow,testOnReturn,GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE);
142 }
143
144 /**
145 * Create a new GenericKeyedObjectPoolFactory.
146 *
147 * @param factory the KeyedPoolableObjectFactory to used by created pools.
148 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
149 * @param whenExhaustedAction the action to take when the pool is exhausted.
150 * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
151 * @param maxIdle the maximum number of idle objects in the pools.
152 * @param testOnBorrow whether to validate objects before they are returned by borrowObject.
153 * @param testOnReturn whether to validate objects after they are returned to returnObject.
154 * @param timeBetweenEvictionRunsMillis the number of milliseconds to sleep between examining idle objects for eviction.
155 * @param numTestsPerEvictionRun the number of idle objects to examine per run of the evictor.
156 * @param minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.
157 * @param testWhileIdle whether to validate objects in the idle object eviction thread.
158 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, boolean, boolean, long, int, long, boolean)
159 */
160 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle) {
161 this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle, GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle);
162 }
163
164 /**
165 * Create a new GenericKeyedObjectPoolFactory.
166 *
167 * @param factory the KeyedPoolableObjectFactory to used by created pools.
168 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
169 * @param whenExhaustedAction the action to take when the pool is exhausted.
170 * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
171 * @param maxIdle the maximum number of idle objects in the pools.
172 * @param maxTotal the maximum number of objects that can exists at one time.
173 * @param testOnBorrow whether to validate objects before they are returned by borrowObject.
174 * @param testOnReturn whether to validate objects after they are returned to returnObject.
175 * @param timeBetweenEvictionRunsMillis the number of milliseconds to sleep between examining idle objects for eviction.
176 * @param numTestsPerEvictionRun the number of idle objects to examine per run of the evictor.
177 * @param minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.
178 * @param testWhileIdle whether to validate objects in the idle object eviction thread.
179 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, int, boolean, boolean, long, int, long, boolean)
180 */
181 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle) {
182 this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle, maxTotal, GenericKeyedObjectPool.DEFAULT_MIN_IDLE , testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle);
183 }
184
185 /**
186 * Create a new GenericKeyedObjectPoolFactory.
187 *
188 * @param factory the KeyedPoolableObjectFactory to used by created pools.
189 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
190 * @param whenExhaustedAction the action to take when the pool is exhausted.
191 * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
192 * @param maxIdle the maximum number of idle objects in the pools.
193 * @param maxTotal the maximum number of objects that can exists at one time.
194 * @param minIdle the minimum number of idle objects to have in the pool at any one time.
195 * @param testOnBorrow whether to validate objects before they are returned by borrowObject.
196 * @param testOnReturn whether to validate objects after they are returned to returnObject.
197 * @param timeBetweenEvictionRunsMillis the number of milliseconds to sleep between examining idle objects for eviction.
198 * @param numTestsPerEvictionRun the number of idle objects to examine per run of the evictor.
199 * @param minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.
200 * @param testWhileIdle whether to validate objects in the idle object eviction thread.
201 * @since Pool 1.3
202 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, int, int, boolean, boolean, long, int, long, boolean)
203 */
204 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle) {
205 this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle, maxTotal, minIdle, testOnBorrow, testOnReturn, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis, testWhileIdle, GenericKeyedObjectPool.DEFAULT_LIFO);
206 }
207
208 /**
209 * Create a new GenericKeyedObjectPoolFactory.
210 *
211 * @param factory the KeyedPoolableObjectFactory to used by created pools.
212 * @param maxActive the maximum number of objects that can be borrowed from pools at one time.
213 * @param whenExhaustedAction the action to take when the pool is exhausted.
214 * @param maxWait the maximum amount of time to wait for an idle object when the pool is exhausted.
215 * @param maxIdle the maximum number of idle objects in the pools.
216 * @param maxTotal the maximum number of objects that can exists at one time.
217 * @param minIdle the minimum number of idle objects to have in the pool at any one time.
218 * @param testOnBorrow whether to validate objects before they are returned by borrowObject.
219 * @param testOnReturn whether to validate objects after they are returned to returnObject.
220 * @param timeBetweenEvictionRunsMillis the number of milliseconds to sleep between examining idle objects for eviction.
221 * @param numTestsPerEvictionRun the number of idle objects to examine per run of the evictor.
222 * @param minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligible for eviction.
223 * @param testWhileIdle whether to validate objects in the idle object eviction thread.
224 * @param lifo whether or not objects are returned in last-in-first-out order from the idle object pool.
225 * @since Pool 1.4
226 * @see GenericKeyedObjectPool#GenericKeyedObjectPool(KeyedPoolableObjectFactory, int, byte, long, int, int, int, boolean, boolean, long, int, long, boolean, boolean)
227 */
228 public GenericKeyedObjectPoolFactory(KeyedPoolableObjectFactory<K, V> factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int maxTotal, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle, boolean lifo) {
229 _maxIdle = maxIdle;
230 _maxActive = maxActive;
231 _maxTotal = maxTotal;
232 _minIdle = minIdle;
233 _maxWait = maxWait;
234 _whenExhaustedAction = whenExhaustedAction;
235 _testOnBorrow = testOnBorrow;
236 _testOnReturn = testOnReturn;
237 _testWhileIdle = testWhileIdle;
238 _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
239 _numTestsPerEvictionRun = numTestsPerEvictionRun;
240 _minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
241 _factory = factory;
242 _lifo = lifo;
243 }
244
245 /**
246 * Create a new GenericKeyedObjectPool with the currently configured properties.
247 *
248 * @return GenericKeyedObjectPool with {@link GenericKeyedObjectPool.Config Configuration} determined by
249 * current property settings
250 */
251 public KeyedObjectPool<K, V> createPool() {
252 return new GenericKeyedObjectPool<K, V>(_factory,_maxActive,_whenExhaustedAction,_maxWait,_maxIdle,_maxTotal,_minIdle,_testOnBorrow,_testOnReturn,_timeBetweenEvictionRunsMillis,_numTestsPerEvictionRun,_minEvictableIdleTimeMillis,_testWhileIdle,_lifo);
253 }
254
255 /**
256 * @return the {@link GenericKeyedObjectPool#getMaxIdle() maxIdle} setting for pools created by this factory.
257 * @since 1.5.5
258 */
259 public int getMaxIdle() {
260 return _maxIdle;
261 }
262
263 /**
264 * @return the {@link GenericKeyedObjectPool#getMaxActive() maxActive} setting for pools created by this factory.
265 * @since 1.5.5
266 */
267 public int getMaxActive() {
268 return _maxActive;
269 }
270
271 /**
272 * @return the {@link GenericKeyedObjectPool#getMaxTotal() maxTotal} setting for pools created by this factory.
273 * @since 1.5.5
274 */
275 public int getMaxTotal() {
276 return _maxTotal;
277 }
278
279 /**
280 * @return the {@link GenericKeyedObjectPool#getMinIdle() minIdle} setting for pools created by this factory.
281 * @since 1.5.5
282 */
283 public int getMinIdle() {
284 return _minIdle;
285 }
286
287 /**
288 * @return the {@link GenericKeyedObjectPool#getMaxWait() maxWait} setting for pools created by this factory.
289 * @since 1.5.5
290 */
291 public long getMaxWait() {
292 return _maxWait;
293 }
294
295 /**
296 * @return the {@link GenericKeyedObjectPool#getWhenExhaustedAction() whenExhaustedAction} setting for pools created by this factory.
297 * @since 1.5.5
298 */
299 public byte getWhenExhaustedAction() {
300 return _whenExhaustedAction;
301 }
302
303 /**
304 * @return the {@link GenericKeyedObjectPool#getTestOnBorrow() testOnBorrow} setting for pools created by this factory.
305 * @since 1.5.5
306 */
307 public boolean getTestOnBorrow() {
308 return _testOnBorrow;
309 }
310
311 /**
312 * @return the {@link GenericKeyedObjectPool#getTestOnReturn() testOnReturn} setting for pools created by this factory.
313 * @since 1.5.5
314 */
315 public boolean getTestOnReturn() {
316 return _testOnReturn;
317 }
318
319 /**
320 * @return the {@link GenericKeyedObjectPool#getTestWhileIdle() testWhileIdle} setting for pools created by this factory.
321 * @since 1.5.5
322 */
323 public boolean getTestWhileIdle() {
324 return _testWhileIdle;
325 }
326
327 /**
328 * @return the {@link GenericKeyedObjectPool#getTimeBetweenEvictionRunsMillis() timeBetweenEvictionRunsMillis}
329 * setting for pools created by this factory.
330 * @since 1.5.5
331 */
332 public long getTimeBetweenEvictionRunsMillis() {
333 return _timeBetweenEvictionRunsMillis;
334 }
335
336 /**
337 * @return the {@link GenericKeyedObjectPool#getNumTestsPerEvictionRun() numTestsPerEvictionRun}
338 * setting for pools created by this factory.
339 * @since 1.5.5
340 */
341 public int getNumTestsPerEvictionRun() {
342 return _numTestsPerEvictionRun;
343 }
344
345 /**
346 * @return the {@link GenericKeyedObjectPool#getMinEvictableIdleTimeMillis() minEvictableIdleTimeMillis}
347 * setting for pools created by this factory.
348 * @since 1.5.5
349 */
350 public long getMinEvictableIdleTimeMillis() {
351 return _minEvictableIdleTimeMillis;
352 }
353
354 /**
355 * @return the {@link KeyedPoolableObjectFactory} used by pools created by this factory.
356 * @since 1.5.5
357 */
358 public KeyedPoolableObjectFactory<K, V> getFactory() {
359 return _factory;
360 }
361
362 /**
363 * @return the {@link GenericKeyedObjectPool#getLifo() lifo} setting for pools created by this factory.
364 * @since 1.5.5
365 */
366 public boolean getLifo() {
367 return _lifo;
368 }
369
370 //--- protected attributes - deprecated, use getters to access these properties
371
372 /**
373 * The {@link GenericKeyedObjectPool#getMaxIdle() maxIdle} setting for pools created by this factory.
374 * @deprecated to be removed in pool 2.0. Use {@link #getMaxIdle()}.
375 */
376 @Deprecated
377 protected int _maxIdle = GenericKeyedObjectPool.DEFAULT_MAX_IDLE;
378
379 /**
380 * The {@link GenericKeyedObjectPool#getMaxActive() maxActive} setting for pools created by this factory.
381 * @deprecated to be removed in pool 2.0. Use {@link #getMaxActive()}.
382 */
383 @Deprecated
384 protected int _maxActive = GenericKeyedObjectPool.DEFAULT_MAX_ACTIVE;
385
386 /**
387 * The {@link GenericKeyedObjectPool#getMaxTotal() maxTotal} setting for pools created by this factory.
388 * @deprecated to be removed in pool 2.0. Use {@link #getMaxTotal()}.
389 */
390 @Deprecated
391 protected int _maxTotal = GenericKeyedObjectPool.DEFAULT_MAX_TOTAL;
392
393 /**
394 * The {@link GenericKeyedObjectPool#getMinIdle() minIdle} setting for pools created by this factory.
395 * @deprecated to be removed in pool 2.0. Use {@link #getMinIdle()}.
396 */
397 @Deprecated
398 protected int _minIdle = GenericKeyedObjectPool.DEFAULT_MIN_IDLE;
399
400 /**
401 * The {@link GenericKeyedObjectPool#getMaxWait() maxWait} setting for pools created by this factory.
402 * @deprecated to be removed in pool 2.0. Use {@link #getMaxWait()}.
403 */
404 @Deprecated
405 protected long _maxWait = GenericKeyedObjectPool.DEFAULT_MAX_WAIT;
406
407 /**
408 * The {@link GenericKeyedObjectPool#getWhenExhaustedAction() whenExhaustedAction} setting for pools created by this factory.
409 * @deprecated to be removed in pool 2.0. Use {@link #getWhenExhaustedAction()}.
410 */
411 @Deprecated
412 protected byte _whenExhaustedAction = GenericKeyedObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION;
413
414 /**
415 * The {@link GenericKeyedObjectPool#getTestOnBorrow() testOnBorrow} setting for pools created by this factory.
416 * @deprecated to be removed in pool 2.0. Use {@link #getTestOnBorrow()}.
417 */
418 @Deprecated
419 protected boolean _testOnBorrow = GenericKeyedObjectPool.DEFAULT_TEST_ON_BORROW;
420
421 /**
422 * The {@link GenericKeyedObjectPool#getTestOnReturn() testOnReturn} setting for pools created by this factory.
423 * @deprecated to be removed in pool 2.0. Use {@link #getTestOnReturn()}.
424 */
425 @Deprecated
426 protected boolean _testOnReturn = GenericKeyedObjectPool.DEFAULT_TEST_ON_RETURN;
427
428 /**
429 * The {@link GenericKeyedObjectPool#getTestWhileIdle() testWhileIdle} setting for pools created by this factory.
430 * @deprecated to be removed in pool 2.0. Use {@link #getTestWhileIdle()}.
431 */
432 @Deprecated
433 protected boolean _testWhileIdle = GenericKeyedObjectPool.DEFAULT_TEST_WHILE_IDLE;
434
435 /**
436 * The {@link GenericKeyedObjectPool#getTimeBetweenEvictionRunsMillis() timeBetweenEvictionRunsMillis} setting for
437 * pools created by this factory.
438 * @deprecated to be removed in pool 2.0. Use {@link #getTimeBetweenEvictionRunsMillis()}.
439 */
440 @Deprecated
441 protected long _timeBetweenEvictionRunsMillis = GenericKeyedObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
442
443 /**
444 * The {@link GenericKeyedObjectPool#getNumTestsPerEvictionRun() numTestsPerEvictionRun} setting for
445 * pools created by this factory.
446 * @deprecated to be removed in pool 2.0. Use {@link #getNumTestsPerEvictionRun()}.
447 */
448 @Deprecated
449 protected int _numTestsPerEvictionRun = GenericKeyedObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
450
451 /**
452 * The {@link GenericKeyedObjectPool#getMinEvictableIdleTimeMillis() minEvictableIdleTimeMillis} setting for
453 * pools created by this factory.
454 * @deprecated to be removed in pool 2.0. Use {@link #getMinEvictableIdleTimeMillis()}.
455 */
456 @Deprecated
457 protected long _minEvictableIdleTimeMillis = GenericKeyedObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
458
459 /**
460 * The {@link KeyedPoolableObjectFactory} used by pools created by this factory.
461 * @deprecated to be removed in pool 2.0. Use {@link #getFactory()}.
462 */
463 @Deprecated
464 protected KeyedPoolableObjectFactory<K, V> _factory = null;
465
466 /**
467 * The {@link GenericKeyedObjectPool#getLifo() lifo} setting for pools created by this factory.
468 * @deprecated to be removed in pool 2.0. Use {@link #getLifo()}.
469 */
470 @Deprecated
471 protected boolean _lifo = GenericKeyedObjectPool.DEFAULT_LIFO;
472
473 }