-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
191c479
commit af09689
Showing
6 changed files
with
169 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package sast.evento.config; | ||
|
||
import com.zaxxer.hikari.HikariDataSource; | ||
import org.quartz.impl.StdSchedulerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; | ||
import org.springframework.boot.autoconfigure.quartz.JobStoreType; | ||
import org.springframework.boot.autoconfigure.quartz.QuartzProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||
import org.springframework.scheduling.quartz.SchedulerFactoryBean; | ||
|
||
import java.util.Properties; | ||
|
||
@Configuration | ||
public class QuartzConfig { | ||
|
||
@Value("${spring.quartz.datasource.url}") | ||
private String url; | ||
@Value("${spring.quartz.datasource.username}") | ||
private String username; | ||
@Value("${spring.quartz.datasource.password}") | ||
private String password; | ||
@Value("${spring.quartz.datasource.driver-class-name}") | ||
private String driverClassName; | ||
@Value("${spring.quartz.datasource.name}") | ||
private String name; | ||
|
||
@Bean(name = "schedulerFactoryBean") | ||
public SchedulerFactoryBean schedulerFactoryBean() { | ||
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean(); | ||
schedulerFactoryBean.setDataSource(quartzDataSource()); | ||
schedulerFactoryBean.setTransactionManager(quartzDataSourceTransactionManager()); | ||
schedulerFactoryBean.setAutoStartup(true); | ||
schedulerFactoryBean.setSchedulerName("quartzScheduler"); | ||
schedulerFactoryBean.setSchedulerFactoryClass(StdSchedulerFactory.class); | ||
schedulerFactoryBean.setOverwriteExistingJobs(true); | ||
schedulerFactoryBean.setExposeSchedulerInRepository(true); | ||
return schedulerFactoryBean; | ||
} | ||
|
||
private HikariDataSource quartzDataSource() { | ||
DataSourceProperties dataSourceProperties = new DataSourceProperties(); | ||
dataSourceProperties.setUrl(url); | ||
dataSourceProperties.setUsername(username); | ||
dataSourceProperties.setPassword(password); | ||
dataSourceProperties.setDriverClassName(driverClassName); | ||
dataSourceProperties.setName(name); | ||
return dataSourceProperties.initializeDataSourceBuilder() | ||
.type(HikariDataSource.class) | ||
.build(); | ||
} | ||
|
||
private DataSourceTransactionManager quartzDataSourceTransactionManager() { | ||
return new DataSourceTransactionManager(quartzDataSource()); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.