FromCacheLoader.java :  » 6.0-JDK-Modules » jsr107 » ri » cache » loader » Java Open Source

Java Open Source » 6.0 JDK Modules » jsr107 
jsr107 » ri » cache » loader » FromCacheLoader.java
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");
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.