package com.stylefeng.guns.modular.system.util.quartz;
|
|
import org.quartz.Scheduler;
|
import org.quartz.impl.StdSchedulerFactory;
|
|
import java.io.InputStream;
|
|
/**
|
* @author zhibing.pu
|
* @Date 2024/3/20 10:56
|
*/
|
public class SchedulerUtil {
|
|
|
/**
|
* 获取调度器
|
* 加载自定义配置文件
|
* @param propertiesStream 配置文件流
|
* @return
|
*/
|
public static Scheduler getScheduler(InputStream propertiesStream) {
|
try {
|
StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();
|
if(null == propertiesStream){
|
stdSchedulerFactory.initialize("quartz.properties");
|
}else{
|
stdSchedulerFactory.initialize(propertiesStream);
|
}
|
return stdSchedulerFactory.getScheduler();
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
return null;
|
}
|
}
|