Interface ReadinessStateAware

All Known Implementing Classes:
AbstractMcpRestServlet, ExampleMcpServer, McpRestServlet, McpRestServlet, SecuredExampleMcpServer

public interface ReadinessStateAware
Implemented by servlets that want to be told the embedded server's per-service ReadinessState, so they can react when shutdown begins (see ReadinessState.onOutOfService(Object, Runnable)).

The embedded-server lifecycle component (e.g. JettyServerComponent, TomcatServerComponent) calls acceptReadinessState(ReadinessState) on each auto-discovered servlet that implements this interface, before the server starts. A typical use is closing long-lived streaming connections at the start of a graceful shutdown so the drain does not have to wait out its stop timeout for them.

Example:

@Rest(path="/events") public class EventsResource extends BasicRestServlet implements ReadinessStateAware { @Override /* ReadinessStateAware */ public void acceptReadinessState(ReadinessState state) { // Stable key: a re-publish on server restart replaces this callback instead of adding another. state.onOutOfService("my-streams", this::closeStreams); } private void closeStreams() { // End long-lived SSE/streaming responses so the graceful drain can finish. } }

Since:
10.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Receives the lifecycle-owned readiness state.
  • Method Details

    • acceptReadinessState

      Receives the lifecycle-owned readiness state.

      May be called more than once (once per server start); implementations should register callbacks under a stable key so repeated calls replace rather than accumulate.

      Parameters:
      state - The per-service readiness state. Never null.