|
|
|
@ -50,11 +50,13 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
import org.springframework.scheduling.quartz.LocalDataSourceJobStore;
|
|
|
|
|
import org.springframework.scheduling.quartz.LocalTaskExecutorThreadPool;
|
|
|
|
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
@ -174,7 +176,7 @@ public class QuartzAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void withCustomizer() throws Exception {
|
|
|
|
|
load(QuartzCustomConfig.class);
|
|
|
|
|
load(QuartzCustomConfiguration.class);
|
|
|
|
|
assertThat(this.context.getBeansOfType(Scheduler.class)).hasSize(1);
|
|
|
|
|
Scheduler scheduler = this.context.getBean(Scheduler.class);
|
|
|
|
|
assertThat(scheduler.getSchedulerName()).isEqualTo("fooScheduler");
|
|
|
|
@ -199,8 +201,14 @@ public class QuartzAutoConfigurationTests {
|
|
|
|
|
this.context = ctx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Import(ComponentThatUsesScheduler.class)
|
|
|
|
|
@Configuration
|
|
|
|
|
protected static class QuartzJobsConfiguration {
|
|
|
|
|
protected static class BaseQuartzConfiguration {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
protected static class QuartzJobsConfiguration extends BaseQuartzConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public JobDetail fooJob() {
|
|
|
|
@ -217,7 +225,7 @@ public class QuartzAutoConfigurationTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
protected static class QuartzFullConfiguration {
|
|
|
|
|
protected static class QuartzFullConfiguration extends BaseQuartzConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public JobDetail fooJob() {
|
|
|
|
@ -237,7 +245,7 @@ public class QuartzAutoConfigurationTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
protected static class QuartzCalendarsConfiguration {
|
|
|
|
|
protected static class QuartzCalendarsConfiguration extends BaseQuartzConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public Calendar weekly() {
|
|
|
|
@ -252,7 +260,7 @@ public class QuartzAutoConfigurationTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
protected static class QuartzExecutorConfiguration {
|
|
|
|
|
protected static class QuartzExecutorConfiguration extends BaseQuartzConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public Executor executor() {
|
|
|
|
@ -262,7 +270,7 @@ public class QuartzAutoConfigurationTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
protected static class QuartzCustomConfig {
|
|
|
|
|
protected static class QuartzCustomConfiguration extends BaseQuartzConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public SchedulerFactoryBeanCustomizer customizer() {
|
|
|
|
@ -272,6 +280,17 @@ public class QuartzAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class ComponentThatUsesScheduler {
|
|
|
|
|
|
|
|
|
|
private Scheduler scheduler;
|
|
|
|
|
|
|
|
|
|
public ComponentThatUsesScheduler(Scheduler scheduler) {
|
|
|
|
|
Assert.notNull(scheduler, "Scheduler must not be null");
|
|
|
|
|
this.scheduler = scheduler;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class FooJob extends QuartzJobBean {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|