JobExecutor使用简化,在没有配置线程池时,使用默认的线程池
This commit is contained in:
@@ -23,6 +23,7 @@ package fun.asgc.neutrino.core.quartz;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import fun.asgc.neutrino.core.annotation.Autowired;
|
||||
import fun.asgc.neutrino.core.base.CustomThreadFactory;
|
||||
import fun.asgc.neutrino.core.context.ApplicationRunner;
|
||||
import fun.asgc.neutrino.core.context.Environment;
|
||||
import fun.asgc.neutrino.core.quartz.annotation.JobHandler;
|
||||
@@ -37,7 +38,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Job执行器
|
||||
@@ -60,9 +63,13 @@ public class JobExecutor implements ApplicationRunner, IJobExecutor {
|
||||
|
||||
@Override
|
||||
public void run(String[] args) throws JobException {
|
||||
if (!environment.isEnableJob() || null == jobSource || null == threadPoolExecutor) {
|
||||
if (!environment.isEnableJob() || null == jobSource) {
|
||||
return;
|
||||
}
|
||||
if (null == threadPoolExecutor) {
|
||||
threadPoolExecutor = new ThreadPoolExecutor(5, 20, 10L, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(), new CustomThreadFactory("DefaultJobPool"));
|
||||
}
|
||||
|
||||
List<IJobHandler> jobHandlerList = BeanManager.getBeanListBySuperClass(IJobHandler.class);
|
||||
if (!CollectionUtil.isEmpty(jobHandlerList)) {
|
||||
|
||||
-2
@@ -49,8 +49,6 @@ public class JobConfig {
|
||||
public JobExecutor jobExecutor() {
|
||||
JobExecutor executor = new JobExecutor();
|
||||
executor.setJobSource(jobInfoService);
|
||||
executor.setThreadPoolExecutor(new ThreadPoolExecutor(5, 20, 10L, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(), new CustomThreadFactory("JobPool")));
|
||||
executor.setJobCallback(jobLogService);
|
||||
return executor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user