beowulf.util.pooling
Interface Pool

All Known Implementing Classes:
ReflectionPool

public interface Pool

This is supposed to represent a generic Pooling interface. It can be implemented in any way that the implementor sees fit, but the intent sould always be kept in mind. The premise of pooling supposes that creating new instances of objects is relatively expensive and that having a pool of unused objects would save the costs of instantiation for frequently instantiated objects.

Version:
1.0 11/7/2003
Author:
Andy Scukanec (ags at cs dot cornell dot edu)

Method Summary
 void checkIn(Object returnedObject)
          This method is designed so that implementing subclasses will have a generic way to accept now-unused objects from the user.
 Object checkOut()
          This method should return an instance of the class that this pool is responsible for spawning.
 Class getPoolClass()
          This method will return the class of the objects that this pool will generate.
 

Method Detail

getPoolClass

public Class getPoolClass()
This method will return the class of the objects that this pool will generate.

Returns:
The class of objects generated by this pool.

checkOut

public Object checkOut()
This method should return an instance of the class that this pool is responsible for spawning. Ideally, an implementing subclass would keep a collection of unused instances and just return one of those. If no more instances exist, it is implementor dependant on how a new instance is generated. Upon returning from the call however, a valid instance must be returned.

Returns:
An instance of the class that this pool is responsible for spawning.

checkIn

public void checkIn(Object returnedObject)
This method is designed so that implementing subclasses will have a generic way to accept now-unused objects from the user. The intent is that the implementing class will hold onto the returned object and keep it for use at a later time. Losing the reference to the object would defeat the purpose of pooling, unless the pool size needs to shrink, etc.

Parameters:
returnedObject - The object to be checked back in.