Interface ThreadContextListener
- All Superinterfaces:
Comparable<ThreadContextListener>
- All Known Implementing Classes:
AuthTokenThreadContextListener,BasicAuthenticationThreadContextListener,PrincipalThreadContextListener,RequestHeaderThreadContextListener,TenantThreadContextListener
Enables listening to lifecycle events of a
ThreadContext. ThreadContextListeners are invoked by a
ThreadContextExecutor.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classThe priorities used to order the default listeners provided by the SDK. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidafterInitialize(ThreadContext threadContext) Invoked after the currentThreadContextis initialized and set.default voidbeforeInitialize(ThreadContext threadContext) Invoked before the currentThreadContextis initialized and set.default intcompareTo(ThreadContextListener other) intReturns the priority that defines the order in which listeners are invoked.
-
Method Details
-
getPriority
int getPriority()Returns the priority that defines the order in which listeners are invoked. Smaller priorities are invoked earlier during context initialization and invoked later (reversed initialization order) during context destruction. Negative number must not be used as they are reserved for internal use.- Returns:
- The priority of this listener implementation.
-
beforeInitialize
Invoked before the currentThreadContextis initialized and set. This method can be used, for example, to inherit properties from the parent context.ThreadContextAccessor.getCurrentContext()returns the oldThreadContextreference.- Parameters:
threadContext- TheThreadContextthat is initialized and will be set.
-
afterInitialize
Invoked after the currentThreadContextis initialized and set.- Parameters:
threadContext- TheThreadContextthat was initialized is now set.
-
compareTo
- Specified by:
compareToin interfaceComparable<ThreadContextListener>
-