Skip to content

Commit edd9429

Browse files
committed
优化配置
1 parent a3bee0b commit edd9429

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

hsweb-web-service/hsweb-web-service-simple/src/main/java/org/hsweb/web/service/impl/SchedulerAutoConfiguration.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package org.hsweb.web.service.impl;
1818

1919
import org.hsweb.web.service.impl.quartz.SimpleJobFactory;
20+
import org.quartz.Calendar;
21+
import org.quartz.SchedulerListener;
2022
import org.quartz.core.QuartzScheduler;
2123
import org.quartz.impl.StdSchedulerFactory;
2224
import org.quartz.spi.JobFactory;
@@ -33,6 +35,8 @@
3335
import org.springframework.transaction.PlatformTransactionManager;
3436

3537
import javax.sql.DataSource;
38+
import java.util.List;
39+
import java.util.Map;
3640

3741
@Configuration
3842
@ConditionalOnClass(QuartzScheduler.class)
@@ -51,6 +55,12 @@ public class SchedulerAutoConfiguration {
5155
@Autowired
5256
private PlatformTransactionManager platformTransactionManager;
5357

58+
@Autowired(required = false)
59+
private Map<String, Calendar> calendarMap;
60+
61+
@Autowired(required = false)
62+
private SchedulerListener[] schedulerListeners;
63+
5464
@Bean
5565
public JobFactory jobFactory() {
5666
SimpleJobFactory jobFactory = new SimpleJobFactory();
@@ -71,6 +81,9 @@ public SchedulerFactoryBean schedulerFactory(JobFactory jobFactory) {
7181
schedulerFactoryBean.setJobFactory(jobFactory);
7282
schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(schedulerProperties.isWaitOnShutdown());
7383
schedulerFactoryBean.setQuartzProperties(schedulerProperties.getProperties());
84+
schedulerFactoryBean.setStartupDelay(schedulerProperties.getStartupDelay());
85+
schedulerFactoryBean.setCalendars(calendarMap);
86+
schedulerFactoryBean.setSchedulerListeners(schedulerListeners);
7487
return schedulerFactoryBean;
7588
}
7689
}

hsweb-web-service/hsweb-web-service-simple/src/main/java/org/hsweb/web/service/impl/SchedulerProperties.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class SchedulerProperties {
3030

3131
private boolean waitOnShutdown = true;
3232

33+
private int startupDelay = 0;
3334
private Properties properties;
3435

3536
public boolean isAutoStartup() {
@@ -71,4 +72,12 @@ public Properties getProperties() {
7172
public void setProperties(Properties properties) {
7273
this.properties = properties;
7374
}
75+
76+
public int getStartupDelay() {
77+
return startupDelay;
78+
}
79+
80+
public void setStartupDelay(int startupDelay) {
81+
this.startupDelay = startupDelay;
82+
}
7483
}

0 commit comments

Comments
 (0)