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
|
* @Date: 2018/12/28
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ApplicationShutdownBean {
|
public class ApplicationShutdownBean
|
||||||
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger("sys-user");
|
private static final Logger logger = LoggerFactory.getLogger("sys-user");
|
||||||
|
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private SpringSessionValidationScheduler springSessionValidationScheduler;
|
private SpringSessionValidationScheduler springSessionValidationScheduler;
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void destroy(){
|
public void destroy()
|
||||||
|
{
|
||||||
shutdownSpringSessionValidationScheduler();
|
shutdownSpringSessionValidationScheduler();
|
||||||
shutdownAsyncManager();
|
shutdownAsyncManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shutdownSpringSessionValidationScheduler(){
|
private void shutdownSpringSessionValidationScheduler()
|
||||||
|
{
|
||||||
if(springSessionValidationScheduler != null && springSessionValidationScheduler.isEnabled())
|
if(springSessionValidationScheduler != null && springSessionValidationScheduler.isEnabled())
|
||||||
try {
|
{
|
||||||
logger.info("关闭会话验证任务");
|
try
|
||||||
springSessionValidationScheduler.disableSessionValidation();
|
{
|
||||||
} catch (Exception e) {
|
logger.info("关闭会话验证任务");
|
||||||
logger.error(e.getMessage(),e);
|
springSessionValidationScheduler.disableSessionValidation();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void shutdownAsyncManager(){
|
private void shutdownAsyncManager()
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
logger.info("关闭后台任务线程池");
|
logger.info("关闭后台任务线程池");
|
||||||
AsyncManager.me().shutdown(10, TimeUnit.SECONDS);
|
AsyncManager.me().shutdown(10, TimeUnit.SECONDS);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
logger.error(e.getMessage(),e);
|
logger.error(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,11 +134,15 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu
|
||||||
log.debug("Stopping Spring Scheduler session validation job...");
|
log.debug("Stopping Spring Scheduler session validation job...");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.enabled){
|
if(this.enabled)
|
||||||
|
{
|
||||||
executorService.shutdown();
|
executorService.shutdown();
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
executorService.awaitTermination(10,TimeUnit.SECONDS);
|
executorService.awaitTermination(10,TimeUnit.SECONDS);
|
||||||
} catch (InterruptedException e) {
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
log.error(e.getMessage(),e);
|
log.error(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue