|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--org.sape.carbon.services.cache.total.AbstractTotalCache
|
+--org.sape.carbon.services.cache.total.ReadOnlyCache
This Total Cache implementation is intended for fast
reading of data which expires periodically as a whole. This implementation
is optimized for read operations. All operations on the Map interface
that could modify the cache are not supported and throw
UnsupportedOperationException.
Two hashmaps are used during the operation of the cache. The activeMap is the active map which is used to service all get requests for the cache. The holdingMap is used to reinitialize the cache. A call to initializeHoldingCache() creates a new holding map. The new map is then filled with all the information from the data loader. Then activateHoldingCache() atomically replaces the activeMap with the holdingMap and dereferences the old activeMap for garbage collection.
Copyright 2003 Sapient
| Field Summary | |
private Map |
activeMap
The active map the cache queries against. |
private TotalCacheDataLoader |
dataLoader
Holds the dataloader for this cache. |
private Map |
holdingMap
A background map used for reloading the cache to minimize synchronization time. |
private org.apache.commons.logging.Log |
log
The handle to Apache-commons logger |
| Constructor Summary | |
ReadOnlyCache()
|
|
| Method Summary | |
private void |
activateHoldingCache()
Replace the activeMap with the holdingMap |
void |
clear()
Removes all mappings from this cache. |
void |
configure(ComponentConfiguration configuration)
Configure the component. |
Set |
entrySet()
Returns a set view of the mappings contained in this cache. |
protected Map |
getCacheMap()
Returns a referench to the Map that contains all the cached data. |
private void |
initializeHoldingCache()
Initialize the holdingMap |
Set |
keySet()
Returns the keys of the cache. |
Object |
put(Object key,
Object value)
Put the Object value into the cache referenced by the Object key |
void |
putAll(Map t)
Copies all of the mappings from the specified map to this cache. |
void |
refreshAll()
Refresh the contents of the cache. |
Object |
remove(Object key)
Removes the mapping for this key from this cache. |
Collection |
values()
Returns a collection view of the values contained in this cache. |
| Methods inherited from class org.sape.carbon.services.cache.total.AbstractTotalCache |
containsKey, containsValue, get, isEmpty, resume, runScheduledTask, size, start, stop, suspend |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
equals, hashCode |
| Field Detail |
private org.apache.commons.logging.Log log
private Map activeMap
private Map holdingMap
private TotalCacheDataLoader dataLoader
| Constructor Detail |
public ReadOnlyCache()
| Method Detail |
public void refreshAll()
throws CacheLoadException
refreshAll in interface CacherefreshAll in class AbstractTotalCacheCacheLoadException - when its data loader has failed to load datapublic void configure(ComponentConfiguration configuration)
Configurable
configure in interface Configurableconfiguration - the configuration for this componentConfigurable.configure(ComponentConfiguration)public Set entrySet()
AbstractTotalCache
entrySet in interface MapentrySet in class AbstractTotalCacheMap.entrySet()public Set keySet()
AbstractTotalCache
keySet in interface MapkeySet in class AbstractTotalCacheMap.keySet()public Collection values()
AbstractTotalCache
values in interface Mapvalues in class AbstractTotalCacheMap.values()public void clear()
AbstractTotalCache
clear in interface Mapclear in class AbstractTotalCacheUnsupportedOperationException - this is a read-only cache,
modification methods are not supportedMap.clear()
public Object put(Object key,
Object value)
AbstractTotalCache
put in interface Mapput in class AbstractTotalCachekey - the key to add to the mapvalue - the value to add for the key
UnsupportedOperationException - this is a read-only cache,
modification methods are not supportedMap.put(Object, Object)public void putAll(Map t)
AbstractTotalCache
putAll in interface MapputAll in class AbstractTotalCachet - the map to place into the cache
UnsupportedOperationException - this is a read-only cache,
modification methods are not supportedMap.putAll(Map)public Object remove(Object key)
AbstractTotalCache
remove in interface Mapremove in class AbstractTotalCachekey - the key to remove from this map
UnsupportedOperationException - this is a read-only cache,
modification methods are not supportedMap.remove(Object)protected Map getCacheMap()
AbstractTotalCache
getCacheMap in class AbstractTotalCacheAbstractTotalCache.getCacheMap()private void activateHoldingCache()
Replace the activeMap with the holdingMap
private void initializeHoldingCache()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||