org.jasig.portal.utils.threading
Class TrackingThreadLocal<T>

java.lang.Object
  extended by java.lang.ThreadLocal<T>
      extended by org.jasig.portal.utils.threading.TrackingThreadLocal<T>

public class TrackingThreadLocal<T>
extends ThreadLocal<T>

A ThreadLocal subclass that keeps track of all created instances. Using this ThreadLocal subclass in uPortal allows any Runnable wrapped by org.jasig.portal.utils.ThreadLocalCopyRunnable to have the values copied into the appropriate ThreadLocals in the child thread when the Runable is run. This avoids having to write explicit code for each ThreadLocal that needs to be copied.

The references kept the the ThreadLocal instances is done using a weak set so this tracking subclass will not cause leaks by holding on to thread local instances that are no longer referenced.

Version:
$Revision: 1.4 $
Author:
Eric Dalquist

Constructor Summary
TrackingThreadLocal()
           
 
Method Summary
static void clearCurrentData()
           
static void clearCurrentData(Set<TrackingThreadLocal<Object>> locals)
           
static Map<TrackingThreadLocal<Object>,Object> getCurrentData()
           
static Set<TrackingThreadLocal<Object>> getInstances()
          Gets an umodifiable version of the Set of TrackingThreadLocal's that have been created and are still referenced strongly somewhere in the JVM.
static void setCurrentData(Map<TrackingThreadLocal<Object>,Object> localCopies)
           
 
Methods inherited from class java.lang.ThreadLocal
get, initialValue, remove, set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrackingThreadLocal

public TrackingThreadLocal()
Method Detail

getInstances

public static Set<TrackingThreadLocal<Object>> getInstances()
Gets an umodifiable version of the Set of TrackingThreadLocal's that have been created and are still referenced strongly somewhere in the JVM.

Returns:
An unmodifiable set of TrackingThreadLocals

getCurrentData

public static Map<TrackingThreadLocal<Object>,Object> getCurrentData()

setCurrentData

public static void setCurrentData(Map<TrackingThreadLocal<Object>,Object> localCopies)

clearCurrentData

public static void clearCurrentData()

clearCurrentData

public static void clearCurrentData(Set<TrackingThreadLocal<Object>> locals)


Copyright © 2010 Jasig. All Rights Reserved.