Class JiraThreadLocalUtils

  extended by com.atlassian.jira.util.thread.JiraThreadLocalUtils

public class JiraThreadLocalUtils
extends Object

This class has static methods that perform a number of standard operations at the start and end of "runnable code" such as a JiraServiceContainerImpl or a TaskManagerImpl.

The main purpose of this class is to setup and clear ThreadLocal variables that can otherwise interfere with the smooth running of JIRA.

You MUST remember to call postCall() in a finally{} block like this :

 run() {
      try {
          // do runnable code here
      } finally {
          JiraThreadLocalUtils.postCall(log, myProblemDeterminationCallback);


Nested Class Summary
static interface JiraThreadLocalUtils.ProblemDeterminationCallback
          This interface is used as a callback mechansim in the case where "runnnable code" has completed and left things in a bad way.
Constructor Summary
Method Summary
static void postCall(org.apache.log4j.Logger log, JiraThreadLocalUtils.ProblemDeterminationCallback problemDeterminationCallback)
          This should be called in a finally {} block to clear up ThreadLocals once the runnable stuff has been done.
static void preCall()
          This should be called "before" an "runnable code" is called.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public JiraThreadLocalUtils()
Method Detail


public static void preCall()
This should be called "before" an "runnable code" is called. This will setup a clean ThreadLocal environment for the runnable code to execute in.


public static void postCall(org.apache.log4j.Logger log,
                            JiraThreadLocalUtils.ProblemDeterminationCallback problemDeterminationCallback)
This should be called in a finally {} block to clear up ThreadLocals once the runnable stuff has been done.

log - the log to write error messages to in casse of any problems
problemDeterminationCallback - the callback to invoke in case where problems are detected after the runnable code is done running and its not cleaned up properly. This can be null.

Copyright © 2002-2008 Atlassian. All Rights Reserved.