class ContextAwareThread
extends java.lang.Thread
This class is intentionally made package-private because it MUST not be accessible to external code.
Modifier and Type | Field and Description |
---|---|
private java.lang.Runnable |
core
The core logic that will be executed.
|
protected static SecurityManager |
sm
Security Manager instance (it is singleton so it is safe as a static).
|
protected SecurityContextStack |
stack
The security context of the instantiating thread.
|
Constructor and Description |
---|
ContextAwareThread(java.lang.Runnable core,
SecurityContextStack stack)
Constructor which allows the core logic to be specified.
|
Modifier and Type | Method and Description |
---|---|
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.
|
void |
run()
This method will be invoked when the thread is started, it sets up the initial security
context as obtained from the instantiating thread, then it will execute the core logic
specified by the caller and drop the security context after that logic is done.
|
activeCount, 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, yield
protected static final SecurityManager sm
private final java.lang.Runnable core
protected final SecurityContextStack stack
public ContextAwareThread(java.lang.Runnable core, SecurityContextStack stack) throws java.lang.NullPointerException
core
- The logic to execute when the thread is started. Must not be null
.stack
- The security context to set for the duration of the core logic execution.java.lang.NullPointerException
- If the instantiating thread has no security context or if any parameter is
null
.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public boolean needsSession()
true
if a new session must be created.