public class FilterManager
extends java.lang.Object
RemoteCachingWrapperFilter
or just to save filters locally for reuse.
This class makes it possble to cache Filters even when using RMI, as it
keeps the cache on the seaercher side of the RMI connection.
Also could be used as a persistent storage for any filter as long as the
filter provides a proper hashCode(), as that is used as the key in the cache.
The cache is periodically cleaned up from a separate thread to ensure the
cache doesn't exceed the maximum size.Modifier and Type | Class and Description |
---|---|
protected class |
FilterManager.FilterCleaner
Keeps the cache from getting too big.
|
protected class |
FilterManager.FilterItem
Holds the filter and the last time the filter was used, to make LRU-based
cache cleaning possible.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.Map |
cache
The cache itself
|
protected int |
cacheCleanSize
Maximum allowed cache size
|
protected long |
cleanSleepTime
Cache cleaning frequency
|
protected static int |
DEFAULT_CACHE_CLEAN_SIZE
The default maximum number of Filters in the cache
|
protected static long |
DEFAULT_CACHE_SLEEP_TIME
The default frequency of cache clenup
|
protected FilterManager.FilterCleaner |
filterCleaner
Cache cleaner that runs in a separate thread
|
protected static FilterManager |
manager |
Modifier | Constructor and Description |
---|---|
protected |
FilterManager()
Sets up the FilterManager singleton.
|
Modifier and Type | Method and Description |
---|---|
Filter |
getFilter(Filter filter)
Returns the cached version of the filter.
|
static FilterManager |
getInstance() |
void |
setCacheSize(int cacheCleanSize)
Sets the max size that cache should reach before it is cleaned up
|
void |
setCleanThreadSleepTime(long cleanSleepTime)
Sets the cache cleaning frequency in milliseconds.
|
protected static FilterManager manager
protected static final int DEFAULT_CACHE_CLEAN_SIZE
protected static final long DEFAULT_CACHE_SLEEP_TIME
protected java.util.Map cache
protected int cacheCleanSize
protected long cleanSleepTime
protected FilterManager.FilterCleaner filterCleaner
public static FilterManager getInstance()
public void setCacheSize(int cacheCleanSize)
cacheCleanSize
- maximum allowed cache sizepublic void setCleanThreadSleepTime(long cleanSleepTime)
cleanSleepTime
- cleaning frequency in milliosecondspublic Filter getFilter(Filter filter)
filter
- The input filterCopyright © 2000-2014 Apache Software Foundation. All Rights Reserved.