KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > pool > impl > StackKeyedObjectPoolFactory


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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$ $Date: 2005-02-26 05:13:28 -0800 (Sat, 26 Feb 2005) $
31  */

32 public class StackKeyedObjectPoolFactory implements KeyedObjectPoolFactory {
33     public StackKeyedObjectPoolFactory() {
34         this((KeyedPoolableObjectFactory)null,StackKeyedObjectPool.DEFAULT_MAX_SLEEPING,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
35     }
36
37     public StackKeyedObjectPoolFactory(int max) {
38         this((KeyedPoolableObjectFactory)null,max,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
39     }
40
41     public StackKeyedObjectPoolFactory(int max, int init) {
42         this((KeyedPoolableObjectFactory)null,max,init);
43     }
44
45     public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory factory) {
46         this(factory,StackKeyedObjectPool.DEFAULT_MAX_SLEEPING,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
47     }
48
49     public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory factory, int max) {
50         this(factory,max,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
51     }
52
53     public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory factory, int max, int init) {
54         _factory = factory;
55         _maxSleeping = max;
56         _initCapacity = init;
57     }
58
59     public KeyedObjectPool createPool() {
60         return new StackKeyedObjectPool(_factory,_maxSleeping,_initCapacity);
61     }
62
63     protected KeyedPoolableObjectFactory _factory = null;
64     protected int _maxSleeping = StackKeyedObjectPool.DEFAULT_MAX_SLEEPING;
65     protected int _initCapacity = StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY;
66
67 }
68
Popular Tags