當前位置: 首頁>>代碼示例>>Java>>正文


Java StdSchedulerFactory類代碼示例

本文整理匯總了Java中org.quartz.impl.StdSchedulerFactory的典型用法代碼示例。如果您正苦於以下問題:Java StdSchedulerFactory類的具體用法?Java StdSchedulerFactory怎麽用?Java StdSchedulerFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StdSchedulerFactory類屬於org.quartz.impl包,在下文中一共展示了StdSchedulerFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refreshMetadata

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
/**
 * Refresh metadata. Schedules the job to retrieve metadata.
 * @throws SchedulerException the scheduler exception
 */
@PostConstruct
public void refreshMetadata() throws SchedulerException {
    final Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            buildMetadataResolverAggregate();
        }
    });
    thread.start();

    final JobDetail job = JobBuilder.newJob(this.getClass())
            .withIdentity(this.getClass().getSimpleName()).build();
    final Trigger trigger = TriggerBuilder.newTrigger()
            .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                    .withIntervalInMinutes(this.refreshIntervalInMinutes)
                    .repeatForever()).build();

    final SchedulerFactory schFactory = new StdSchedulerFactory();
    final Scheduler sch = schFactory.getScheduler();
    sch.start();
    sch.scheduleJob(job, trigger);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:27,代碼來源:StaticMetadataResolverAdapter.java

示例2: scheduleJob

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
/**
 * The user may configure this binding to update the internal clock of
 * FHT80b devices via rf command. The method takes care of scheduling this
 * job.
 */
private JobKey scheduleJob(Class<? extends Job> jobClass, String cronExpression) {
	JobKey jobKey = null;
	try {
		Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
		JobDetail detail = JobBuilder.newJob(jobClass).withIdentity("FHT "+jobClass.getSimpleName(), "cul").build();
		detail.getJobDataMap().put(FHTBinding.class.getName(), this);
		
		CronTrigger trigger = TriggerBuilder.newTrigger().forJob(detail)
				.withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)).build();
		jobKey = detail.getKey();
		sched.scheduleJob(detail, trigger);
	} catch (SchedulerException e) {
		logger.error("Can't schedule time update job", e);
	}
	return jobKey;
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:22,代碼來源:FHTBinding.java

示例3: schedulerFactory

import org.quartz.impl.StdSchedulerFactory; //導入依賴的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

示例4: start

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
public void start(){
    for(int index = 0; index < jobList.size(); index++){
        JobInfo jobInfo = jobList.get(index);
        String logTitle = "[" + code + "]" + jobInfo.getName() + " ";
        try{
            SchedulerFactory sf = new StdSchedulerFactory();
            Scheduler sched = sf.getScheduler();
            JobDetail job = newJob(DataTask.class).withIdentity("job-" + jobInfo.getName(), code).build();
            job.getJobDataMap().put("srcDb", srcDb);
            job.getJobDataMap().put("destDb", destDb);
            job.getJobDataMap().put("jobInfo", jobInfo);
            job.getJobDataMap().put("logTitle", logTitle);
            logger.info(jobInfo.getCron());
            CronTrigger trigger = newTrigger()
                            .withIdentity("trigger-" +  jobInfo.getName(), code)
                            .withSchedule(cronSchedule(jobInfo.getCron())).build();
            sched.scheduleJob(job, trigger);
            sched.start();  
        }catch(Exception e){
            logger.info(logTitle + e.getMessage());
            logger.info(logTitle + " run failed");
            continue;
        }
    }
}
 
開發者ID:GongDexing,項目名稱:database-sync,代碼行數:26,代碼來源:App.java

示例5: cancelAllJobs

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
/**
 * Delete all quartz scheduler jobs of the group <code>Dropbox</code>.
 */
private void cancelAllJobs() {
	try {
		Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
		Set<JobKey> jobKeys = sched
				.getJobKeys(jobGroupEquals(SCHEDULER_GROUP));
		if (jobKeys.size() > 0) {
			sched.deleteJobs(new ArrayList<JobKey>(jobKeys));
			logger.debug(
					"Found {} MapDB-Jobs to delete from DefaulScheduler (keys={})",
					jobKeys.size(), jobKeys);
		}
	} catch (SchedulerException e) {
		logger.warn("Couldn't remove Commit-Job: {}", e.getMessage());
	}
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:19,代碼來源:MapDBPersistenceService.java

示例6: testCodedCronTriggerBean

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
/**
 * Ensures that jobs that are coded without a delay run without delay.
 * @throws Exception
 */
@Test
public void testCodedCronTriggerBean() throws Exception
{
    final String JOB_NAME = "codedCronJob";
    List<Long> jobRuns = this.getRunList(JOB_NAME);
    assertEquals(0, jobRuns.size());
    scheduler = StdSchedulerFactory.getDefaultScheduler();
    scheduler.start();
    CronTriggerBean ctBean = new CronTriggerBean();
    ctBean.setBeanName("Dummy");
    ctBean.setCronExpression("0/1 * * * * ? *");
    ctBean.setEnabled(true);
    JobDetail jobDetail = new JobDetail(JOB_NAME, "DefaultGroup", DummyJob.class);
    ctBean.setJobDetail(jobDetail);
    ctBean.setScheduler(scheduler);
    ctBean.afterPropertiesSet();

    assertJobRunsAfterInterval(jobRuns);
    scheduler.shutdown();
    this.assertJobStopsAfterShutdown(jobRuns);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:26,代碼來源:CronTriggerBeanTest.java

示例7: startHealthCheckJob

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
public static void startHealthCheckJob() {
    try {
        // Grab the Scheduler instance from the Factory
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        // and start it off
        scheduler.start();
        // define the job and tie it to our Job class
        JobDetail job = newJob(DirectoryHealthCheck.class)
                .withIdentity("microserviceheartbeat", "heartbeats")
                .build();

        // Trigger the job to run now, and then repeat every 90 seconds
        Trigger trigger = newTrigger()
                .withIdentity("microserviceHeartbeatTrigger", "DefaultTrigger")
                .startNow()
                .withSchedule(simpleSchedule()
                        .withIntervalInSeconds(HEALTH_CHECK_FREQUENCY_SECONDS)
                        .repeatForever())
                .build();

        // Tell quartz to schedule the job using our trigger
        scheduler.scheduleJob(job, trigger);
    } catch (SchedulerException ex) {
        Logger.getLogger(DirectoryHealthCheck.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:camendoza94,項目名稱:ZooKeeperClient,代碼行數:27,代碼來源:DirectoryHealthCheck.java

示例8: doStartup

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
/**
 * Starts up this event scheduler.
 */
@Override
public void doStartup() {
    try {
        Properties props = new Properties();
        props.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, getName());
        props.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_ID, getName());
        props.put(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getName());

        // There should be only one thread here to ensure the proper order of scheduled events.
        props.put(PROP_THREAD_COUNT, Integer.toString(1));

        StdSchedulerFactory schedulerFactory = new StdSchedulerFactory();
        schedulerFactory.initialize(props);

        scheduler = schedulerFactory.getScheduler();
        scheduler.start();
    } catch (SchedulerException e) {
        throw SpongeUtils.wrapException(getName(), e);
    }
}
 
開發者ID:softelnet,項目名稱:sponge,代碼行數:24,代碼來源:QuartzEventScheduler.java

示例9: DefaultTaskScheduler

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
public DefaultTaskScheduler() {
	StdSchedulerFactory schedFactory = new StdSchedulerFactory();
	Properties props = new Properties();
	props.setProperty("org.quartz.scheduler.instanceName", "DefaultQuartzScheduler");
	props.setProperty("org.quartz.scheduler.rmi.export", "false");
	props.setProperty("org.quartz.scheduler.rmi.proxy", "false");
       props.setProperty("org.quartz.scheduler.wrapJobExecutionInUserTransaction", "false");
       props.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
       props.setProperty("org.quartz.threadPool.threadCount", "10");
       props.setProperty("org.quartz.jobStore.misfireThreshold", "60000");
       props.setProperty("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");
	try {
		schedFactory.initialize(props);
		quartz = schedFactory.getScheduler();
	} catch (SchedulerException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:19,代碼來源:DefaultTaskScheduler.java

示例10: run

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
@Override
	public void run(String... strings) throws Exception {
		try {
			/*
			 * 在 Quartz 中, scheduler 由 SchedulerFactory創建:DirectSchedulerFactory 或者
			 * StdSchedulerFactory。第二種工廠 StdSchedulerFactory 使用較多,因為
			 * DirectSchedulerFactory 使用起來不夠方便,需要作許多詳細的手工編碼設置。
			 */
			// 獲取Scheduler實例
			scheduler = StdSchedulerFactory.getDefaultScheduler();
			scheduler.start();
//			System.out.println("scheduler.start");
//			System.out.println(scheduler.getSchedulerName());
			// 注冊任務
			JobDetail jobDetail = JobBuilder.newJob(QuartzTask.class).withIdentity("QuartzTaskJob", "QuartzTaskGroup").build();
			// 設置出發時間(每1天執行1次)
			SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(24).repeatForever();
			Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger", "group").startNow().withSchedule(simpleScheduleBuilder).build();
			// 交由Scheduler安排觸發
			scheduler.scheduleJob(jobDetail, trigger);
		} catch (SchedulerException e) {
			e.printStackTrace();
		}
	}
 
開發者ID:CharleyXu,項目名稱:tulingchat,代碼行數:25,代碼來源:QuartzConfig.java

示例11: serverTasks

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
public serverTasks() throws SchedulerException, ParseException{
	
	/* 
	 * 循環式的
	 */
	SchedulerFactory factory = new StdSchedulerFactory();
	Scheduler scheduler = factory.getScheduler();
	//設置啟動時間
	DateBuilder.evenMinuteDate(new Date());
	JobDetail job = JobBuilder.newJob(job.class).withIdentity("job1", "group1").build();
 
	//job.getJobDataMap().put("a", true);//實現傳參
	// @NOTICE
	// 與SimpleTrigger對比:類不同了,現在的是Trigger的子類CronTrigger;withSchedule中的參數變為CronScheduleBuilder了
	// CronScheduleBuilder可以通過類似"0/13 * * * * ?"這種表達式來創建定時任務
	// 當前這個表達式的定義是30分鍾執行一次
	CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger1", "group1")
			.withSchedule(CronScheduleBuilder.cronSchedule("1 0/30 * * * ?")).build();

	scheduler.scheduleJob(job, trigger);

	scheduler.start();
 
	//scheduler.shutdown(true);
	
}
 
開發者ID:Xvms,項目名稱:xvms,代碼行數:27,代碼來源:serverTasks.java

示例12: newScheduler

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
protected Scheduler newScheduler()throws SchedulerException{
	StdSchedulerFactory factory=new StdSchedulerFactory();
	Properties mergedProps = new Properties();
	mergedProps.setProperty(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getName());
	mergedProps.setProperty("org.quartz.scheduler.instanceName", "BDF2Scheduler");
	mergedProps.setProperty("org.quartz.scheduler.instanceId", "CoreBDF2Scheduler");
	mergedProps.setProperty("org.quartz.scheduler.makeSchedulerThreadDaemon", makeSchedulerThreadDaemon);
	mergedProps.setProperty("org.quartz.threadPool.threadCount", Integer.toString(threadCount));
	if (this.configLocation != null) {
		try {
			PropertiesLoaderUtils.fillProperties(mergedProps, this.configLocation);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	factory.initialize(mergedProps);
	Scheduler scheduler=factory.getScheduler();
	Collection<JobExecutionListener> jobListeners = this.getApplicationContext().getBeansOfType(JobExecutionListener.class).values();
	for(JobExecutionListener jobListener:jobListeners){
		jobListener.setSessionFactory(getSessionFactory());
		scheduler.getListenerManager().addJobListener(jobListener);
	}
	return scheduler;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:25,代碼來源:SchedulerServiceImpl.java

示例13: main

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
public static void main(String[] args) {
    try {
        final Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        scheduler.start();
        final JobDetail job = JobBuilder.newJob(MailFilterJob.class).build();
        final Trigger trigger = TriggerBuilder.newTrigger()
                .startNow()
                .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                        .withIntervalInMinutes(15)
                        .repeatForever())
                .build();
        scheduler.scheduleJob(job, trigger);
    } catch (SchedulerException ex) {
        Logger.getLogger(MailFilterService.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:17,代碼來源:MailFilterService.java

示例14: schedulerFactoryBean

import org.quartz.impl.StdSchedulerFactory; //導入依賴的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

示例15: provideScheduler

import org.quartz.impl.StdSchedulerFactory; //導入依賴的package包/類
@Provides
@Singleton
static Scheduler provideScheduler(AuroraCronJobFactory jobFactory) throws SchedulerException {
  // There are several ways to create a quartz Scheduler instance.  This path was chosen as the
  // simplest to create a Scheduler that uses a *daemon* QuartzSchedulerThread instance.
  Properties props = new Properties();
  String name = "aurora-cron-" + ID_GENERATOR.incrementAndGet();
  props.setProperty(PROP_SCHED_NAME, name);
  props.setProperty(PROP_SCHED_INSTANCE_ID, name);
  props.setProperty(PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getCanonicalName());
  props.setProperty(PROP_THREAD_POOL_PREFIX + ".threadCount", NUM_THREADS.get().toString());
  props.setProperty(PROP_THREAD_POOL_PREFIX + ".makeThreadsDaemons", Boolean.TRUE.toString());

  props.setProperty(PROP_SCHED_MAKE_SCHEDULER_THREAD_DAEMON, Boolean.TRUE.toString());
  Scheduler scheduler = new StdSchedulerFactory(props).getScheduler();
  scheduler.setJobFactory(jobFactory);
  return scheduler;
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:19,代碼來源:CronModule.java


注:本文中的org.quartz.impl.StdSchedulerFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。