Interface ThreadContextListener

All Superinterfaces:
Comparable<ThreadContextListener>
All Known Implementing Classes:
AuthTokenThreadContextListener, BasicAuthenticationThreadContextListener, PrincipalThreadContextListener, RequestHeaderThreadContextListener, TenantThreadContextListener

public interface ThreadContextListener extends Comparable<ThreadContextListener>
Enables listening to lifecycle events of a ThreadContext. ThreadContextListeners are invoked by a ThreadContextExecutor.
  • 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

      default void beforeInitialize(@Nonnull ThreadContext threadContext)
      Invoked before the current ThreadContext is initialized and set. This method can be used, for example, to inherit properties from the parent context.

      ThreadContextAccessor.getCurrentContext() returns the old ThreadContext reference.

      Parameters:
      threadContext - The ThreadContext that is initialized and will be set.
    • afterInitialize

      default void afterInitialize(@Nonnull ThreadContext threadContext)
      Invoked after the current ThreadContext is initialized and set.
      Parameters:
      threadContext - The ThreadContext that was initialized is now set.
    • compareTo

      default int compareTo(@Nonnull ThreadContextListener other)
      Specified by:
      compareTo in interface Comparable<ThreadContextListener>