zinger.util.recycling
Class SynchronizedObjectPool

java.lang.Object
  extended by zinger.util.recycling.SynchronizedObjectPool
All Implemented Interfaces:
ObjectPool

public class SynchronizedObjectPool
extends java.lang.Object
implements ObjectPool


Field Summary
protected  ObjectPool pool
           
 
Constructor Summary
SynchronizedObjectPool(ObjectPool pool)
           
 
Method Summary
 void clearCache()
          Clears existing cache.
 java.lang.Object getObject()
          Gets an instance out of the pool with default initialization.
 java.lang.Object getObject(java.lang.Object arg)
          Gets an instance out of the pool and initializes it using the specified parameter object.
 boolean recycleObject(java.lang.Object obj)
          Returns an object into the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pool

protected final ObjectPool pool
Constructor Detail

SynchronizedObjectPool

public SynchronizedObjectPool(ObjectPool pool)
Method Detail

getObject

public java.lang.Object getObject()
                           throws java.lang.IllegalArgumentException
Description copied from interface: ObjectPool
Gets an instance out of the pool with default initialization. This is equivalent to calling getObject(null).

Specified by:
getObject in interface ObjectPool
Throws:
java.lang.IllegalArgumentException
See Also:
ObjectPool.getObject(java.lang.Object)

getObject

public java.lang.Object getObject(java.lang.Object arg)
                           throws java.lang.IllegalArgumentException
Description copied from interface: ObjectPool
Gets an instance out of the pool and initializes it using the specified parameter object.

Specified by:
getObject in interface ObjectPool
Parameters:
arg - Initialization parameter. If null, default initialziation is used.
Throws:
java.lang.IllegalArgumentException

recycleObject

public boolean recycleObject(java.lang.Object obj)
Description copied from interface: ObjectPool
Returns an object into the pool. By calling this method, the user guarantees not to perform any more operation on the passed-in instance. The pool does not guarantee the passed-in instance will be accepted, or if accepted that it will ever be returned by getObject() or getObject(arg).

Specified by:
recycleObject in interface ObjectPool
See Also:
ObjectPool.getObject(), ObjectPool.getObject(java.lang.Object)

clearCache

public void clearCache()
Description copied from interface: ObjectPool
Clears existing cache. This could be useful if a memory monitor was connected to this instance and ran in the background. It could know to discard cache when activity is down and memory usage is high.

Specified by:
clearCache in interface ObjectPool