1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.pool.impl;
19
20 import org.apache.commons.pool.ObjectPool;
21 import org.apache.commons.pool.ObjectPoolFactory;
22 import org.apache.commons.pool.PoolableObjectFactory;
23
24 /***
25 * A factory for creating {@link StackObjectPool} instances.
26 *
27 * @see StackObjectPool
28 * @see StackKeyedObjectPoolFactory
29 *
30 * @author Rodney Waldhoff
31 * @version $Revision: 480413 $ $Date: 2006-11-28 22:16:05 -0700 (Tue, 28 Nov 2006) $
32 * @since Pool 1.0
33 */
34 public class StackObjectPoolFactory implements ObjectPoolFactory {
35 /***
36 * Create a new StackObjectPoolFactory.
37 *
38 * @see StackObjectPool#StackObjectPool()
39 */
40 public StackObjectPoolFactory() {
41 this((PoolableObjectFactory)null,StackObjectPool.DEFAULT_MAX_SLEEPING,StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
42 }
43
44 /***
45 * Create a new StackObjectPoolFactory.
46 *
47 * @param maxIdle cap on the number of "sleeping" instances in the pool.
48 * @see StackObjectPool#StackObjectPool(int)
49 */
50 public StackObjectPoolFactory(int maxIdle) {
51 this((PoolableObjectFactory)null,maxIdle,StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
52 }
53
54 /***
55 * Create a new StackObjectPoolFactory.
56 *
57 * @param maxIdle cap on the number of "sleeping" instances in the pool.
58 * @param initIdleCapacity - initial size of the pool (this specifies the size of the container, it does not cause the pool to be pre-populated.)
59 * @see StackObjectPool#StackObjectPool(int, int)
60 */
61 public StackObjectPoolFactory(int maxIdle, int initIdleCapacity) {
62 this((PoolableObjectFactory)null,maxIdle,initIdleCapacity);
63 }
64
65 /***
66 * Create a new StackObjectPoolFactory.
67 *
68 * @param factory the PoolableObjectFactory used by created pools.
69 * @see StackObjectPool#StackObjectPool(PoolableObjectFactory)
70 */
71 public StackObjectPoolFactory(PoolableObjectFactory factory) {
72 this(factory,StackObjectPool.DEFAULT_MAX_SLEEPING,StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
73 }
74
75 /***
76 * Create a new StackObjectPoolFactory.
77 *
78 * @param factory the PoolableObjectFactory used by created pools.
79 * @param maxIdle cap on the number of "sleeping" instances in the pool.
80 */
81 public StackObjectPoolFactory(PoolableObjectFactory factory, int maxIdle) {
82 this(factory,maxIdle,StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
83 }
84
85 /***
86 * Create a new StackObjectPoolFactory.
87 *
88 * @param factory the PoolableObjectFactory used by created pools.
89 * @param maxIdle cap on the number of "sleeping" instances in the pool.
90 * @param initIdleCapacity - initial size of the pool (this specifies the size of the container, it does not cause the pool to be pre-populated.)
91 */
92 public StackObjectPoolFactory(PoolableObjectFactory factory, int maxIdle, int initIdleCapacity) {
93 _factory = factory;
94 _maxSleeping = maxIdle;
95 _initCapacity = initIdleCapacity;
96 }
97
98 public ObjectPool createPool() {
99 return new StackObjectPool(_factory,_maxSleeping,_initCapacity);
100 }
101
102 protected PoolableObjectFactory _factory = null;
103 protected int _maxSleeping = StackObjectPool.DEFAULT_MAX_SLEEPING;
104 protected int _initCapacity = StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY;
105
106 }