001: /**
002: * $Revision$
003: * $Date$
004: *
005: * Copyright (C) 1999-2005 Jive Software. All rights reserved.
006: * This software is the proprietary information of Jive Software. Use is subject to license terms.
007: */package org.jivesoftware.util.cache;
008:
009: import java.util.Collection;
010: import java.util.Map;
011: import java.util.Set;
012:
013: /**
014: * Acts as a proxy for a Cache implementation. The Cache implementation can be switched on the fly,
015: * which enables users to hold a reference to a CacheWrapper object, but for the underlying
016: * Cache implementation to switch from clustered to local, etc.
017: *
018: */
019: public class CacheWrapper<K, V> implements Cache<K, V> {
020:
021: private Cache<K, V> cache;
022:
023: public CacheWrapper(Cache<K, V> cache) {
024: this .cache = cache;
025: }
026:
027: public Cache<K, V> getWrappedCache() {
028: return cache;
029: }
030:
031: public void setWrappedCache(Cache<K, V> cache) {
032: this .cache = cache;
033: }
034:
035: public String getName() {
036: return cache.getName();
037: }
038:
039: public void setName(String name) {
040: cache.setName(name);
041: }
042:
043: public long getMaxCacheSize() {
044: return cache.getMaxCacheSize();
045: }
046:
047: public void setMaxCacheSize(int maxSize) {
048: cache.setMaxCacheSize(maxSize);
049: }
050:
051: public long getMaxLifetime() {
052: return cache.getMaxLifetime();
053: }
054:
055: public void setMaxLifetime(long maxLifetime) {
056: cache.setMaxLifetime(maxLifetime);
057: }
058:
059: public int getCacheSize() {
060: return cache.getCacheSize();
061: }
062:
063: public long getCacheHits() {
064: return cache.getCacheHits();
065: }
066:
067: public long getCacheMisses() {
068: return cache.getCacheMisses();
069: }
070:
071: public int size() {
072: return cache.size();
073: }
074:
075: public void clear() {
076: cache.clear();
077: }
078:
079: public boolean isEmpty() {
080: return cache.isEmpty();
081: }
082:
083: public boolean containsKey(Object key) {
084: return cache.containsKey(key);
085: }
086:
087: public boolean containsValue(Object value) {
088: return cache.containsValue(value);
089: }
090:
091: public Collection<V> values() {
092: return cache.values();
093: }
094:
095: public void putAll(Map<? extends K, ? extends V> t) {
096: cache.putAll(t);
097: }
098:
099: public Set<Map.Entry<K, V>> entrySet() {
100: return cache.entrySet();
101: }
102:
103: public Set<K> keySet() {
104: return cache.keySet();
105: }
106:
107: public V get(Object key) {
108: return cache.get(key);
109: }
110:
111: public V remove(Object key) {
112: return cache.remove(key);
113: }
114:
115: public V put(K key, V value) {
116: return cache.put(key, value);
117: }
118:
119: }
|