1 21 22 package org.jacorb.notification.util; 23 24 import java.util.Map ; 25 import java.util.WeakHashMap ; 26 27 31 public class WeakCacheWildcardMap implements WildcardMap 32 { 33 private final WildcardMap delegate_; 34 private final Map cache_ = new WeakHashMap (); 35 36 public WeakCacheWildcardMap(WildcardMap delegate) 37 { 38 delegate_ = delegate; 39 } 40 41 public WeakCacheWildcardMap() 42 { 43 this(new DefaultWildcardMap()); 44 } 45 46 public void clear() 47 { 48 delegate_.clear(); 49 cache_.clear(); 50 } 51 52 public Object getNoExpansion(Object key) 53 { 54 return delegate_.getNoExpansion(key); 55 } 56 57 public Object [] getWithExpansion(Object key) 58 { 59 Object [] result = (Object []) cache_.get(key.toString()); 60 61 if (result != null) 62 { 63 return result; 64 } 65 66 result = delegate_.getWithExpansion(key); 67 cache_.put(key.toString(), result); 68 69 return result; 70 } 71 72 public Object put(Object key, Object value) 73 { 74 cache_.remove(key.toString()); 75 76 return delegate_.put(key, value); 77 } 78 79 public Object remove(Object key) 80 { 81 cache_.remove(key.toString()); 82 83 return delegate_.remove(key); 84 } 85 } | Popular Tags |