CacheWrapper.java 2.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
/**
 * $Revision$
 * $Date$
 *
 * Copyright (C) 1999-2005 Jive Software. All rights reserved.
 * This software is the proprietary information of Jive Software. Use is subject to license terms.
 */
package org.jivesoftware.util.cache;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * Acts as a proxy for a Cache implementation. The Cache implementation can be switched on the fly,
 * which enables users to hold a reference to a CacheWrapper object, but for the underlying
 * Cache implementation to switch from clustered to local, etc.
 *
 */
public class CacheWrapper<K, V> implements Cache<K, V> {

    private Cache<K, V> cache;

    public CacheWrapper(Cache<K, V> cache) {
        this.cache = cache;
    }

    public Cache<K, V> getWrappedCache() {
        return cache;
    }

    public void setWrappedCache(Cache<K, V> cache) {
        this.cache = cache;
    }

    public String getName() {
        return cache.getName();
    }

    public void setName(String name) {
        cache.setName(name);
    }

    public long getMaxCacheSize() {
        return cache.getMaxCacheSize();
    }

    public void setMaxCacheSize(int maxSize) {
        cache.setMaxCacheSize(maxSize);
    }

    public long getMaxLifetime() {
        return cache.getMaxLifetime();
    }

    public void setMaxLifetime(long maxLifetime) {
        cache.setMaxLifetime(maxLifetime);
    }

    public int getCacheSize() {
        return cache.getCacheSize();
    }

    public long getCacheHits() {
        return cache.getCacheHits();
    }

    public long getCacheMisses() {
        return cache.getCacheMisses();
    }

    public int size() {
        return cache.size();
    }

    public void clear() {
        cache.clear();
    }

    public boolean isEmpty() {
        return cache.isEmpty();
    }

    public boolean containsKey(Object key) {
        return cache.containsKey(key);
    }

    public boolean containsValue(Object value) {
        return cache.containsValue(value);
    }

    public Collection<V> values() {
        return cache.values();
    }

    public void putAll(Map<? extends K, ? extends V> t) {
        cache.putAll(t);
    }

    public Set<Map.Entry<K, V>> entrySet() {
        return cache.entrySet();
    }

    public Set<K> keySet() {
        return cache.keySet();
    }

    public V get(Object key) {
        return cache.get(key);
    }

    public V remove(Object key) {
        return cache.remove(key);
    }

    public V put(K key, V value) {
        return cache.put(key, value);
    }

}