1 package org.jboss.cache.lock; 2 3 import java.util.Collection ; 4 import java.util.HashMap ; 5 import java.util.Map ; 6 import java.util.Set ; 7 8 14 public class ThreadLocalMap implements Map { 15 16 private ThreadLocal threadLocal = new ThreadLocal (); 17 18 private Map getThreadLocalMap() { 19 Map map = (Map ) threadLocal.get(); 20 if (map == null) { 21 map = new HashMap (); 22 threadLocal.set(map); 23 } 24 return map; 25 } 26 27 public Object put(Object key, Object value) { 28 return getThreadLocalMap().put(key, value); 29 } 30 31 public Object get(Object key) { 32 return getThreadLocalMap().get(key); 33 } 34 35 public Object remove(Object key) { 36 return getThreadLocalMap().remove(key); 37 } 38 39 public int size() { 40 return getThreadLocalMap().size(); 41 } 42 43 public void clear() { 44 getThreadLocalMap().clear(); 45 } 46 47 public boolean isEmpty() { 48 return getThreadLocalMap().isEmpty(); 49 } 50 51 public boolean containsKey(Object arg0) { 52 return getThreadLocalMap().containsKey(arg0); 53 } 54 55 public boolean containsValue(Object arg0) { 56 return getThreadLocalMap().containsValue(arg0); 57 } 58 59 public Collection values() { 60 return getThreadLocalMap().values(); 61 } 62 63 public void putAll(Map arg0) { 64 getThreadLocalMap().putAll(arg0); 65 } 66 67 public Set entrySet() { 68 return getThreadLocalMap().entrySet(); 69 } 70 71 public Set keySet() { 72 return getThreadLocalMap().keySet(); 73 } 74 75 } | Popular Tags |