org.apache.commons.pool
Class BaseKeyedObjectPool

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

public abstract class BaseKeyedObjectPool
extends java.lang.Object
implements KeyedObjectPool

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

Version:
$Revision: 155430 $ $Date: 2005-02-26 08:13:28 -0500 (Sat, 26 Feb 2005) $
Author:
Rodney Waldhoff

Constructor Summary
BaseKeyedObjectPool()
           
 
Method Summary
 void addObject(java.lang.Object key)
          Not supported in this base implementation.
abstract  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.
abstract  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.
abstract  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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseKeyedObjectPool

public BaseKeyedObjectPool()
Method Detail

addObject

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

Specified by:
addObject in interface KeyedObjectPool
Throws:
java.lang.Exception
java.lang.UnsupportedOperationException

borrowObject

public abstract java.lang.Object borrowObject(java.lang.Object key)
                                       throws java.lang.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.
Throws:
java.lang.Exception

clear

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

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

clear

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

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

close

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

Specified by:
close in interface KeyedObjectPool
Throws:
java.lang.Exception

getNumActive

public int getNumActive()
                 throws java.lang.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:
java.lang.UnsupportedOperationException - when this implementation doesn't support the operation

getNumActive

public int getNumActive(java.lang.Object key)
                 throws java.lang.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:
java.lang.UnsupportedOperationException - when this implementation doesn't support the operation

getNumIdle

public int getNumIdle()
               throws java.lang.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:
java.lang.UnsupportedOperationException - when this implementation doesn't support the operation

getNumIdle

public int getNumIdle(java.lang.Object key)
               throws java.lang.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:
java.lang.UnsupportedOperationException - when this implementation doesn't support the operation

invalidateObject

public abstract void invalidateObject(java.lang.Object key,
                                      java.lang.Object obj)
                               throws java.lang.Exception
Description copied from interface: KeyedObjectPool
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.

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.

Specified by:
invalidateObject in interface KeyedObjectPool
obj - a borrowed instance to be returned.
Throws:
java.lang.Exception

returnObject

public abstract void returnObject(java.lang.Object key,
                                  java.lang.Object obj)
                           throws java.lang.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.
Throws:
java.lang.Exception

setFactory

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

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


Copyright © 2001-2003 Apache Software Foundation. Documenation generated April 15 2009.