当前位置: 首页>>代码示例>>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;未经允许,请勿转载。