public class StackKeyedObjectPool extends BaseKeyedObjectPool implements KeyedObjectPool
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.
| Constructor and Description |
|---|
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.
|
StackKeyedObjectPool(KeyedPoolableObjectFactory factory,
int max,
int init)
Create a new SimpleKeyedObjectPool using
the specified factory to create new instances.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addObject(java.lang.Object key)
Not supported in this base implementation.
|
java.lang.Object |
borrowObject(java.lang.Object key)
Obtain an instance from my pool
for the specified key.
|
void |
clear()
Not supported in this base implementation.
|
void |
clear(java.lang.Object key)
Not supported in this base implementation.
|
void |
close()
Does nothing this base implementation.
|
int |
getNumActive()
Not supported in this base implementation.
|
int |
getNumActive(java.lang.Object key)
Not supported in this base implementation.
|
int |
getNumIdle()
Not supported in this base implementation.
|
int |
getNumIdle(java.lang.Object key)
Not supported in this base implementation.
|
void |
invalidateObject(java.lang.Object key,
java.lang.Object obj)
Invalidates an object from the pool
By contract, obj MUST have been obtained
using
borrowObject
or a related method as defined in an implementation
or sub-interface
using a key that is equivalent to the one used to
borrow the Object in the first place. |
void |
returnObject(java.lang.Object key,
java.lang.Object obj)
Return an instance to my pool.
|
void |
setFactory(KeyedPoolableObjectFactory factory)
Not supported in this base implementation.
|
java.lang.String |
toString() |
public StackKeyedObjectPool()
returnObject(java.lang.Object,java.lang.Object)
before they can be borrowed.public StackKeyedObjectPool(int max)
returnObject(java.lang.Object,java.lang.Object)
before they can be borrowed.max - cap on the number of "sleeping" instances in the poolpublic StackKeyedObjectPool(int max,
int init)
returnObject(java.lang.Object,java.lang.Object)
before they can be borrowed.max - cap on the number of "sleeping" instances in the poolinit - initial size of the pool (this specifies the size of the container,
it does not cause the pool to be pre-populated.)public StackKeyedObjectPool(KeyedPoolableObjectFactory factory)
factory - the KeyedPoolableObjectFactory used to populate the poolpublic StackKeyedObjectPool(KeyedPoolableObjectFactory factory, int max)
factory - the KeyedPoolableObjectFactory used to populate the poolmax - cap on the number of "sleeping" instances in the poolpublic StackKeyedObjectPool(KeyedPoolableObjectFactory factory, int max, int init)
factory - the KeyedPoolableObjectFactory used to populate the poolmax - cap on the number of "sleeping" instances in the poolinit - initial size of the pool (this specifies the size of the container,
it does not cause the pool to be pre-populated.)public void addObject(java.lang.Object key)
throws java.lang.Exception
BaseKeyedObjectPooladdObject in interface KeyedObjectPooladdObject in class BaseKeyedObjectPooljava.lang.Exceptionpublic java.lang.Object borrowObject(java.lang.Object key)
throws java.lang.Exception
KeyedObjectPoolreturnObject,
or a related method as defined in an implementation
or sub-interface,
using a key that is equivalent to the one used to
borrow the instance in the first place.borrowObject in interface KeyedObjectPoolborrowObject in class BaseKeyedObjectPoolkey - the key used to obtain the objectjava.lang.Exceptionpublic void clear()
BaseKeyedObjectPoolclear in interface KeyedObjectPoolclear in class BaseKeyedObjectPoolpublic void clear(java.lang.Object key)
BaseKeyedObjectPoolclear in interface KeyedObjectPoolclear in class BaseKeyedObjectPoolkey - the key to clearpublic void close()
throws java.lang.Exception
BaseKeyedObjectPoolclose in interface KeyedObjectPoolclose in class BaseKeyedObjectPooljava.lang.Exceptionpublic int getNumActive()
BaseKeyedObjectPoolgetNumActive in interface KeyedObjectPoolgetNumActive in class BaseKeyedObjectPoolpublic int getNumActive(java.lang.Object key)
BaseKeyedObjectPoolgetNumActive in interface KeyedObjectPoolgetNumActive in class BaseKeyedObjectPoolkey - the keypublic int getNumIdle()
BaseKeyedObjectPoolgetNumIdle in interface KeyedObjectPoolgetNumIdle in class BaseKeyedObjectPoolpublic int getNumIdle(java.lang.Object key)
BaseKeyedObjectPoolgetNumIdle in interface KeyedObjectPoolgetNumIdle in class BaseKeyedObjectPoolkey - the keypublic void invalidateObject(java.lang.Object key,
java.lang.Object obj)
throws java.lang.Exception
KeyedObjectPoolborrowObject
or a related method as defined in an implementation
or sub-interface
using a key that is equivalent to the one used to
borrow the Object in the first place.
This method should be used when an object that has been borrowed
is determined (due to an exception or other problem) to be invalid.
If the connection should be validated before or after borrowing,
then the PoolableObjectFactory.validateObject(java.lang.Object) method should be
used instead.
invalidateObject in interface KeyedObjectPoolinvalidateObject in class BaseKeyedObjectPoolobj - a borrowed instance to be returned.java.lang.Exceptionpublic void returnObject(java.lang.Object key,
java.lang.Object obj)
throws java.lang.Exception
KeyedObjectPoolborrowObject
or a related method as defined in an implementation
or sub-interface
using a key that is equivalent to the one used to
borrow the Object in the first place.returnObject in interface KeyedObjectPoolreturnObject in class BaseKeyedObjectPoolkey - the key used to obtain the objectobj - a borrowed instance to be returned.java.lang.Exceptionpublic void setFactory(KeyedPoolableObjectFactory factory) throws java.lang.IllegalStateException
BaseKeyedObjectPoolsetFactory in interface KeyedObjectPoolsetFactory in class BaseKeyedObjectPoolfactory - the KeyedPoolableObjectFactory I use to create new instances.java.lang.IllegalStateException - when the factory cannot be set at this timepublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2001-2003 Apache Software Foundation. Documenation generated October 15 2014.