Class WebServerInitializedEvent

java.lang.Object
java.util.EventObject
org.springframework.context.ApplicationEvent
org.springframework.boot.web.context.WebServerInitializedEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ReactiveWebServerInitializedEvent, ServletWebServerInitializedEvent

public abstract class WebServerInitializedEvent extends org.springframework.context.ApplicationEvent
Event to be published when the WebServer is ready. Useful for obtaining the local port of a running server.
Since:
2.0.0
See Also:
  • Constructor Details

    • WebServerInitializedEvent

      protected WebServerInitializedEvent(WebServer webServer)
  • Method Details

    • getWebServer

      public WebServer getWebServer()
      Access the WebServer.
      Returns:
      the embedded web server
    • getApplicationContext

      public abstract WebServerApplicationContext getApplicationContext()
      Access the application context that the server was created in. Sometimes it is prudent to check that this matches expectations (like being equal to the current context) before acting on the server itself.
      Returns:
      the applicationContext that the server was created from
    • getSource

      public WebServer getSource()
      Access the source of the event (an WebServer).
      Overrides:
      getSource in class EventObject
      Returns:
      the embedded web server