com.atlassian.threadlocal
Class RegisteredThreadLocals
java.lang.Object
com.atlassian.threadlocal.RegisteredThreadLocals
public class RegisteredThreadLocals
- extends java.lang.Object
A registry of RegisteredThreadLocal objects that can be cleared all at one at the end of a request
The set of registered ThreadLocals is itself a ThreadLocal and that set will be cleared during
reset().
This code is inspired from the blog : http://www.liferay.com/web/shuyang.zhou/blog/-/blogs/4508884 and http://techblog.bozho.net/?p=323
|
Method Summary |
static java.util.Set<java.lang.ThreadLocal<?>> |
get()
|
static java.lang.ThreadLocal |
register(java.lang.ThreadLocal threadLocal)
Call this to register a ThreadLocal that can be cleaned up in one fell swoop via reset() |
static void |
reset()
Call this at the end of the request to ThreadLocal.remove() reset all the ThreadLocal values
This will help prevent warnings in Tomcat and concurrency problems in general. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RegisteredThreadLocals
public RegisteredThreadLocals()
register
public static java.lang.ThreadLocal register(java.lang.ThreadLocal threadLocal)
- Call this to register a ThreadLocal that can be cleaned up in one fell swoop via
reset()
- Parameters:
threadLocal - the ThreadLocal to register
- Returns:
- the ThreadLocal itself to allow builder pattern
reset
public static void reset()
- Call this at the end of the request to
ThreadLocal.remove() reset all the ThreadLocal values
This will help prevent warnings in Tomcat and concurrency problems in general.
get
public static java.util.Set<java.lang.ThreadLocal<?>> get()
- Returns:
- the current set of registered ThreadLocals
Copyright © 2013 Atlassian. All Rights Reserved.