1 8 package org.apache.avalon.excalibur.cache; 9 10 import org.apache.avalon.framework.thread.ThreadSafe; 11 12 19 public class SynchronizedCache 20 implements ThreadSafe, Cache 21 { 22 private Cache m_cache; 23 24 public SynchronizedCache( final Cache cache ) 25 { 26 m_cache = cache; 27 } 28 29 public void addListener( final CacheListener listener ) 30 { 31 m_cache.addListener( listener ); 32 } 33 34 public void removeListener( final CacheListener listener ) 35 { 36 m_cache.removeListener( listener ); 37 } 38 39 public int capacity() 40 { 41 synchronized ( m_cache ) 42 { 43 return m_cache.capacity(); 44 } 45 } 46 47 public int size() 48 { 49 synchronized ( m_cache ) 50 { 51 return m_cache.size(); 52 } 53 } 54 55 public Object put( final Object key, final Object value ) 56 { 57 synchronized ( m_cache ) 58 { 59 return m_cache.put( key, value ); 60 } 61 } 62 63 public Object get( final Object key ) 64 { 65 synchronized ( m_cache ) 66 { 67 return m_cache.get( key ); 68 } 69 } 70 71 public Object remove( Object key ) 72 { 73 synchronized ( m_cache ) 74 { 75 return m_cache.remove( key ); 76 } 77 } 78 79 public boolean containsKey( final Object key ) 80 { 81 synchronized ( m_cache ) 82 { 83 return m_cache.containsKey( key ); 84 } 85 } 86 87 public void clear() 88 { 89 synchronized ( m_cache ) 90 { 91 m_cache.clear(); 92 } 93 } 94 } 95 | Popular Tags |