zinger.util.recycling
Class CappedObjectRecycler

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

public class CappedObjectRecycler
extends ObjectRecycler

Performs the same task as its superclass, but allows the ability to specify the maximum number of cached instances. Useful when we know the approximate range of usage and don't want too many objects sitting cached in memory indefinitely after a surge.


Field Summary
protected  int cap
           
 
Fields inherited from class zinger.util.recycling.ObjectRecycler
generator, instances
 
Constructor Summary
CappedObjectRecycler(ObjectGenerator generator, int cap)
           
CappedObjectRecycler(ObjectGenerator generator, java.util.List instances, int cap)
           
 
Method Summary
 boolean recycleObject(java.lang.Object obj)
          Rejects the object if the instance cache exceeds specified size.
 
Methods inherited from class zinger.util.recycling.ObjectRecycler
clearCache, getObject, getObject, instantiate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cap

protected final int cap
Constructor Detail

CappedObjectRecycler

public CappedObjectRecycler(ObjectGenerator generator,
                            java.util.List instances,
                            int cap)

CappedObjectRecycler

public CappedObjectRecycler(ObjectGenerator generator,
                            int cap)
Method Detail

recycleObject

public boolean recycleObject(java.lang.Object obj)
Rejects the object if the instance cache exceeds specified size.

Specified by:
recycleObject in interface ObjectPool
Overrides:
recycleObject in class ObjectRecycler
Returns:
whether the object was recycled
See Also:
ObjectRecycler.getObject(java.lang.Object)