package ri.cache.loader;
import javax.cache.Cache;
import javax.cache.spi.CacheLoaderException;
import javax.cache.spi.CacheLoader;
/**
* FromCacheLoader
*
* @author Brian Goetz
*/
public class FromCacheLoader<K, V> extends AbstractCacheLoader<K, V> implements CacheLoader<K, V> {
private final Cache<K, V> cache;
public FromCacheLoader(Cache<K, V> cache) {
this.cache = cache;
}
public V load(K key) throws CacheLoaderException {
return cache.get(key);
}
public void censorPut(K key, V value) throws CacheLoaderException {
throw new PutNotPermittedException("objects in this cache must be loaded, not put");
}
}
|