|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.shotoku.cache.ShotokuCacheItem<K,T>
K
- Type of the key of the objects held in cache. The keys
should bahave well as map keys (most probably, the hashCode() and
equals() methods should be overriden).T
- Type of the object that will be stored in the cache.public abstract class ShotokuCacheItem<K,T>
Extend this class if you want to store objects in the cache that will be updated on every Shotoku service timer timeout. The cache item will be auto-registered in the service upon construction - so take care when constructing objects of this class.
Constructor Summary | |
---|---|
ShotokuCacheItem()
|
|
ShotokuCacheItem(long interval)
|
Method Summary | |
---|---|
T |
get(K key)
Gets an object that is bound to the given key in the cache. |
protected ContentManager |
getContentManager(K key)
Use this to bind a content manager with a key. |
abstract T |
init(K key)
Called when the user demanded an object which hasn't been accessed before, and thus, which hasn't been yet initialized. |
protected ContentManager |
initContentManager(K key)
Called when getContentManager(key) is called for the first time. |
void |
put(K key,
T object)
Binds the given key with the given object in the cache. |
void |
remove()
Removes all keys handled by this ShotokuCacheItem from the cache. |
void |
update()
Called by the Shotoku service. |
abstract void |
update(K key,
T currentObject)
Called by the service periodically to update the object held. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ShotokuCacheItem(long interval)
interval
- Interval at which the update operation will be executed.
Effectively, the interval will be rounded to the nearest multiplicity of
the service timer interval. The interval should be given in milliseconds.public ShotokuCacheItem()
Method Detail |
---|
public final void put(K key, T object) throws CacheException
key
- Key of the object.object
- Object that should be bound.
CacheException
public final T get(K key)
key
- Key of the object to get.
public final void remove()
public final void update()
public abstract void update(K key, T currentObject)
key
- Key of the object to update.currentObject
- Current value held in the cache.public abstract T init(K key)
key
- Key of the object to initialize.
protected final ContentManager getContentManager(K key)
key
- Key for which to get the content manager.
protected ContentManager initContentManager(K key)
key
- Key for which the content manager should be initialized.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |