01: /*
02: * Copyright 1999-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.commons.pool.impl;
18:
19: import org.apache.commons.pool.ObjectPool;
20: import org.apache.commons.pool.ObjectPoolFactory;
21: import org.apache.commons.pool.PoolableObjectFactory;
22:
23: /**
24: * A factory for creating {@link StackObjectPool} instances.
25: *
26: * @see StackObjectPool
27: * @see StackKeyedObjectPoolFactory
28: *
29: * @author Rodney Waldhoff
30: * @version $Revision: 155430 $ $Date: 2005-02-26 08:13:28 -0500 (Sat, 26 Feb 2005) $
31: */
32: public class StackObjectPoolFactory implements ObjectPoolFactory {
33: public StackObjectPoolFactory() {
34: this ((PoolableObjectFactory) null,
35: StackObjectPool.DEFAULT_MAX_SLEEPING,
36: StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
37: }
38:
39: public StackObjectPoolFactory(int max) {
40: this ((PoolableObjectFactory) null, max,
41: StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
42: }
43:
44: public StackObjectPoolFactory(int max, int init) {
45: this ((PoolableObjectFactory) null, max, init);
46: }
47:
48: public StackObjectPoolFactory(PoolableObjectFactory factory) {
49: this (factory, StackObjectPool.DEFAULT_MAX_SLEEPING,
50: StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
51: }
52:
53: public StackObjectPoolFactory(PoolableObjectFactory factory, int max) {
54: this (factory, max,
55: StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
56: }
57:
58: public StackObjectPoolFactory(PoolableObjectFactory factory,
59: int max, int init) {
60: _factory = factory;
61: _maxSleeping = max;
62: _initCapacity = init;
63: }
64:
65: public ObjectPool createPool() {
66: return new StackObjectPool(_factory, _maxSleeping,
67: _initCapacity);
68: }
69:
70: protected PoolableObjectFactory _factory = null;
71: protected int _maxSleeping = StackObjectPool.DEFAULT_MAX_SLEEPING;
72: protected int _initCapacity = StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY;
73:
74: }
|