cn.jiangzeyin.system.cache.SystemJob Maven / Gradle / Ivy
package cn.jiangzeyin.system.cache;
import cn.jiangzeyin.database.run.read.Select;
import cn.jiangzeyin.entity.defaults.QuartzInfo;
import cn.jiangzeyin.system.log.SystemLog;
import cn.jiangzeyin.system.pool.SystemExecutorService;
import cn.jiangzeyin.util.system.interfaces.UtilSystemExecutorService;
import cn.jiangzeyin.util.system.util.UtilSystemCache;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author jiangzeyin
* Created by jiangzeyin on 2017/2/13.
*/
public class SystemJob implements UtilSystemExecutorService {
private static final SystemJob SYSTEM_JOB = new SystemJob();
/**
* 加载调度信息
*
* @author jiangzeyin
*/
public static void init() {
UtilSystemCache.init(SYSTEM_JOB);
long s = System.currentTimeMillis();
try {
Class> jobManager = Class.forName("com.yoke.job.SystemJobManager");
Method method = jobManager.getDeclaredMethod("init", List.class);
method.invoke(null, getQuartzList());
} catch (ClassNotFoundException e) {
return;
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
SystemLog.ERROR().error("初始化调度异常", e);
}
SystemLog.LOG().info("初始化调度信息完成:" + (System.currentTimeMillis() - s));
}
private static List getQuartzList() {
if (SiteCache.currentSite == null) {
SystemLog.LOG().info("没有找到当前站点,无法加载相关调度");
return null;
}
SystemLog.LOG().info("初始化调度信息");
Select util = new Select() {
};
util.setWhere("isDelete=0 and status=0 and (siteId=0 or FIND_IN_SET(" + SiteCache.currentSite.getId() + ",siteId))");
util.setRemove("siteId");
return util.run();
}
@Override
public ThreadPoolExecutor newCachedThreadPool(Class cls) {
return SystemExecutorService.newCachedThreadPool(cls);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy