KickJava   Java API By Example, From Geeks To Geeks.

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


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.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$ $Date: 2005-02-26 05:13:28 -0800 (Sat, 26 Feb 2005) $
31  */

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