Can any one please explain me what is the difference between the contextstoppedevent vs contextclosedevent in spring .
I think they are same like ,
ConfigurableApplicationContext sss = (ConfigurableApplicationContext) ((ApplicationContextEvent) event).getApplicationContext();
sss.stop();
sss.close();
May I know where I have to use and when I have to use it ?
First of all, in the vast majority of cases, it's not you who has to explicitly call the stop()
and close()
methods. Usually, they will be called by the framework and you will listen for the associated events.
You can find here a good comparison of events related to Spring lifecycle. Essentially, closing event occurs chronologically after any other stop events. A stopped context can be restarted, but a closed one cannot be reopened.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With