| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| StackObjectPoolFactory |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 | * contributor license agreements. See the NOTICE file distributed with | |
| 4 | * this work for additional information regarding copyright ownership. | |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 | * (the "License"); you may not use this file except in compliance with | |
| 7 | * the License. You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | ||
| 18 | package org.apache.commons.pool.impl; | |
| 19 | ||
| 20 | import org.apache.commons.pool.ObjectPool; | |
| 21 | import org.apache.commons.pool.ObjectPoolFactory; | |
| 22 | import org.apache.commons.pool.PoolableObjectFactory; | |
| 23 | ||
| 24 | /** | |
| 25 | * A factory for creating {@link StackObjectPool} instances. | |
| 26 | * | |
| 27 | * @see StackObjectPool | |
| 28 | * @see StackKeyedObjectPoolFactory | |
| 29 | * | |
| 30 | * @author Rodney Waldhoff | |
| 31 | * @version $Revision: 777748 $ $Date: 2009-05-22 20:00:44 -0400 (Fri, 22 May 2009) $ | |
| 32 | * @since Pool 1.0 | |
| 33 | */ | |
| 34 | public class StackObjectPoolFactory implements ObjectPoolFactory { | |
| 35 | /** | |
| 36 | * Create a new StackObjectPoolFactory. | |
| 37 | * | |
| 38 | * @see StackObjectPool#StackObjectPool() | |
| 39 | */ | |
| 40 | public StackObjectPoolFactory() { | |
| 41 | 0 | this((PoolableObjectFactory)null,StackObjectPool.DEFAULT_MAX_SLEEPING,StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY); |
| 42 | 0 | } |
| 43 | ||
| 44 | /** | |
| 45 | * Create a new StackObjectPoolFactory. | |
| 46 | * | |
| 47 | * @param maxIdle cap on the number of "sleeping" instances in the pool. | |
| 48 | * @see StackObjectPool#StackObjectPool(int) | |
| 49 | */ | |
| 50 | public StackObjectPoolFactory(int maxIdle) { | |
| 51 | 0 | this((PoolableObjectFactory)null,maxIdle,StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY); |
| 52 | 0 | } |
| 53 | ||
| 54 | /** | |
| 55 | * Create a new StackObjectPoolFactory. | |
| 56 | * | |
| 57 | * @param maxIdle cap on the number of "sleeping" instances in the pool. | |
| 58 | * @param initIdleCapacity - initial size of the pool (this specifies the size of the container, it does not cause the pool to be pre-populated.) | |
| 59 | * @see StackObjectPool#StackObjectPool(int, int) | |
| 60 | */ | |
| 61 | public StackObjectPoolFactory(int maxIdle, int initIdleCapacity) { | |
| 62 | 0 | this((PoolableObjectFactory)null,maxIdle,initIdleCapacity); |
| 63 | 0 | } |
| 64 | ||
| 65 | /** | |
| 66 | * Create a new StackObjectPoolFactory. | |
| 67 | * | |
| 68 | * @param factory the PoolableObjectFactory used by created pools. | |
| 69 | * @see StackObjectPool#StackObjectPool(PoolableObjectFactory) | |
| 70 | */ | |
| 71 | public StackObjectPoolFactory(PoolableObjectFactory factory) { | |
| 72 | 0 | this(factory,StackObjectPool.DEFAULT_MAX_SLEEPING,StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY); |
| 73 | 0 | } |
| 74 | ||
| 75 | /** | |
| 76 | * Create a new StackObjectPoolFactory. | |
| 77 | * | |
| 78 | * @param factory the PoolableObjectFactory used by created pools. | |
| 79 | * @param maxIdle cap on the number of "sleeping" instances in the pool. | |
| 80 | */ | |
| 81 | public StackObjectPoolFactory(PoolableObjectFactory factory, int maxIdle) { | |
| 82 | 0 | this(factory,maxIdle,StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY); |
| 83 | 0 | } |
| 84 | ||
| 85 | /** | |
| 86 | * Create a new StackObjectPoolFactory. | |
| 87 | * | |
| 88 | * @param factory the PoolableObjectFactory used by created pools. | |
| 89 | * @param maxIdle cap on the number of "sleeping" instances in the pool. | |
| 90 | * @param initIdleCapacity - initial size of the pool (this specifies the size of the container, it does not cause the pool to be pre-populated.) | |
| 91 | */ | |
| 92 | 0 | public StackObjectPoolFactory(PoolableObjectFactory factory, int maxIdle, int initIdleCapacity) { |
| 93 | 0 | _factory = factory; |
| 94 | 0 | _maxSleeping = maxIdle; |
| 95 | 0 | _initCapacity = initIdleCapacity; |
| 96 | 0 | } |
| 97 | ||
| 98 | public ObjectPool createPool() { | |
| 99 | 0 | return new StackObjectPool(_factory,_maxSleeping,_initCapacity); |
| 100 | } | |
| 101 | ||
| 102 | 0 | protected PoolableObjectFactory _factory = null; |
| 103 | 0 | protected int _maxSleeping = StackObjectPool.DEFAULT_MAX_SLEEPING; |
| 104 | 0 | protected int _initCapacity = StackObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY; |
| 105 | ||
| 106 | } |