zhibing.pu
2024-04-19 2e366b939271b6ea338641f8a72d1bcd2182dbe7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
    }
}