Search in sources :

Example 16 with SchedulerFactoryBean

use of org.springframework.scheduling.quartz.SchedulerFactoryBean in project spring-cloud-framework by zhuwj921.

the class SchedulerConfiguration method schedulerFactoryBean.

@Bean(name = "SchedulerFactory")
public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
    // 获取配置属性
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
    // 在quartz.properties中的属性被读取并注入后再初始化对象
    propertiesFactoryBean.afterPropertiesSet();
    // 创建SchedulerFactoryBean
    SchedulerFactoryBean factory = new SchedulerFactoryBean();
    factory.setQuartzProperties(propertiesFactoryBean.getObject());
    // 使用数据源
    factory.setDataSource(dataSource);
    factory.setJobFactory(jobFactory);
    return factory;
}
Also used : PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource) PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean)

Example 17 with SchedulerFactoryBean

use of org.springframework.scheduling.quartz.SchedulerFactoryBean in project tutorials by eugenp.

the class SpringQrtzScheduler method scheduler.

@Bean
public SchedulerFactoryBean scheduler(Trigger trigger, JobDetail job) {
    SchedulerFactoryBean schedulerFactory = new SchedulerFactoryBean();
    schedulerFactory.setConfigLocation(new ClassPathResource("quartz.properties"));
    logger.debug("Setting the Scheduler up");
    schedulerFactory.setJobFactory(springBeanJobFactory());
    schedulerFactory.setJobDetails(job);
    schedulerFactory.setTriggers(trigger);
    return schedulerFactory;
}
Also used : SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource) JobDetailFactoryBean(org.springframework.scheduling.quartz.JobDetailFactoryBean) SimpleTriggerFactoryBean(org.springframework.scheduling.quartz.SimpleTriggerFactoryBean) Bean(org.springframework.context.annotation.Bean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean)

Example 18 with SchedulerFactoryBean

use of org.springframework.scheduling.quartz.SchedulerFactoryBean in project openmeetings by apache.

the class Admin method getApplicationContext.

private WebApplicationContext getApplicationContext() {
    if (context == null) {
        // preserve step
        String _step = step;
        step = "Shutdown schedulers";
        Long lngId = (long) cfg.getDefaultLangId();
        context = ApplicationHelper.getApplicationContext(lngId);
        SchedulerFactoryBean sfb = context.getBean(SchedulerFactoryBean.class);
        try {
            sfb.getScheduler().shutdown(false);
            // restore
            step = _step;
        } catch (Exception e) {
            handleError(e);
        }
    }
    return context;
}
Also used : SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) OmException(org.apache.openmeetings.util.OmException) ParseException(org.apache.commons.cli.ParseException) IOException(java.io.IOException)

Example 19 with SchedulerFactoryBean

use of org.springframework.scheduling.quartz.SchedulerFactoryBean in project erp-catering by liuyandong33.

the class QuartzSchedulerConfiguration method schedulerFactoryBean.

@Bean
public SchedulerFactoryBean schedulerFactoryBean(JobFactory jobFactory) {
    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
    schedulerFactoryBean.setJobFactory(jobFactory);
    return schedulerFactoryBean;
}
Also used : SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) Bean(org.springframework.context.annotation.Bean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean)

Example 20 with SchedulerFactoryBean

use of org.springframework.scheduling.quartz.SchedulerFactoryBean in project cloudbreak by hortonworks.

the class AppConfig method schedulerFactoryBean.

@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
    SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
    scheduler.setTaskExecutor(getAsyncExecutor());
    scheduler.setAutoStartup(true);
    scheduler.setJobFactory(new SimpleJobFactory());
    return scheduler;
}
Also used : SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) SimpleJobFactory(org.quartz.simpl.SimpleJobFactory) ThreadPoolExecutorFactoryBean(org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean) Bean(org.springframework.context.annotation.Bean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean)

Aggregations

SchedulerFactoryBean (org.springframework.scheduling.quartz.SchedulerFactoryBean)28 Bean (org.springframework.context.annotation.Bean)20 PropertiesFactoryBean (org.springframework.beans.factory.config.PropertiesFactoryBean)7 ClassPathResource (org.springframework.core.io.ClassPathResource)6 IOException (java.io.IOException)5 Properties (java.util.Properties)5 Test (org.junit.jupiter.api.Test)3 JobDetail (org.quartz.JobDetail)3 Trigger (org.quartz.Trigger)3 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)2 Map (java.util.Map)2 PostConstruct (javax.annotation.PostConstruct)2 SchedulerException (org.quartz.SchedulerException)2 ServerSettings (com.radensolutions.reporting.service.ServerSettings)1 Job (com.weicoder.frame.quartz.Job)1 SchedulerManager (eu.bcvsolutions.idm.core.scheduler.api.service.SchedulerManager)1 DefaultSchedulerManager (eu.bcvsolutions.idm.core.scheduler.service.impl.DefaultSchedulerManager)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1