public class PrincipalThreadContextListener extends Object implements ThreadContextListener
ThreadContextListener
that ensures the correct initialization of Principal
s when
working with non-container managed threads on all supported Cloud platforms.ThreadContextListener.DefaultPriorities
Modifier and Type | Field and Description |
---|---|
static String |
PROPERTY_PRINCIPAL
The ThreadContext key.
|
Constructor and Description |
---|
PrincipalThreadContextListener()
Default constructor.
|
PrincipalThreadContextListener(Principal principal)
Constructor for providing a
Principal to be returned by this listener. |
Modifier and Type | Method and Description |
---|---|
void |
afterInitialize(ThreadContext threadContext,
ThreadContext parentThreadContext)
Invoked after the current
ThreadContext is initialized and set. |
void |
beforeDestroy(ThreadContext threadContext,
ThreadContext parentThreadContext)
Invoked before the current
ThreadContext is destroyed and reset. |
int |
getPriority()
Returns the priority that defines the order in which listeners are invoked.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
afterDestroy, beforeInitialize, compareTo
public static final String PROPERTY_PRINCIPAL
public PrincipalThreadContextListener()
public int getPriority()
getPriority
in interface ThreadContextListener
public void afterInitialize(@Nonnull ThreadContext threadContext, @Nullable ThreadContext parentThreadContext)
ThreadContext
is initialized and set.afterInitialize
in interface ThreadContextListener
threadContext
- The ThreadContext
that was initialized is now set.parentThreadContext
- The parent ThreadContext
, or null
if there is no parent ThreadContext
.public void beforeDestroy(@Nonnull ThreadContext threadContext, @Nullable ThreadContext parentThreadContext)
ThreadContext
is destroyed and reset.beforeDestroy
in interface ThreadContextListener
threadContext
- The ThreadContext
that is destroyed and will be removed.parentThreadContext
- The parent ThreadContext
, or null
if there is no parent ThreadContext
.Copyright © 2021 SAP SE. All rights reserved.