You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.1 KiB

2 months ago
package com.archive.framework.manager;
import com.archive.framework.manager.AsyncManager;
import com.archive.framework.shiro.web.session.SpringSessionValidationScheduler;
import javax.annotation.PreDestroy;
import net.sf.ehcache.CacheManager;
import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ShutdownManager
{
private static final Logger logger = LoggerFactory.getLogger("sys-user");
@Autowired(required = false)
private SpringSessionValidationScheduler springSessionValidationScheduler;
@Autowired(required = false)
private EhCacheManager ehCacheManager;
@PreDestroy
public void destroy() {
shutdownSpringSessionValidationScheduler();
shutdownAsyncManager();
shutdownEhCacheManager();
}
private void shutdownSpringSessionValidationScheduler() {
if (this.springSessionValidationScheduler != null && this.springSessionValidationScheduler.isEnabled()) {
try {
logger.info("====关闭会话验证任务====");
this.springSessionValidationScheduler.disableSessionValidation();
}
catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
private void shutdownAsyncManager() {
try {
logger.info("====关闭后台任务任务线程池====");
AsyncManager.me().shutdown();
}
catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
private void shutdownEhCacheManager() {
try {
logger.info("====关闭缓存====");
if (this.ehCacheManager != null)
{
CacheManager cacheManager = this.ehCacheManager.getCacheManager();
cacheManager.shutdown();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\manager\ShutdownManager.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/