|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2020 the original author or authors.
|
|
|
|
* Copyright 2012-2021 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -21,30 +21,28 @@ import java.util.Properties;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
|
|
|
|
|
|
|
import liquibase.integration.spring.SpringLiquibase;
|
|
|
|
|
|
|
|
import org.quartz.Calendar;
|
|
|
|
import org.quartz.Calendar;
|
|
|
|
import org.quartz.JobDetail;
|
|
|
|
import org.quartz.JobDetail;
|
|
|
|
import org.quartz.Scheduler;
|
|
|
|
import org.quartz.Scheduler;
|
|
|
|
import org.quartz.Trigger;
|
|
|
|
import org.quartz.Trigger;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
import org.springframework.boot.autoconfigure.AbstractDependsOnBeanFactoryPostProcessor;
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
|
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
|
|
|
|
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer;
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
|
|
|
|
import org.springframework.boot.sql.init.dependency.DatabaseInitializationDependencyConfigurer;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
|
|
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
|
|
|
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
|
|
@ -100,6 +98,7 @@ public class QuartzAutoConfiguration {
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@ConditionalOnSingleCandidate(DataSource.class)
|
|
|
|
@ConditionalOnSingleCandidate(DataSource.class)
|
|
|
|
@ConditionalOnProperty(prefix = "spring.quartz", name = "job-store-type", havingValue = "jdbc")
|
|
|
|
@ConditionalOnProperty(prefix = "spring.quartz", name = "job-store-type", havingValue = "jdbc")
|
|
|
|
|
|
|
|
@Import(DatabaseInitializationDependencyConfigurer.class)
|
|
|
|
protected static class JdbcStoreTypeConfiguration {
|
|
|
|
protected static class JdbcStoreTypeConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
@ -141,51 +140,6 @@ public class QuartzAutoConfiguration {
|
|
|
|
return new QuartzDataSourceInitializer(dataSourceToUse, resourceLoader, properties);
|
|
|
|
return new QuartzDataSourceInitializer(dataSourceToUse, resourceLoader, properties);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Additional configuration to ensure that {@link SchedulerFactoryBean} and
|
|
|
|
|
|
|
|
* {@link Scheduler} beans depend on any beans that perform data source
|
|
|
|
|
|
|
|
* initialization.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
|
|
|
static class QuartzSchedulerDependencyConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
static SchedulerDependsOnBeanFactoryPostProcessor quartzSchedulerDataSourceInitializerDependsOnBeanFactoryPostProcessor() {
|
|
|
|
|
|
|
|
return new SchedulerDependsOnBeanFactoryPostProcessor(QuartzDataSourceInitializer.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
@ConditionalOnBean(FlywayMigrationInitializer.class)
|
|
|
|
|
|
|
|
static SchedulerDependsOnBeanFactoryPostProcessor quartzSchedulerFlywayDependsOnBeanFactoryPostProcessor() {
|
|
|
|
|
|
|
|
return new SchedulerDependsOnBeanFactoryPostProcessor(FlywayMigrationInitializer.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
|
|
|
@ConditionalOnClass(SpringLiquibase.class)
|
|
|
|
|
|
|
|
static class LiquibaseQuartzSchedulerDependencyConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
@ConditionalOnBean(SpringLiquibase.class)
|
|
|
|
|
|
|
|
static SchedulerDependsOnBeanFactoryPostProcessor quartzSchedulerLiquibaseDependsOnBeanFactoryPostProcessor() {
|
|
|
|
|
|
|
|
return new SchedulerDependsOnBeanFactoryPostProcessor(SpringLiquibase.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* {@link AbstractDependsOnBeanFactoryPostProcessor} for Quartz {@link Scheduler} and
|
|
|
|
|
|
|
|
* {@link SchedulerFactoryBean}.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static class SchedulerDependsOnBeanFactoryPostProcessor extends AbstractDependsOnBeanFactoryPostProcessor {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SchedulerDependsOnBeanFactoryPostProcessor(Class<?>... dependencyTypes) {
|
|
|
|
|
|
|
|
super(Scheduler.class, SchedulerFactoryBean.class, dependencyTypes);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|