SubjectCallable associates a
Subject with a target/delegate
Callable to ensure proper
Subject thread-state management when the
This ensures that any calls to
SecurityUtils.org.apache.shiro.SecurityUtils#getSubject()during the target
Callable's execution still work correctly even if the
Callable executes on a
different thread than the one that created it. This allows
Subject access during asynchronous operations.
When instances of this class execute (typically via a
the following occurs:
- The specified Subject any of its associated thread state is first bound to the thread that executes the
- The delegate/target
- The previous thread state that might have existed before the
Subject was bound is fully restored
This behavior ensures that the thread that executes this
Callable, which is often a different thread than
the one that created the instance, retains a
Subject to support
SecurityUtils.getSubject()invocations. It also guarantees that the running thread remains 'clean' in any thread-pooled environments.
This is typically considered a support class and is not often directly referenced. Most people prefer to use
Subject.Subject#associateWith(Callable) method, which will automatically return
an instance of this class.
An even more convenient alternative is to use a
transparently uses instances of this class.