|
|||||||||||
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
This is the base class for caches of data that load all of their contents into memory. The methods implemented here fulfill the requirements of the Cache interfact with the exception of refreshAll. It also implements the Startable and Suspendable interfaces. Refresh and configuration functionality are left up to extending classes.
Copyright 2002 Sapient
Constructor Summary | |
AbstractTotalCache()
|
Method Summary | |
void |
clear()
Removes all mappings from this cache. |
boolean |
containsKey(Object key)
For a given key value, return a boolean indicating if the cache contains a value for the key. |
boolean |
containsValue(Object value)
Returns true if this cache maps one or more keys to the specified value. |
Set |
entrySet()
Returns a set view of the mappings contained in this cache. |
Object |
get(Object key)
For a given key value, return the object associated with the key value from the cache. |
protected abstract Map |
getCacheMap()
Returns a referench to the Map that contains all the cached data. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
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. |
abstract void |
refreshAll()
Refresh the contents of the cache. |
Object |
remove(Object key)
Removes the mapping for this key from this cache. |
void |
resume()
Resume the component. |
void |
runScheduledTask()
This execution should flush the cache of the current entries and refill it from the dataloader with new entries. |
int |
size()
Returns the number of key-value mappings in this map. |
void |
start()
Start the component. |
void |
stop()
Stop the component. |
void |
suspend()
Suspend the component. |
Collection |
values()
Returns a collection view of the values contained in this cache. |
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 |
Constructor Detail |
public AbstractTotalCache()
Method Detail |
public abstract void refreshAll() throws CacheLoadException
refreshAll
in interface Cache
CacheLoadException
- when its data loader has failed to load datapublic void clear()
clear
in interface Map
public boolean containsKey(Object key)
For a given key value, return a boolean indicating if the cache contains a value for the key.
containsKey
in interface Map
key
- key for the desired cache entry
public boolean containsValue(Object value)
(value==null ? v==null : value.equals(v))
.
This operation will require time linear in the cache size.
containsValue
in interface Map
value
- value whose presence in this map is to be
tested.
public Set entrySet()
entrySet
in interface Map
public Object get(Object key)
For a given key value, return the object associated with the key value from the cache. If the value is not found in the cache, or the key is associated with the value null, a null reference is returned. The only way to tell for certain if the cache contains the key is to use the containsKey() method.
get
in interface Map
key
- key for the desired cache entry
Object
public boolean isEmpty()
isEmpty
in interface Map
public Set keySet()
keySet
in interface Map
Set
The set of all keys in the cache.public Object put(Object key, Object value)
put
in interface Map
key
- key for the value to add to this cachevalue
- value to add for the given key
public void putAll(Map t)
putAll
in interface Map
t
- the map to place all values of into this cachepublic Object remove(Object key)
remove
in interface Map
key
- the key to remove from the cache
public int size()
size
in interface Map
public Collection values()
values
in interface Map
public void start() throws CacheLoadException
Startable
start
in interface Startable
CacheLoadException
Startable.start()
public void stop()
Startable
stop
in interface Startable
Startable.stop()
public void resume() throws CacheLoadException
Suspendable
resume
in interface Suspendable
CacheLoadException
Suspendable.resume()
public void suspend()
Suspendable
suspend
in interface Suspendable
Suspendable.suspend()
public void runScheduledTask() throws CacheLoadException
runScheduledTask
in interface Schedulable
CacheLoadException
- when their is a failure to load the values
from the dataloader.Schedulable.runScheduledTask()
protected abstract Map getCacheMap()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |