org.codehaus.aspectwerkz.util
Class SerializableThreadLocal

java.lang.Object
  extended by java.lang.ThreadLocal
      extended by org.codehaus.aspectwerkz.util.SerializableThreadLocal
All Implemented Interfaces:
Serializable

public class SerializableThreadLocal
extends ThreadLocal
implements Serializable

Extends the java.lang.ThreadLocal to be able to add additional functionality.

This classes enhances the base implementation by:

making it serializable

making it wrap an unwrap the values in a java.lang.ref.WeakReference to avoid potential memory leaks

Author:
Jonas BonŽr
See Also:
Serialized Form

Constructor Summary
SerializableThreadLocal()
          Constructor.
 
Method Summary
 Object get()
          Overrides the java.lang.ThreadLocal#get() method.
 void set(Object value)
          Overrides the java.lang.ThreadLoca#set(Object value) method.
 
Methods inherited from class java.lang.ThreadLocal
initialValue, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializableThreadLocal

public SerializableThreadLocal()
Constructor. Simply calls the base class constructor.

Method Detail

get

public Object get()
Overrides the java.lang.ThreadLocal#get() method. Retrieves and returns the value wrapped up in a java.lang.ref.WeakReference by the SerializableThreadLocal#set(Object value) method

Overrides:
get in class ThreadLocal
Returns:
the value wrapped up in a weak reference

set

public void set(Object value)
Overrides the java.lang.ThreadLoca#set(Object value) method. Wraps the value in a java.lang.ref.WeakReference before passing it on to the java.lang.ThreadLocal#set(Object value) method

Overrides:
set in class ThreadLocal
Parameters:
value - the value that should be wrapped up in a weak reference


Copyright © 2002-2005 Jonas Bonér, Alexandre Vasseur. All Rights Reserved.