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

Type Parameters:
K - Type of keys in the cache. The keys should bahave well as map keys (most probably, the hashCode() and equals() methods should be overriden).
T - Type of the values bound to the keys in the cache.

public interface CacheItemDataSource<K,T>

Basic interface when using a renewable cache item --- defines methods, which are used to determine what values should be put to the cache. The init(Object) method is called when a user demands a value for a key that hasn't been accessed before. That value is then placed in the cache, and updated periodically in the background, using the update(Object, Object) method. How often the updates happen, depends on the settings of the RenewableCacheServiceMBean and on settings passed when creating the cache item (CacheItem#create(CacheItemDataSource, org.jboss.cache.Fqn, String, long)).

Author:
Adam Warski

Method Summary
 java.lang.String getInfo()
           
 T init(K key)
          Called when the user demands an object which hasn't been accessed before, and thus, which hasn't been yet initialized.
 ValueChange<T> update(K key, T currentObject)
          Called by the service periodically to update the object held in the cache, bound to the given key.
 

Method Detail

update

ValueChange<T> update(K key,
                      T currentObject)
Called by the service periodically to update the object held in the cache, bound to the given key. The value current held in the cache can be changed or not.

Parameters:
key - Key of the object to update.
currentObject - Current value held in the cache.
Returns:
Can return either:

init

T init(K key)
Called when the user demands an object which hasn't been accessed before, and thus, which hasn't been yet initialized.

Parameters:
key - Key of the object to initialize.
Returns:
Initial value of an object with the given key.

getInfo

java.lang.String getInfo()
Returns:
Additional information about this data source, which is visible for example in the cache administration web application. Has no influence on the behaviour or content of the cache.