mirror of
https://github.com/fabioformosa/quartz-manager.git
synced 2026-05-14 22:00:30 +09:00
#67 put a qualifier name to the quartz-scheduler instance
This commit is contained in:
@@ -6,7 +6,7 @@ import org.springframework.context.annotation.Bean;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnProperty(name = "quartz.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(name = "quartz-manager.quartz.enabled", matchIfMissing = true)
|
||||||
public class QuartzDefaultPropertiesConfig {
|
public class QuartzDefaultPropertiesConfig {
|
||||||
|
|
||||||
protected static final String QUARTZ_MANAGER_SCHEDULER_DEFAULT_NAME = "quartz-manager-scheduler";
|
protected static final String QUARTZ_MANAGER_SCHEDULER_DEFAULT_NAME = "quartz-manager-scheduler";
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import it.fabioformosa.quartzmanager.api.common.properties.QuartzModulePropertie
|
|||||||
import it.fabioformosa.quartzmanager.api.scheduler.AutowiringSpringBeanJobFactory;
|
import it.fabioformosa.quartzmanager.api.scheduler.AutowiringSpringBeanJobFactory;
|
||||||
import org.quartz.spi.JobFactory;
|
import org.quartz.spi.JobFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnResource;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnResource;
|
||||||
@@ -18,7 +19,7 @@ import java.util.List;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnProperty(name = "quartz.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(name = "quartz-manager.quartz.enabled", matchIfMissing = true)
|
||||||
public class SchedulerConfig {
|
public class SchedulerConfig {
|
||||||
|
|
||||||
private final List<QuartzModuleProperties> quartzModuleProperties;
|
private final List<QuartzModuleProperties> quartzModuleProperties;
|
||||||
@@ -28,7 +29,7 @@ public class SchedulerConfig {
|
|||||||
this.quartzModuleProperties = quartzModuleProperties;
|
this.quartzModuleProperties = quartzModuleProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean(name = "quartzJobFactory")
|
||||||
public JobFactory jobFactory(ApplicationContext applicationContext) {
|
public JobFactory jobFactory(ApplicationContext applicationContext) {
|
||||||
AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
|
AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
|
||||||
jobFactory.setApplicationContext(applicationContext);
|
jobFactory.setApplicationContext(applicationContext);
|
||||||
@@ -44,8 +45,8 @@ public class SchedulerConfig {
|
|||||||
return propertiesFactoryBean.getObject();
|
return propertiesFactoryBean.getObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "scheduler")
|
@Bean(name = "quartzScheduler")
|
||||||
public SchedulerFactoryBean schedulerFactoryBean(JobFactory jobFactory, Properties quartzProperties) throws IOException {
|
public SchedulerFactoryBean schedulerFactoryBean(@Qualifier("quartzJobFactory") JobFactory jobFactory, Properties quartzProperties) throws IOException {
|
||||||
SchedulerFactoryBean factory = new SchedulerFactoryBean();
|
SchedulerFactoryBean factory = new SchedulerFactoryBean();
|
||||||
factory.setJobFactory(jobFactory);
|
factory.setJobFactory(jobFactory);
|
||||||
Properties mergedProperties = new Properties();
|
Properties mergedProperties = new Properties();
|
||||||
|
|||||||
@@ -7,11 +7,13 @@ import org.quartz.JobDetail;
|
|||||||
import org.quartz.JobKey;
|
import org.quartz.JobKey;
|
||||||
import org.quartz.Scheduler;
|
import org.quartz.Scheduler;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class JobKeyToJobDetailDTO extends AbstractBaseConverterToDTO<JobKey, JobDetailDTO> {
|
public class JobKeyToJobDetailDTO extends AbstractBaseConverterToDTO<JobKey, JobDetailDTO> {
|
||||||
|
|
||||||
|
@Qualifier("quartzScheduler")
|
||||||
@Autowired
|
@Autowired
|
||||||
private Scheduler scheduler;
|
private Scheduler scheduler;
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ package it.fabioformosa.quartzmanager.api.services;
|
|||||||
import it.fabioformosa.quartzmanager.api.dto.SchedulerDTO;
|
import it.fabioformosa.quartzmanager.api.dto.SchedulerDTO;
|
||||||
import org.quartz.Scheduler;
|
import org.quartz.Scheduler;
|
||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SchedulerService extends AbstractSchedulerService{
|
public class SchedulerService extends AbstractSchedulerService{
|
||||||
|
|
||||||
public SchedulerService(Scheduler scheduler, ConversionService conversionService) {
|
public SchedulerService(@Qualifier("quartzScheduler") Scheduler scheduler, ConversionService conversionService) {
|
||||||
super(scheduler, conversionService);
|
super(scheduler, conversionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ import it.fabioformosa.quartzmanager.api.dto.TriggerDTO;
|
|||||||
import it.fabioformosa.quartzmanager.api.dto.SimpleTriggerDTO;
|
import it.fabioformosa.quartzmanager.api.dto.SimpleTriggerDTO;
|
||||||
import it.fabioformosa.quartzmanager.api.exceptions.TriggerNotFoundException;
|
import it.fabioformosa.quartzmanager.api.exceptions.TriggerNotFoundException;
|
||||||
import org.quartz.*;
|
import org.quartz.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SimpleTriggerService extends AbstractSchedulerService {
|
public class SimpleTriggerService extends AbstractSchedulerService {
|
||||||
|
|
||||||
public SimpleTriggerService(Scheduler scheduler, ConversionService conversionService) {
|
public SimpleTriggerService(@Qualifier("quartzScheduler") Scheduler scheduler, ConversionService conversionService) {
|
||||||
super(scheduler, conversionService);
|
super(scheduler, conversionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.quartz.Scheduler;
|
|||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
import org.quartz.TriggerKey;
|
import org.quartz.TriggerKey;
|
||||||
import org.quartz.impl.matchers.GroupMatcher;
|
import org.quartz.impl.matchers.GroupMatcher;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.core.convert.TypeDescriptor;
|
import org.springframework.core.convert.TypeDescriptor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -18,7 +19,7 @@ public class TriggerService {
|
|||||||
private Scheduler scheduler;
|
private Scheduler scheduler;
|
||||||
private ConversionService conversionService;
|
private ConversionService conversionService;
|
||||||
|
|
||||||
public TriggerService(Scheduler scheduler, ConversionService conversionService) {
|
public TriggerService(@Qualifier("quartzScheduler") Scheduler scheduler, ConversionService conversionService) {
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
this.conversionService = conversionService;
|
this.conversionService = conversionService;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user