org.apache.commons.pool
Class BaseObjectPool

java.lang.Object
  |
  +--org.apache.commons.pool.BaseObjectPool
All Implemented Interfaces:
ObjectPool
Direct Known Subclasses:
GenericObjectPool, SoftReferenceObjectPool, StackObjectPool

public abstract class BaseObjectPool
extends Object
implements ObjectPool

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

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

Constructor Summary
BaseObjectPool()
           
 
Method Summary
abstract  Object borrowObject()
          Obtain an instance from my pool.
 void clear()
          Not supported in this base implementation.
 void close()
          Does nothing this base implementation.
 int getNumActive()
          Not supported in this base implementation.
 int getNumIdle()
          Not supported in this base implementation.
abstract  void returnObject(Object obj)
          Return an instance to my pool.
 void setFactory(PoolableObjectFactory 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

BaseObjectPool

public BaseObjectPool()
Method Detail

borrowObject

public abstract Object borrowObject()
                             throws Exception
Description copied from interface: ObjectPool
Obtain an instance from my pool. By contract, clients MUST return the borrowed instance using returnObject or a related method as defined in an implementation or sub-interface.

The behaviour of this method when the pool has been exhausted is not specified (although it may be specified by implementations).

Specified by:
borrowObject in interface ObjectPool
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 ObjectPool
Throws:
UnsupportedOperationException - if this implementation does not support the operation
Exception

close

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

Specified by:
close in interface ObjectPool
Exception

getNumActive

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

Specified by:
getNumActive in interface ObjectPool
Returns:
the number of instances currently borrowed in my pool
Throws:
UnsupportedOperationException - if this implementation does not support the operation

getNumIdle

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

Specified by:
getNumIdle in interface ObjectPool
Returns:
the number of instances currently idle in my pool
Throws:
UnsupportedOperationException - if this implementation does not support the operation

returnObject

public abstract void returnObject(Object obj)
                           throws Exception
Description copied from interface: ObjectPool
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.

Specified by:
returnObject in interface ObjectPool
Parameters:
obj - a borrowed instance to be returned.
Exception

setFactory

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

Specified by:
setFactory in interface ObjectPool
Parameters:
factory - the PoolableObjectFactory I use to create new instances.
Throws:
IllegalStateException - when the factory cannot be set at this time
UnsupportedOperationException - if this implementation does not support the operation


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