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.KeyedObjectPool;
20: import org.apache.commons.pool.KeyedObjectPoolFactory;
21: import org.apache.commons.pool.KeyedPoolableObjectFactory;
22:
23: /**
24: * A factory for creating {@link StackKeyedObjectPool} instances.
25: *
26: * @see StackKeyedObjectPool
27: * @see KeyedObjectPoolFactory
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 StackKeyedObjectPoolFactory implements
33: KeyedObjectPoolFactory {
34: public StackKeyedObjectPoolFactory() {
35: this ((KeyedPoolableObjectFactory) null,
36: StackKeyedObjectPool.DEFAULT_MAX_SLEEPING,
37: StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
38: }
39:
40: public StackKeyedObjectPoolFactory(int max) {
41: this ((KeyedPoolableObjectFactory) null, max,
42: StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
43: }
44:
45: public StackKeyedObjectPoolFactory(int max, int init) {
46: this ((KeyedPoolableObjectFactory) null, max, init);
47: }
48:
49: public StackKeyedObjectPoolFactory(
50: KeyedPoolableObjectFactory factory) {
51: this (factory, StackKeyedObjectPool.DEFAULT_MAX_SLEEPING,
52: StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
53: }
54:
55: public StackKeyedObjectPoolFactory(
56: KeyedPoolableObjectFactory factory, int max) {
57: this (factory, max,
58: StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
59: }
60:
61: public StackKeyedObjectPoolFactory(
62: KeyedPoolableObjectFactory factory, int max, int init) {
63: _factory = factory;
64: _maxSleeping = max;
65: _initCapacity = init;
66: }
67:
68: public KeyedObjectPool createPool() {
69: return new StackKeyedObjectPool(_factory, _maxSleeping,
70: _initCapacity);
71: }
72:
73: protected KeyedPoolableObjectFactory _factory = null;
74: protected int _maxSleeping = StackKeyedObjectPool.DEFAULT_MAX_SLEEPING;
75: protected int _initCapacity = StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY;
76:
77: }
|