mirror of https://gitee.com/y_project/RuoYi.git
代码风格和项目保持一致
parent
fc834b35cb
commit
0e240cb244
|
@ -17,32 +17,44 @@ import java.util.concurrent.TimeUnit;
|
|||
* @Date: 2018/12/28
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationShutdownBean {
|
||||
public class ApplicationShutdownBean
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger("sys-user");
|
||||
|
||||
@Autowired(required = false)
|
||||
private SpringSessionValidationScheduler springSessionValidationScheduler;
|
||||
|
||||
@PreDestroy
|
||||
public void destroy(){
|
||||
public void destroy()
|
||||
{
|
||||
shutdownSpringSessionValidationScheduler();
|
||||
shutdownAsyncManager();
|
||||
}
|
||||
|
||||
private void shutdownSpringSessionValidationScheduler(){
|
||||
private void shutdownSpringSessionValidationScheduler()
|
||||
{
|
||||
if(springSessionValidationScheduler != null && springSessionValidationScheduler.isEnabled())
|
||||
try {
|
||||
logger.info("关闭会话验证任务");
|
||||
springSessionValidationScheduler.disableSessionValidation();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.info("关闭会话验证任务");
|
||||
springSessionValidationScheduler.disableSessionValidation();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void shutdownAsyncManager(){
|
||||
try {
|
||||
private void shutdownAsyncManager()
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.info("关闭后台任务线程池");
|
||||
AsyncManager.me().shutdown(10, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,11 +134,15 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu
|
|||
log.debug("Stopping Spring Scheduler session validation job...");
|
||||
}
|
||||
|
||||
if(this.enabled){
|
||||
if(this.enabled)
|
||||
{
|
||||
executorService.shutdown();
|
||||
try {
|
||||
try
|
||||
{
|
||||
executorService.awaitTermination(10,TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue