org.apache.commons.pool.impl

Class StackKeyedObjectPool

public class StackKeyedObjectPool extends BaseKeyedObjectPool implements KeyedObjectPool

A simple, java.util.Stack Stack-based KeyedObjectPool implementation.

Given a KeyedPoolableObjectFactory, this class will maintain a simple pool of instances. A finite number of "sleeping" or inactive instances is enforced, but when the pool is empty, new instances are created to support the new load. Hence this class places no limit on the number of "active" instances created by the pool, but is quite useful for re-using Objects without introducing artificial limits.

Version: $Revision: 328937 $ $Date: 2005-10-27 15:23:53 -0400 (Thu, 27 Oct 2005) $

Author: Rodney Waldhoff

Constructor Summary
StackKeyedObjectPool()
Create a new pool using no factory.
StackKeyedObjectPool(int max)
Create a new pool using no factory.
StackKeyedObjectPool(int max, int init)
Create a new pool using no factory.
StackKeyedObjectPool(KeyedPoolableObjectFactory factory)
Create a new SimpleKeyedObjectPool using the specified factory to create new instances.
StackKeyedObjectPool(KeyedPoolableObjectFactory factory, int max)
Create a new SimpleKeyedObjectPool using the specified factory to create new instances. capping the number of "sleeping" instances to max
StackKeyedObjectPool(KeyedPoolableObjectFactory factory, int max, int init)
Create a new SimpleKeyedObjectPool using the specified factory to create new instances. capping the number of "sleeping" instances to max, and initially allocating a container capable of containing at least init instances.
Method Summary
voidaddObject(Object key)
ObjectborrowObject(Object key)
voidclear()
voidclear(Object key)
voidclose()
intgetNumActive()
intgetNumActive(Object key)
intgetNumIdle()
intgetNumIdle(Object key)
voidinvalidateObject(Object key, Object obj)
voidreturnObject(Object key, Object obj)
voidsetFactory(KeyedPoolableObjectFactory factory)
StringtoString()

Constructor Detail

StackKeyedObjectPool

public StackKeyedObjectPool()
Create a new pool using no factory. Clients must first populate the pool using StackKeyedObjectPool before they can be borrowed.

StackKeyedObjectPool

public StackKeyedObjectPool(int max)
Create a new pool using no factory. Clients must first populate the pool using StackKeyedObjectPool before they can be borrowed.

Parameters: max cap on the number of "sleeping" instances in the pool

StackKeyedObjectPool

public StackKeyedObjectPool(int max, int init)
Create a new pool using no factory. Clients must first populate the pool using StackKeyedObjectPool before they can be borrowed.

Parameters: max cap on the number of "sleeping" instances in the pool init initial size of the pool (this specifies the size of the container, it does not cause the pool to be pre-populated.)

StackKeyedObjectPool

public StackKeyedObjectPool(KeyedPoolableObjectFactory factory)
Create a new SimpleKeyedObjectPool using the specified factory to create new instances.

Parameters: factory the KeyedPoolableObjectFactory used to populate the pool

StackKeyedObjectPool

public StackKeyedObjectPool(KeyedPoolableObjectFactory factory, int max)
Create a new SimpleKeyedObjectPool using the specified factory to create new instances. capping the number of "sleeping" instances to max

Parameters: factory the KeyedPoolableObjectFactory used to populate the pool max cap on the number of "sleeping" instances in the pool

StackKeyedObjectPool

public StackKeyedObjectPool(KeyedPoolableObjectFactory factory, int max, int init)
Create a new SimpleKeyedObjectPool using the specified factory to create new instances. capping the number of "sleeping" instances to max, and initially allocating a container capable of containing at least init instances.

Parameters: factory the KeyedPoolableObjectFactory used to populate the pool max cap on the number of "sleeping" instances in the pool init initial size of the pool (this specifies the size of the container, it does not cause the pool to be pre-populated.)

Method Detail

addObject

public void addObject(Object key)

borrowObject

public Object borrowObject(Object key)

clear

public void clear()

clear

public void clear(Object key)

close

public void close()

getNumActive

public int getNumActive()

getNumActive

public int getNumActive(Object key)

getNumIdle

public int getNumIdle()

getNumIdle

public int getNumIdle(Object key)

invalidateObject

public void invalidateObject(Object key, Object obj)

returnObject

public void returnObject(Object key, Object obj)

setFactory

public void setFactory(KeyedPoolableObjectFactory factory)

toString

public String toString()
Copyright © 2001-2003 Apache Software Foundation. Documenation generated April 29 2009.