public class RelatedThread extends ContextAwareThread
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Thread |
main
The "main" thread of the related threads.
|
private static java.util.HashMap<java.lang.Thread,java.util.Map<java.lang.Object,java.lang.Object>> |
storage
Stores a map that is shared between all related sessions.
|
sm, stack| Constructor and Description |
|---|
RelatedThread(java.lang.Runnable core)
Constructor which allows the core logic to be specified.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Object |
get(java.lang.Object key)
Obtain the common object mapped by the given key for the current thread's related thread
group.
|
boolean |
needsSession()
Report if this thread should create a new session when the security context is pushed or if
the existing session should be reused.
|
private static java.util.Map<java.lang.Object,java.lang.Object> |
relatedStorage()
Lookup the related thread storage for the given thread.
|
static java.lang.Object |
remove(java.lang.Object key)
Remove the mapping (both the key and the value), if one is present for that key.
|
static void |
set(java.lang.Object key,
java.lang.Object value)
Store the common object using the given key for the current thread's related thread
group.
|
runactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprivate static final java.util.HashMap<java.lang.Thread,java.util.Map<java.lang.Object,java.lang.Object>> storage
private final java.lang.Thread main
public RelatedThread(java.lang.Runnable core)
throws java.lang.NullPointerException
core - The logic to execute when the thread is started. Must not be null.java.lang.NullPointerException - If the instantiating thread has no security context or if core is
null.public static java.lang.Object get(java.lang.Object key)
RelatedThread instance), then there will be no object returned.key - Object used as a key in the lookup.null if there is no
object mapped under that key OR if the current thread is not part of a related
thread group.public static void set(java.lang.Object key,
java.lang.Object value)
RelatedThread instance), then there will be no object stored.
Do NOT use an easily guessed key (e.g. a string) for any stored resource. This storage facility is by nature a public facility. Any code that can run on the current thread can read a stored value if the key is known. If you have a named resource that you need to store, do not use the name as a key. Keep your own private map of the names to keys and use a new Object instance as the keys.
key - Object used as a key in the mapping.value - The object to be stored.public static java.lang.Object remove(java.lang.Object key)
key - Object used as a key in the mapping.null.public boolean needsSession()
needsSession in class ContextAwareThreadtrue if a new session must be created.private static java.util.Map<java.lang.Object,java.lang.Object> relatedStorage()
RelatedThread
instance), then there will be no storage returned.null if this thread is not part of a group
of related threads.