spring-framework/spring-context
Sam Brannen ff1e5a87b3 Introduce ContextRestartedEvent as a subtype of ContextStartedEvent
Prior to this commit, there was no way to differentiate between an
ApplicationContext "start" and "restart" in terms of events. This was
due to the fact that a ContextStartedEvent was fired for both
AbstractApplicationContext.start() and
AbstractApplicationContext.restart().

To assist developers who may wish to differentiate between "start" and
"restart" events, this commit introduces a new ContextRestartedEvent as
a subtype of ContextStartedEvent. In addition,
AbstractApplicationContext.restart() now publishes a
ContextRestartedEvent instead of a ContextStartedEvent.

By making ContextRestartedEvent a subtype of ContextStartedEvent,
applications can still expect ContextStoppedEvent/ContextStartedEvent
event pairs for consistent lifecycle semantics, and they can optionally
check if the ContextStartedEvent is a ContextRestartedEvent.
Alternatively, applications can explicitly react to a
ContextRestartedEvent.

See gh-35168
See gh-35171
Closes gh-35194
2025-07-12 18:14:05 +02:00
..
src Introduce ContextRestartedEvent as a subtype of ContextStartedEvent 2025-07-12 18:14:05 +02:00
.springBeans
spring-context.gradle Convert Spring @⁠Inject TCK tests from JUnit 3 to JUnit Jupiter 2025-06-28 19:29:49 +02:00