當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。