zinger.util.recycling
Class CappedObjectRecycler

java.lang.Object
  |
  +--zinger.util.recycling.ObjectRecycler
        |
        +--zinger.util.recycling.CappedObjectRecycler

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)
           
 
Method Summary
 boolean recycleObject(java.lang.Object obj)
          Puts obj into the cache.
 
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, registerNatives, toString, wait, wait, wait
 

Field Detail

cap

protected final int cap
Constructor Detail

CappedObjectRecycler

public CappedObjectRecycler(ObjectGenerator generator,
                            int cap)
Method Detail

recycleObject

public boolean recycleObject(java.lang.Object obj)
Description copied from class: ObjectRecycler
Puts obj into the cache. It is the user's responsibility to make sure only the objects that were generated this instance are returned. If getObject method encounters a bad instance from the cache, it will discard it and go on to the next one.
Overrides:
recycleObject in class ObjectRecycler
Following copied from class: zinger.util.recycling.ObjectRecycler
Returns:
whether the object was recycled
See Also:
ObjectRecycler.getObject(java.lang.Object)