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 after the application context is refreshed and theWebServer
is ready. Useful for obtaining the local port of a running server.- Since:
- 2.0.0
- See Also:
- Serialized Form
Field Summary
Fields inherited from class java.util.EventObject
source
Constructor Summary
Constructors Modifier Constructor Description protected
WebServerInitializedEvent(WebServer webServer)
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract WebServerApplicationContext
getApplicationContext()
Access the application context that the server was created in.WebServer
getSource()
Access the source of the event (anWebServer
).WebServer
getWebServer()
Access theWebServer
.Methods inherited from class java.util.EventObject
toString
Constructor Detail
WebServerInitializedEvent
protected WebServerInitializedEvent(WebServer webServer)
Method Detail
getWebServer
public WebServer getWebServer()
Access theWebServer
.- 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 (anWebServer
).- Overrides:
getSource
in classEventObject
- Returns:
- the embedded web server