Skip to content

Introduce ContextRestartedEvent as a subtype of ContextStartedEvent #35194

@sbrannen

Description

@sbrannen

While working on #35168, I noticed that there is currently no way to differentiate between an ApplicationContext start and restart in terms of events.

This is due to the fact that a ContextStartedEvent is fired for both AbstractApplicationContext.start() and AbstractApplicationContext.restart().

Thus, to assist developers who may wish to differentiate between start and restart events, we should introduce a new ContextRestartedEvent as a subtype of 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.

Related Issues

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions