org.nees.util.cache
Class CachingStrategy

java.lang.Object
  extended byorg.nees.util.cache.CachingStrategy
Direct Known Subclasses:
ObjectCountingCachingStrategy, SimpleCachingStrategy

public abstract class CachingStrategy
extends java.lang.Object

CachingStrategies negotiate access to an expensive underlying resource through a single accessor method, get(). The strategy can fetch objects from an underlying resource which implements the Cacheable interface, and can also manage a Cache of objects so as to reduce usage of the underlying resource.

See Also:
Cacheable, Cache

Constructor Summary
CachingStrategy()
           
CachingStrategy(Cache cache, Cacheable cacheable)
           
 
Method Summary
abstract  java.lang.Object get(java.lang.Object key)
          Get an object by key.
 Cache getCache()
           
 Cacheable getCacheable()
           
 void setCache(Cache c)
           
 void setCacheable(Cacheable c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingStrategy

public CachingStrategy(Cache cache,
                       Cacheable cacheable)
Parameters:
cache - the cache
cacheable - the cacheable resources

CachingStrategy

public CachingStrategy()
Method Detail

setCacheable

public void setCacheable(Cacheable c)

getCacheable

public Cacheable getCacheable()

setCache

public void setCache(Cache c)

getCache

public Cache getCache()

get

public abstract java.lang.Object get(java.lang.Object key)
                              throws java.lang.Exception
Get an object by key. Override this to provide specific caching behavior.

Parameters:
key - the key
Returns:
the associated object
Throws:
java.lang.Exception