org.jboss.msc.value
Class ThreadLocalValue<T>

java.lang.Object
  extended by org.jboss.msc.value.ThreadLocalValue<T>
Type Parameters:
T - the value type
All Implemented Interfaces:
Value<T>

public final class ThreadLocalValue<T>
extends Object
implements Value<T>

A thread-local value. Used to pass values in special situations.

Author:
David M. Lloyd

Constructor Summary
ThreadLocalValue()
          Construct a new instance.
 
Method Summary
 Value<? extends T> getAndSetValue(Value<? extends T> newValue)
          Get and set the value.
 T getValue()
          Get the actual value.
 void setValue(Value<? extends T> newValue)
          Set this value, replacing any current value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadLocalValue

public ThreadLocalValue()
Construct a new instance.

Method Detail

getValue

public T getValue()
Get the actual value.

Specified by:
getValue in interface Value<T>
Returns:
the actual value

setValue

public void setValue(Value<? extends T> newValue)
Set this value, replacing any current value.

Parameters:
newValue - the new value to set

getAndSetValue

public Value<? extends T> getAndSetValue(Value<? extends T> newValue)
Get and set the value. Returns the old value so it can be restored later on (typically in a finally block).

Parameters:
newValue - the new value
Returns:
the old value


Copyright © 2011. All Rights Reserved.