How can we shutdown or stop a Spring application by itself programmatically?
We have currently using ConfigurableApplicationContext#close(), and yes, it does close the application but not shutdown or stop the application.
From the tomcat manager, the application status still is running, so the client still can connect to the web app and get the front-end resource. Besides, all servlets seems still working and can accept the request.
The below code shows how we do currently.
@Autowired
private ConfigurableApplicationContext configurableApplicationContext;
@Scheduled(cron="0 0/5 * * * ?")
private void validateLicenseExpired()
{
try
{
LicenseUtils.isLicensingPeriodValid();
} catch (LicenseInvalidException lie) {
logger.error("\t The licensing is expired", lie);
configurableApplicationContext.close();
}
}
Any help is appreciated.