|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@PublicApi public interface JiraThreadLocalUtil
The main purpose of this component is to setup and clear ThreadLocal
variables that
can otherwise interfere with the smooth running of JIRA by leaking resources or allowing
stale cached information to survive between requests.
JiraService
or as a
PluginJob
do not need to use
this component, because the scheduler will perform the cleanup automatically as part of
the service's execution lifecycle. However, any plugin that creates its own threads
for background processing must use this component to guard its work. Prior to JIRA v6.0,
the only way to do this was to access the jira-core
class JiraThreadLocalUtils
directly.
You must place the cleanup call to postCall(Logger)
or
postCall(Logger, WarningCallback)
in a finally
block
to guarantee correct behaviour. For example:
public void run()
{
jiraThreadLocalUtil.preCall();
try
{
// do runnable code here
}
finally
{
jiraThreadLocalUtil.postCall(log, myWarningCallback);
}
}
Nested Class Summary | |
---|---|
static interface |
JiraThreadLocalUtil.WarningCallback
This interface is used as a callback mechanism in the case where "runnable code" has completed and the postCall determines that it did not clean
up properly. |
Method Summary | |
---|---|
void |
postCall(org.apache.log4j.Logger log)
This convenience method is equivalent to postCall(log, null) . |
void |
postCall(org.apache.log4j.Logger log,
JiraThreadLocalUtil.WarningCallback warningCallback)
This should be called in a finally block to clear up ThreadLocal s
once the runnable stuff has been done. |
void |
preCall()
This should be called before any "runnable code" is called. |
Method Detail |
---|
void preCall()
ThreadLocal
environment for the runnable
code to execute in.
void postCall(org.apache.log4j.Logger log)
postCall(log, null)
.
log
- as for postCall(Logger, WarningCallback)
void postCall(org.apache.log4j.Logger log, JiraThreadLocalUtil.WarningCallback warningCallback)
finally
block to clear up ThreadLocal
s
once the runnable stuff has been done.
log
- the log to write error messages to in casse of any problemswarningCallback
- the callback to invoke in case where problems are
detected after the runnable code is done running and its not cleaned up properly.
This may be null
, in which case those problems are logged as errors.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |