com.orderlysoftware.orderlycalls.base
Class ObjectPool

java.lang.Object
  extended by com.orderlysoftware.orderlycalls.base.ObjectPool

public class ObjectPool
extends java.lang.Object

This class is used by the framework to pool objects for increased performance.

You should consider pooling your own objects - please see the example code for examples of how to pool AGIProcessors and ManagerEventListeners.

Author:
Matt King, M.A. Oxon.

Constructor Summary
ObjectPool()
           
 
Method Summary
static java.lang.Object find(java.lang.Class c)
          Alternative method for pooling objects that do not have a zero-argument constructor.
static void free(java.lang.Object o)
          Returns an object to the pool.
static java.lang.Object getInstance(java.lang.Class c)
          Pooled objects MUST have a no-argument constructor to work with this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPool

public ObjectPool()
Method Detail

getInstance

public static java.lang.Object getInstance(java.lang.Class c)
Pooled objects MUST have a no-argument constructor to work with this method.

Parameters:
c - the class of the object to get.
Returns:
An object of the passed class. If no such object can be found, a new one is created.

find

public static java.lang.Object find(java.lang.Class c)
Alternative method for pooling objects that do not have a zero-argument constructor.

This method does NOT instantiate objects if none can be found.

Parameters:
c - the class of the object to find.
Returns:
an object from the pool if one can be found, or null.

free

public static void free(java.lang.Object o)
Returns an object to the pool.

You MUST call this method when you have finished with your object if it is to be reused.

You SHOULD ensure that all non-static member fields of your object have been reset before calling this method.

You CAN pool objects that have not been created with getInstance().

Parameters:
o - the object to return to the pool.