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.KeyedObjectPool;
21 import org.apache.commons.pool.KeyedObjectPoolFactory;
22 import org.apache.commons.pool.KeyedPoolableObjectFactory;
23
24 /***
25 * A factory for creating {@link StackKeyedObjectPool} instances.
26 *
27 * @see StackKeyedObjectPool
28 * @see KeyedObjectPoolFactory
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 StackKeyedObjectPoolFactory implements KeyedObjectPoolFactory {
35 /***
36 * Create a new StackKeyedObjectPoolFactory.
37 *
38 * @see StackKeyedObjectPool#StackKeyedObjectPool()
39 */
40 public StackKeyedObjectPoolFactory() {
41 this((KeyedPoolableObjectFactory)null,StackKeyedObjectPool.DEFAULT_MAX_SLEEPING,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
42 }
43
44 /***
45 * Create a new StackKeyedObjectPoolFactory.
46 *
47 * @param max cap on the number of "sleeping" instances in the pool.
48 * @see StackKeyedObjectPool#StackKeyedObjectPool(int)
49 */
50 public StackKeyedObjectPoolFactory(int max) {
51 this((KeyedPoolableObjectFactory)null,max,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
52 }
53
54 /***
55 * Create a new StackKeyedObjectPoolFactory.
56 *
57 * @param max cap on the number of "sleeping" instances in the pool.
58 * @param init initial size of the pool (this specifies the size of the container, it does not cause the pool to be pre-populated.)
59 * @see StackKeyedObjectPool#StackKeyedObjectPool(int, int)
60 */
61 public StackKeyedObjectPoolFactory(int max, int init) {
62 this((KeyedPoolableObjectFactory)null,max,init);
63 }
64
65 /***
66 * Create a new StackKeyedObjectPoolFactory.
67 *
68 * @param factory the KeyedPoolableObjectFactory used by created pools.
69 * @see StackKeyedObjectPool#StackKeyedObjectPool(KeyedPoolableObjectFactory)
70 */
71 public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory factory) {
72 this(factory,StackKeyedObjectPool.DEFAULT_MAX_SLEEPING,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
73 }
74
75 /***
76 * Create a new StackKeyedObjectPoolFactory.
77 *
78 * @param factory the KeyedPoolableObjectFactory used by created pools.
79 * @param max cap on the number of "sleeping" instances in the pool.
80 * @see StackKeyedObjectPool#StackKeyedObjectPool(KeyedPoolableObjectFactory, int)
81 */
82 public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory factory, int max) {
83 this(factory,max,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
84 }
85
86 /***
87 * Create a new StackKeyedObjectPoolFactory.
88 *
89 * @param factory the KeyedPoolableObjectFactory used by created pools.
90 * @param max cap on the number of "sleeping" instances in the pool.
91 * @param init initial size of the pool (this specifies the size of the container, it does not cause the pool to be pre-populated.)
92 * @see StackKeyedObjectPool#StackKeyedObjectPool(KeyedPoolableObjectFactory, int, int)
93 */
94 public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory factory, int max, int init) {
95 _factory = factory;
96 _maxSleeping = max;
97 _initCapacity = init;
98 }
99
100 public KeyedObjectPool createPool() {
101 return new StackKeyedObjectPool(_factory,_maxSleeping,_initCapacity);
102 }
103
104 protected KeyedPoolableObjectFactory _factory = null;
105 protected int _maxSleeping = StackKeyedObjectPool.DEFAULT_MAX_SLEEPING;
106 protected int _initCapacity = StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY;
107
108 }