org.apache.commons.pool
Class BaseKeyedObjectPool

java.lang.Object
  |
  +--org.apache.commons.pool.BaseKeyedObjectPool
All Implemented Interfaces:
KeyedObjectPool
Direct Known Subclasses:
GenericKeyedObjectPool, StackKeyedObjectPool

public abstract class BaseKeyedObjectPool
extends Object
implements KeyedObjectPool

A simple base impementation of ObjectPool. All optional operations are implemented as throwing UnsupportedOperationException.

Version:
$Revision: 1.3 $ $Date: 2002/05/03 17:01:06 $
Author:
Rodney Waldhoff

Constructor Summary
BaseKeyedObjectPool()
           
 
Method Summary
abstract  Object borrowObject(Object key)
          Obtain an instance from my pool for the specified key.
 void clear()
          Not supported in this base implementation.
 void clear(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(Object key)
          Not supported in this base implementation.
 int getNumIdle()
          Not supported in this base implementation.
 int getNumIdle(Object key)
          Not supported in this base implementation.
abstract  void returnObject(Object key, Object obj)
          Return an instance to my pool.
 void setFactory(KeyedPoolableObjectFactory factory)
          Not supported in this base implementation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseKeyedObjectPool

public BaseKeyedObjectPool()
Method Detail

borrowObject

public abstract Object borrowObject(Object key)
                             throws Exception
Description copied from interface: KeyedObjectPool
Obtain an instance from my pool for the specified key. By contract, clients MUST return the borrowed object using returnObject, 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.

Specified by:
borrowObject in interface KeyedObjectPool
Parameters:
key - the key used to obtain the object
Returns:
an instance from my pool.
Exception

clear

public void clear()
           throws Exception,
                  UnsupportedOperationException
Not supported in this base implementation.

Specified by:
clear in interface KeyedObjectPool
Throws:
UnsupportedOperationException - when this implementation doesn't support the operation
Exception

clear

public void clear(Object key)
           throws Exception,
                  UnsupportedOperationException
Not supported in this base implementation.

Specified by:
clear in interface KeyedObjectPool
Parameters:
key - the key to clear
Throws:
UnsupportedOperationException - when this implementation doesn't support the operation
Exception

close

public void close()
           throws Exception
Does nothing this base implementation.

Specified by:
close in interface KeyedObjectPool
Exception

getNumActive

public int getNumActive()
                 throws UnsupportedOperationException
Not supported in this base implementation.

Specified by:
getNumActive in interface KeyedObjectPool
Returns:
the total number of instances currently borrowed from my pool
Throws:
UnsupportedOperationException - when this implementation doesn't support the operation

getNumActive

public int getNumActive(Object key)
                 throws UnsupportedOperationException
Not supported in this base implementation.

Specified by:
getNumActive in interface KeyedObjectPool
Parameters:
key - the key
Returns:
the number of instances corresponding to the given key currently borrowed in my pool
Throws:
UnsupportedOperationException - when this implementation doesn't support the operation

getNumIdle

public int getNumIdle()
               throws UnsupportedOperationException
Not supported in this base implementation.

Specified by:
getNumIdle in interface KeyedObjectPool
Returns:
the total number of instances currently idle in my pool
Throws:
UnsupportedOperationException - when this implementation doesn't support the operation

getNumIdle

public int getNumIdle(Object key)
               throws UnsupportedOperationException
Not supported in this base implementation.

Specified by:
getNumIdle in interface KeyedObjectPool
Parameters:
key - the key
Returns:
the number of instances corresponding to the given key currently idle in my pool
Throws:
UnsupportedOperationException - when this implementation doesn't support the operation

returnObject

public abstract void returnObject(Object key,
                                  Object obj)
                           throws Exception
Description copied from interface: KeyedObjectPool
Return an instance to my 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.

Specified by:
returnObject in interface KeyedObjectPool
Parameters:
key - the key used to obtain the object
obj - a borrowed instance to be returned.
Exception

setFactory

public void setFactory(KeyedPoolableObjectFactory factory)
                throws IllegalStateException,
                       UnsupportedOperationException
Not supported in this base implementation.

Specified by:
setFactory in interface KeyedObjectPool
Parameters:
factory - the KeyedPoolableObjectFactory I use to create new instances.
Throws:
IllegalStateException - when the factory cannot be set at this time
UnsupportedOperationException - when this implementation doesn't support the operation


Copyright © 2001-2002 Apache Software Foundation. Documenation generated February 22 2003.