public void clear() { Hashtable<String, Object> ht = tlm.get(); if (ht != null) { ht.clear(); } tlm.remove(); }
public void putAll(Map<String, Object> context) { Hashtable<String, Object> ht = tlm.get(); if (ht == null) { ht = new Hashtable<String, Object>(HT_SIZE); tlm.set(ht); } ht.putAll(context); }
public void put(String key, Object o) { Hashtable<String, Object> ht = tlm.get(); if (ht == null) { ht = new Hashtable<String, Object>(HT_SIZE); tlm.set(ht); } ht.put(key, o); }
public void setContextMap(Map<String, Object> contextMap) { Hashtable<String, Object> ht = tlm.get(); if (ht != null) { ht.clear(); } else { ht = new Hashtable<String, Object>(HT_SIZE); tlm.set(ht); } ht.putAll(contextMap); }
@Override public T get() { ThreadLocalMap threadLocalMap = _getThreadLocalMap(); Entry entry = threadLocalMap.getEntry(this); if (entry == null) { T value = initialValue(); threadLocalMap.putEntry(this, value); return value; } else { return (T) entry._value; } }
public Map<String, Object> getCopyOfContextMap() { Hashtable<String, Object> ht = tlm.get(); if (ht != null) { return new Hashtable<String, Object>(ht); } else { return null; } }
public Object get(String key) { Hashtable ht = tlm.get(); if (ht != null && key != null) { return ht.get(key); } else { return null; } }
public static void setThreadLocals( Map<CentralizedThreadLocal<?>, Object> longLivedThreadLocals, Map<CentralizedThreadLocal<?>, Object> shortLivedThreadLocals) { ThreadLocalMap threadLocalMap = _longLivedThreadLocals.get(); for (Map.Entry<CentralizedThreadLocal<?>, Object> entry : longLivedThreadLocals.entrySet()) { threadLocalMap.putEntry(entry.getKey(), entry.getValue()); } threadLocalMap = _shortLivedThreadLocals.get(); for (Map.Entry<CentralizedThreadLocal<?>, Object> entry : shortLivedThreadLocals.entrySet()) { threadLocalMap.putEntry(entry.getKey(), entry.getValue()); } }
public Map<String, Object> getContext() { return tlm.get(); }
public void remove(String key) { Hashtable ht = tlm.get(); if (ht != null) { ht.remove(key); } }
public static void createLoggerForThread(String fileName) { TrafficLogger logger = new TrafficLogger(fileName); ThreadLocalMap.put("logger", logger); }
public static TrafficLogger getLoggerForThread() { return (TrafficLogger) ThreadLocalMap.get("logger"); }
@Override public void set(T value) { ThreadLocalMap threadLocalMap = _getThreadLocalMap(); threadLocalMap.putEntry(this, value); }
@Override public void remove() { ThreadLocalMap threadLocalMap = _getThreadLocalMap(); threadLocalMap.removeEntry(this); }