public class ThreadLocalThreadContextFacade extends Object implements ThreadContextFacade
ThreadContextFacade
that internally uses ThreadLocal
to provide access to the
respective ThreadContext
.
Important: This implementation should only be used when relying on container-managed threads only. In case you use a framework that manages threads, you have to rely on an implementation that is adjusted to your framework.
Constructor and Description |
---|
ThreadLocalThreadContextFacade() |
Modifier and Type | Method and Description |
---|---|
ThreadContext |
getCurrentContextOrNull()
Returns an instance
ThreadContext or null. |
void |
removeCurrentContext()
Removes the current
ThreadContext . |
void |
setCurrentContext(ThreadContext threadContext)
Sets the current
ThreadContext . |
io.vavr.control.Try<ThreadContext> |
tryGetCurrentContext()
Returns a
Try of the current ThreadContext . |
@Nonnull public io.vavr.control.Try<ThreadContext> tryGetCurrentContext()
ThreadContextFacade
Try
of the current ThreadContext
.tryGetCurrentContext
in interface ThreadContextFacade
Try
of the current ThreadContext
.public void setCurrentContext(@Nonnull ThreadContext threadContext)
ThreadContextFacade
ThreadContext
.setCurrentContext
in interface ThreadContextFacade
threadContext
- The ThreadContext
to set.public void removeCurrentContext()
ThreadContextFacade
ThreadContext
.removeCurrentContext
in interface ThreadContextFacade
@Nullable public ThreadContext getCurrentContextOrNull()
ThreadContextFacade
ThreadContext
or null.getCurrentContextOrNull
in interface ThreadContextFacade
ThreadContext
or null.Copyright © 2021 SAP SE. All rights reserved.