org.jboss.shotoku.cache
Interface CacheItemUser<K,T>

Type Parameters:
K - Type of the keys in the cache.
T - Type of the values bound to the keys in the cache.
All Known Subinterfaces:
CacheItemOperations<K,T>
All Known Implementing Classes:
CacheItem

public interface CacheItemUser<K,T>

An interface presented to the user of the cache item. Its main function is to retrieve values from the cache, but also to get configuration information and information about the current state of keys (their last updates, etc) handeled by this cache item.

Author:
Adam Warski

Method Summary
 T get(K key)
          Gets an object that is bound to the given key in the associated TreeCache node.
 Fqn getFqn()
           
 int getId()
           
 java.lang.String getInfo()
           
 long getInterval()
           
 java.util.Set<K> getKeysDuringUpdate()
           
 java.util.Map<K,java.lang.Throwable> getKeysExceptions()
           
 java.util.Map<K,java.lang.Long> getKeysUpdates()
           
 java.lang.String getMbeanName()
           
 java.lang.String getName()
           
 void register()
          Registers this cache item in the service.
 void resetKey(java.lang.Object key)
          Resets the given key, that is, it's update status.
 void setInterval(long interval)
           
 void unregister()
          Removes all keys handled by this cache item from the associated TreeCache node and stops updates on this cache item.
 

Method Detail

resetKey

void resetKey(java.lang.Object key)
Resets the given key, that is, it's update status. Hence, if a thread updating a key locks for some reason, it is possible to resume updates of this key. Use with caution.

Parameters:
key - Key, which update status should be reset.

get

T get(K key)
Gets an object that is bound to the given key in the associated TreeCache node. If this object is not in the cache, it will be initialized (using the CacheItemDataSource.init(Object) method of a data source that was passed to CacheItem.create(CacheItemDataSource)).

Parameters:
key - Key of the object to get.
Returns:
Value of the object.

register

void register()
Registers this cache item in the service. This method is automatically called when creating the cache item (using CacheItem.create(CacheItemDataSource)), so you will only need to use it if you previously manually unregistered the cache item using unregister().


unregister

void unregister()
Removes all keys handled by this cache item from the associated TreeCache node and stops updates on this cache item.


getFqn

Fqn getFqn()
Returns:
A fqn of a TreeCache node associated with this cache item. This is a node in which data will be kept.

getInterval

long getInterval()
Returns:
Interval at which updates of keys will be executed. Effectively, the interval will be rounded to the nearest multiplicity of the service update thread interval. The interval should be given in milliseconds. If it is 0, the CacheItemDataSource.update(Object, Object) method will be executed on every service thread update (for every key).

setInterval

void setInterval(long interval)
Parameters:
interval - Interval at which the update operation will be executed. Effectively, the interval will be rounded to the nearest multiplicity of the service update thread interval. The interval should be given in milliseconds. If it is 0, the CacheItemDataSource.update(Object, Object) method will be executed on every service thread update (for every key).

getMbeanName

java.lang.String getMbeanName()
Returns:
Name of an mbean implementing the RenewableCacheServiceMBean interface, associated with this cache item.

getId

int getId()
Returns:
A unique id of this instance of cache item.

getInfo

java.lang.String getInfo()
Returns:
Additional information about the state of a data source for this cache item. Returns CacheItemDataSource.getInfo().

getName

java.lang.String getName()
Returns:
Name of this CacheItem --- the fully qualified name of the class implementing CacheItemDataSource.

getKeysUpdates

java.util.Map<K,java.lang.Long> getKeysUpdates()
Returns:
A map of keys, which are handeled by this cache item, and corresponding last update times.

getKeysDuringUpdate

java.util.Set<K> getKeysDuringUpdate()
Returns:
A set of keys, which are currently being updated.

getKeysExceptions

java.util.Map<K,java.lang.Throwable> getKeysExceptions()
Returns:
A map of keys, in which an exception occured during an update.