当前位置: 首页>>代码示例>>Java>>正文


Java SchedulerFactoryBean类代码示例

本文整理汇总了Java中org.springframework.scheduling.quartz.SchedulerFactoryBean的典型用法代码示例。如果您正苦于以下问题:Java SchedulerFactoryBean类的具体用法?Java SchedulerFactoryBean怎么用?Java SchedulerFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SchedulerFactoryBean类属于org.springframework.scheduling.quartz包,在下文中一共展示了SchedulerFactoryBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: schedulerFactory

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactory(JobFactory jobFactory) {
    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
    schedulerFactoryBean.setApplicationContext(applicationContext);
    schedulerFactoryBean.setAutoStartup(schedulerProperties.isAutoStartup());
    schedulerFactoryBean.setDataSource(dataSource);
    schedulerFactoryBean.setTransactionManager(platformTransactionManager);
    schedulerFactoryBean.setOverwriteExistingJobs(schedulerProperties.isOverwriteExistingJobs());
    schedulerFactoryBean.setSchedulerFactoryClass(StdSchedulerFactory.class);
    schedulerFactoryBean.setBeanName(schedulerProperties.getBeanName());
    schedulerFactoryBean.setJobFactory(jobFactory);
    schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(schedulerProperties.isWaitOnShutdown());
    schedulerFactoryBean.setQuartzProperties(schedulerProperties.getProperties());
    schedulerFactoryBean.setStartupDelay(schedulerProperties.getStartupDelay());
    schedulerFactoryBean.setCalendars(calendarMap);
    schedulerFactoryBean.setSchedulerListeners(schedulerListeners);
    return schedulerFactoryBean;
}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:19,代码来源:ScheduleAutoConfiguration.java

示例2: schedulerFactoryBean

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
@Bean
    public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
        SchedulerFactoryBean factory = new SchedulerFactoryBean();
        factory.setDataSource(dataSource);

        //quartz参数
        Properties prop = new Properties();
        prop.put("org.quartz.scheduler.instanceName", "RenrenScheduler");
        prop.put("org.quartz.scheduler.instanceId", "AUTO");
        //线程池配置
        prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
        prop.put("org.quartz.threadPool.threadCount", "20");
        prop.put("org.quartz.threadPool.threadPriority", "5");
        //JobStore配置
        prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
        //集群配置
//        prop.put("org.quartz.jobStore.isClustered", "true");
//        prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
//        prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");

        prop.put("org.quartz.jobStore.misfireThreshold", "12000");
        prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
        factory.setQuartzProperties(prop);

        factory.setSchedulerName("RenrenScheduler");
        //延时启动
        factory.setStartupDelay(30);
        factory.setApplicationContextSchedulerContextKey("applicationContextKey");
        //可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
        factory.setOverwriteExistingJobs(true);
        //设置自动启动,默认为true
        factory.setAutoStartup(true);

        return factory;
    }
 
开发者ID:zhaoqicheng,项目名称:renren-fast,代码行数:36,代码来源:ScheduleConfig.java

示例3: schedulerFactoryBean

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
/**
 * create scheduler
 */
@Bean
public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
 
    SchedulerFactoryBean factory = new SchedulerFactoryBean();
    factory.setOverwriteExistingJobs(true);
    factory.setDataSource(dataSource);
    factory.setQuartzProperties(quartzProperties());
    
    //Register listeners to get notification on Trigger misfire etc
    factory.setGlobalTriggerListeners(triggerListner);
    factory.setGlobalJobListeners(jobsListener);
    
    AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
    jobFactory.setApplicationContext(applicationContext);
    factory.setJobFactory(jobFactory);
    
    return factory;
}
 
开发者ID:javabypatel,项目名称:spring-boot-quartz-demo,代码行数:22,代码来源:QuartzSchedulerConfig.java

示例4: schedulerFactoryBean

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
@Bean(name = "batch")
    public SchedulerFactoryBean schedulerFactoryBean(
    		DataSource dataSource, 
    		JobFactory jobFactory) {
        SchedulerFactoryBean factory = new SchedulerFactoryBean();
        factory.setOverwriteExistingJobs(true);
        factory.setDataSource(dataSource);
        factory.setJobFactory(jobFactory);
        
        Properties props = new Properties();
        props.setProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, "batch");
        props.setProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_ID, "auto");
        props.setProperty("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.HSQLDBDelegate");
        props.setProperty("org.quartz.scheduler.skipUpdateCheck", "true");
//        factory.setQuartzProperties(props);
//        factory.setTriggers(sampleJobTrigger);

        return factory;
    }
 
开发者ID:mow811236,项目名称:sample-schedule-job-admin,代码行数:20,代码来源:Quartz.java

示例5: schedulerFactoryBean

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactoryBean(
        DataSource dataSource, PlatformTransactionManager transactionManager, JobFactory jobFactory) {

    final SchedulerFactoryBean factory = new SchedulerFactoryBean();
    factory.setOverwriteExistingJobs(true);
    factory.setTaskExecutor(commonTaskScheduler.getScheduledExecutor());
    factory.setDataSource(dataSource);
    factory.setTransactionManager(transactionManager);
    factory.setJobFactory(jobFactory);
    factory.setQuartzProperties(quartzProperties);
    factory.setSchedulerName(SCHEDULER_NAME);
    factory.setAutoStartup(true);
    factory.setWaitForJobsToCompleteOnShutdown(true);

    // Delay added to avoid errors caused by updating registered tasks and reduce load on startup
    factory.setStartupDelay(30);

    return factory;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:21,代码来源:QuartzConfig.java

示例6: build

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
public SchedulerFactoryBean build() throws Exception {
	SchedulerFactoryBean bean = new SchedulerFactoryBean();
	PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
	propertiesFactoryBean.setLocation(new ClassPathResource(config));
	propertiesFactoryBean.afterPropertiesSet();
	Properties props = propertiesFactoryBean.getObject();
	List<Trigger> triggers = Lists.newArrayList();
	List<JobModel> jobList = getJobs(props);
	for (JobModel job : jobList) {
		if (!job.isEnable()) {
			continue;
		}
		JobDetailFactoryBean detail = createJobDetail(job.getName(), Class.forName(job.getJob()));
		CronTriggerFactoryBean trigger = createCronTrigger(job.getName(), detail.getObject(), job.getCorn());
		CronTrigger t = trigger.getObject();
		triggers.add(t);
	}
	bean.setTriggers(triggers.toArray(new Trigger[0]));
	//bean.afterPropertiesSet();
	return bean;

}
 
开发者ID:mazhaoyong,项目名称:api-server-seed,代码行数:23,代码来源:QuartzFactory.java

示例7: schedulerFactory

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactory(JobFactory jobFactory) throws IOException {
    SchedulerFactoryBean factory = new SchedulerFactoryBean();
    factory.setSchedulerName("Sentry");
    factory.setJobFactory(jobFactory);
    factory.setQuartzProperties(quartzProperties());
    // this allows to update triggers in DB when updating settings in config file:
    factory.setOverwriteExistingJobs(true);
    return factory;
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:11,代码来源:SchedulerConfiguration.java

示例8: getApplicationContext

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
private WebApplicationContext getApplicationContext() {
	if (context == null) {
		String _step = step; //preserve step
		step = "Shutdown schedulers";
		Long lngId = (long)cfg.getDefaultLangId();
		context = ApplicationHelper.getApplicationContext(lngId);
		SchedulerFactoryBean sfb = context.getBean(SchedulerFactoryBean.class);
		try {
			sfb.getScheduler().shutdown(false);
			step = _step; //restore
		} catch (Exception e) {
			handleError(e);
		}
	}
	return context;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:17,代码来源:Admin.java

示例9: schedulerFactoryBean

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactoryBean(ApplicationContext applicationContext, DataSource dataSource,
		JobFactory jobFactory)
{
	SchedulerFactoryBean schedulerFactory = new SchedulerFactoryBean();
	schedulerFactory.setConfigLocation(new ClassPathResource("quartz.properties"));
	schedulerFactory.setAutoStartup(true);
	schedulerFactory.setDataSource(dataSource);
	schedulerFactory.setJobFactory(jobFactory);
	return schedulerFactory;
}
 
开发者ID:yonadev,项目名称:yona-server,代码行数:12,代码来源:QuartzConfig.java

示例10: schedule

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
public static void schedule(final SchedulerFactoryBean scheduler, final Map<String, Object> jobMap) {
    @SuppressWarnings("unchecked")
    AfterHandlingJob jobInstance = (AfterHandlingJob) ApplicationContextProvider.getBeanFactory().
            createBean(AfterHandlingJob.class, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
    String jobName = AfterHandlingJob.class.getName() + UUID.randomUUID();

    jobMap.put(JobManager.DOMAIN_KEY, AuthContextUtils.getDomain());

    ApplicationContextProvider.getBeanFactory().registerSingleton(jobName, jobInstance);

    JobBuilder jobDetailBuilder = JobBuilder.newJob(AfterHandlingJob.class).
            withIdentity(jobName).
            usingJobData(new JobDataMap(jobMap));

    TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger().
            withIdentity(JobNamer.getTriggerName(jobName)).
            startNow();

    try {
        scheduler.getScheduler().scheduleJob(jobDetailBuilder.build(), triggerBuilder.build());
    } catch (SchedulerException e) {
        LOG.error("Could not schedule, aborting", e);
    }
}
 
开发者ID:apache,项目名称:syncope,代码行数:25,代码来源:AfterHandlingJob.java

示例11: schedulerFactoryBean

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
    SchedulerFactoryBean factory = new SchedulerFactoryBean();
    factory.setDataSource(dataSource);

    //quartz参数
    Properties prop = new Properties();
    prop.put("org.quartz.scheduler.instanceName", "JxteleScheduler");
    prop.put("org.quartz.scheduler.instanceId", "AUTO");
    //线程池配置
    prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
    prop.put("org.quartz.threadPool.threadCount", "20");
    prop.put("org.quartz.threadPool.threadPriority", "5");
    //JobStore配置
    prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
    //集群配置
    prop.put("org.quartz.jobStore.isClustered", "true");
    prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
    prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");

    prop.put("org.quartz.jobStore.misfireThreshold", "12000");
    prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
    factory.setQuartzProperties(prop);

    factory.setSchedulerName("RenrenScheduler");
    //延时启动
    factory.setStartupDelay(30);
    factory.setApplicationContextSchedulerContextKey("applicationContextKey");
    //可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
    factory.setOverwriteExistingJobs(true);
    //设置自动启动,默认为true
    factory.setAutoStartup(true);

    return factory;
}
 
开发者ID:guolf,项目名称:pds,代码行数:36,代码来源:ScheduleConfig.java

示例12: schedulerFactory

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
/** 
 * attention: 
 * Details:定义quartz调度工厂 
 */  
@Bean(name = "scheduler")  
public SchedulerFactoryBean schedulerFactory(Trigger cronJobTrigger) {  
    SchedulerFactoryBean bean = new SchedulerFactoryBean();  
    // 用于quartz集群,QuartzScheduler 启动时更新己存在的Job  
    bean.setOverwriteExistingJobs(true);  
    // 延时启动,应用启动1秒后  
    bean.setStartupDelay(1);  
    // 注册触发器  
    bean.setTriggers(cronJobTrigger);  
    return bean;  
}
 
开发者ID:duanyaxin,项目名称:springboot-smart,代码行数:16,代码来源:QuartzConfigration.java

示例13: before

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
@Before
public void before() throws Exception
{
    // Create fresh scheduler
    SchedulerFactoryBean sfb = new SchedulerFactoryBean();
    sfb.setSchedulerFactoryClass(AlfrescoSchedulerFactory.class);
    sfb.setAutoStartup(false);
    sfb.afterPropertiesSet();
    scheduler = sfb.getScheduler();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:HBDataCollectorServiceImplTest.java

示例14: schedulerFactory

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
@Bean
public SchedulerFactoryBean schedulerFactory(ApplicationContext applicationContext) {
	SchedulerFactoryBean factoryBean = new SchedulerFactoryBean();
	AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
	jobFactory.setApplicationContext(applicationContext);
	
	factoryBean.setJobFactory(jobFactory);
	factoryBean.setApplicationContextSchedulerContextKey("applicationContext");
	return factoryBean;
}
 
开发者ID:juliuskrah,项目名称:quartz-manager,代码行数:11,代码来源:Application.java

示例15: createSchedulerFactoryBean

import org.springframework.scheduling.quartz.SchedulerFactoryBean; //导入依赖的package包/类
/**
 * 创建调度服务
 * 每一个批次启动后,创建一个调度服务
 */
public SchedulerFactoryBean createSchedulerFactoryBean(BatchRunConfDto conf, ResourceManagement drm) throws Exception {
    this.conf = conf;
    this.jobKeyStatusService = drm.getJobKeyStatusService();
    this.argumentService = drm.getArgumentService();

    getAllTaskForMap();
    initGroupTaskMap(drm.getJobKeyList());

    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
    // 配置DataSource后,将会出现异常
    // JobLauncher实例化对象无法序列化
    // schedulerFactoryBean.setDataSource(dataSource);
    schedulerFactoryBean.setSchedulerName(conf.getBatchId());
    schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(true);
    schedulerFactoryBean.setAutoStartup(false);

    // 获取指定批次的所有任务Job
    ArrayList<SimpleTrigger> arrayList = new ArrayList<SimpleTrigger>();
    for (String jobId : jobKeyStatusService.getAllJob().keySet()) {
        SimpleTrigger simpleTrigger = createSimpleTrigger(jobId);
        schedulerFactoryBean.setTriggers(simpleTrigger);
        arrayList.add(simpleTrigger);
    }

    SimpleTrigger[] simpleTriggers = new SimpleTrigger[arrayList.size()];
    for (int i = 0; i < arrayList.size(); i++) {
        simpleTriggers[i] = arrayList.get(i);
    }
    schedulerFactoryBean.setTriggers(simpleTriggers);
    schedulerFactoryBean.afterPropertiesSet();
    schedulerFactoryBean.getScheduler().pauseAll();
    schedulerFactoryBean.start();
    return schedulerFactoryBean;
}
 
开发者ID:hzwy23,项目名称:batch-scheduler,代码行数:39,代码来源:BatchSchedulerConfig.java


注:本文中的org.springframework.scheduling.quartz.SchedulerFactoryBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。