ix.util.context
Class ThreadLocalHoldingStrategy

java.lang.Object
  extended by ix.util.context.ContextHoldingStrategy
      extended by ix.util.context.ThreadLocalHoldingStrategy
Direct Known Subclasses:
InheritableThreadLocalHoldingStrategy

public class ThreadLocalHoldingStrategy
extends ContextHoldingStrategy

A context-holding strategy that associates context-holders with threads. The holder for a thread is initially null and so must be explicitly set. More than one thread may be given the same context-holder.


Field Summary
(package private)  java.util.WeakHashMap knownHolders
           
(package private)  java.lang.ThreadLocal threadContextHolder
           
 
Constructor Summary
ThreadLocalHoldingStrategy()
           
 
Method Summary
 void clearContexts()
          Tells any ContextHolders it knows about to set their current context to the root context.
 ContextHolder getContextHolder()
          Returns an appropriate context-holder.
 void setContextHolder(ContextHolder h)
          Changes the context-holder that would be returned, if that makes sense.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

knownHolders

java.util.WeakHashMap knownHolders

threadContextHolder

java.lang.ThreadLocal threadContextHolder
Constructor Detail

ThreadLocalHoldingStrategy

public ThreadLocalHoldingStrategy()
Method Detail

getContextHolder

public ContextHolder getContextHolder()
Description copied from class: ContextHoldingStrategy
Returns an appropriate context-holder.

Specified by:
getContextHolder in class ContextHoldingStrategy

setContextHolder

public void setContextHolder(ContextHolder h)
Description copied from class: ContextHoldingStrategy
Changes the context-holder that would be returned, if that makes sense. (Optional operation.)

Overrides:
setContextHolder in class ContextHoldingStrategy

clearContexts

public void clearContexts()
Description copied from class: ContextHoldingStrategy
Tells any ContextHolders it knows about to set their current context to the root context. Called by Context.clearContexts().

Specified by:
clearContexts in class ContextHoldingStrategy