01: package ri.cache.loader;
02:
03: import javax.cache.Cache;
04: import javax.cache.spi.CacheLoaderException;
05: import javax.cache.spi.CacheLoader;
06:
07: /**
08: * FromCacheLoader
09: *
10: * @author Brian Goetz
11: */
12: public class FromCacheLoader<K, V> extends AbstractCacheLoader<K, V>
13: implements CacheLoader<K, V> {
14: private final Cache<K, V> cache;
15:
16: public FromCacheLoader(Cache<K, V> cache) {
17: this .cache = cache;
18: }
19:
20: public V load(K key) throws CacheLoaderException {
21: return cache.get(key);
22: }
23:
24: public void censorPut(K key, V value) throws CacheLoaderException {
25: throw new PutNotPermittedException(
26: "objects in this cache must be loaded, not put");
27: }
28: }
|