In preparation of #35168, we are introducing a ConfigurableApplicationContext.restart()
method that is to be preferably used after a context-level stop()
call, on reactivation of a context. This effectively restores the lifecycle state after refresh()
, auto-starting all applicable components (SmartLifecycle.isAutoStartup()
), rather than the hard-start of any lifecycle component in the context that a context-level start()
does.
We have a variation of this for CRaC already but that's slightly different (tracking which components were actually started before) and not publicly callable. As a bonus, the new restart()
method also auto-stops all running components before if necessary, so can also be used as a shortcut for a full stop-restart cycle.