|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cxf.common.util.AbstractTwoStageCache<E>
public abstract class AbstractTwoStageCache<E>
This class pools objects, for efficiency accross a lightweight fixed-size primary cache and a variable-size secondary cache - the latter uses soft references to allow the polled object be GCed if necessary.
To use the cache, a subclass is defined which provides an implementation of the abstract get() method - this may be conveniently achieved via an anonymous subclass. The cache is then populated by calling the populate_cache() method - the reason a two-stage process is used is to avoid problems with the inner class create() method accessing outer class data members from the inner class ctor (before its reference to the outer class is initialized).
Constructor Summary | |
---|---|
AbstractTwoStageCache(int pCacheSize,
int highWaterMark,
int prealloc)
Constructor. |
|
AbstractTwoStageCache(int pCacheSize,
int highWaterMark,
int prealloc,
java.lang.Object mutexParam)
Constructor. |
Method Summary | |
---|---|
protected abstract E |
create()
Over-ride this method to create objects to populate the pool |
E |
get()
Return a cached or newly created object |
E |
poll()
Return a cached object if one is available |
void |
populateCache()
Populate the cache |
boolean |
recycle(E oldObject)
Recycle an old Object. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractTwoStageCache(int pCacheSize, int highWaterMark, int prealloc)
pCacheSize
- primary cache sizesecondary_cache_max
- secondary cache high water markpreallocation
- the number of object to preallocation when the
cache is createdpublic AbstractTwoStageCache(int pCacheSize, int highWaterMark, int prealloc, java.lang.Object mutexParam)
pCacheSize
- primary cache sizesecondary_cache_max
- secondary cache high water markpreallocation
- the number of object to preallocation when the
cache is createdmutex
- object to use as a monitorMethod Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
protected abstract E create() throws java.lang.Exception
java.lang.Exception
public void populateCache() throws java.lang.Exception
java.lang.Exception
public E get() throws java.lang.Exception
java.lang.Exception
public E poll()
public boolean recycle(E oldObject)
oldObject
- the object to recycle
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |