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


Java StdSchedulerFactory.getDefaultScheduler方法代码示例

本文整理汇总了Java中org.quartz.impl.StdSchedulerFactory.getDefaultScheduler方法的典型用法代码示例。如果您正苦于以下问题:Java StdSchedulerFactory.getDefaultScheduler方法的具体用法?Java StdSchedulerFactory.getDefaultScheduler怎么用?Java StdSchedulerFactory.getDefaultScheduler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.impl.StdSchedulerFactory的用法示例。


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: testQuartzAPI

import org.quartz.impl.StdSchedulerFactory; //导入方法依赖的package包/类
public void testQuartzAPI() throws SchedulerException, InterruptedException {
    Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
    scheduler.start();
    for (int i = 1 ; i < 10; i++) {
        scheduler.scheduleJob(MockUtils.getEmptyJobDetail(String.valueOf(i)), MockUtils.getEmptyTrigger(String.valueOf(i)));
    }
    Thread.sleep(5000);
    for (;;) {
        List<JobExecutionContext> jobExecutionContexts = scheduler.getCurrentlyExecutingJobs();
        for (JobExecutionContext jobExecutionContext : jobExecutionContexts) {
            System.out.println(JsonHelper.toJson(jobExecutionContext.getJobDetail().getKey().getGroup()));
            System.out.println(JsonHelper.toJson(jobExecutionContext.getJobDetail().getKey().getName()));
            System.out.println(JsonHelper.toJson(scheduler.getTriggerState(jobExecutionContext.getTrigger().getKey())));
            System.out.println("----------------------");
        }
    }
}
 
开发者ID:xiaolongzuo,项目名称:niubi-job-examples,代码行数:18,代码来源:QuartzTest.java

示例8: start

import org.quartz.impl.StdSchedulerFactory; //导入方法依赖的package包/类
public void start(final long interval) {
	try {
		// Grab the Scheduler instance from the Factory
		final org.quartz.Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

		// define the job and tie it to our NokiaHereAdapter class
		final JobDetail jd = new JobDetail(this.name, Scheduler.DEFAULT_GROUP, AdapterJob.class);

		// triggers all 120 seconds the execution of execution, never ends
		final SimpleTrigger simpleTrigger = new SimpleTrigger(this.name, Scheduler.DEFAULT_GROUP, new Date(), null, SimpleTrigger.REPEAT_INDEFINITELY, interval * 1000);

		// Tell quartz to schedule the job using our trigger
		scheduler.scheduleJob(jd, simpleTrigger);
		scheduler.start();
	} catch (final SchedulerException se) {
		se.printStackTrace();
	}
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:19,代码来源:EventAdapter.java

示例9: start

import org.quartz.impl.StdSchedulerFactory; //导入方法依赖的package包/类
public void start()
{
	final JobDetail job = newJob(CrawlJob.class).withIdentity("CraigJob",
			"Crawl").build();

	final Trigger trigger = newTrigger()
			.withIdentity(new TriggerKey("CraigTrigger", "Crawl"))
			.withSchedule(
					simpleSchedule().withIntervalInMinutes(60)
							.repeatForever()).startNow().build();

	try
	{
		Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
		scheduler.scheduleJob(job, trigger);
		scheduler.start();
	}
	catch (SchedulerException e)
	{
		LOGGER.error("Error while scheduling job", e);
	}

}
 
开发者ID:milothemeanie,项目名称:housingcraigcrawl,代码行数:24,代码来源:ApplicationCraigCrawl.java

示例10: addGlobalJobListener

import org.quartz.impl.StdSchedulerFactory; //导入方法依赖的package包/类
@Override
public void addGlobalJobListener(JobListener jobGlobalListener) throws SchedulerException {
	final Scheduler defaultScheduler;
	final List<Matcher<JobKey>> allJobs = new ArrayList<Matcher<JobKey>>();
	allJobs.add(EverythingMatcher.allJobs());
	if (Parameter.QUARTZ_DEFAULT_LISTENER_DISABLED.getValueAsBoolean()) {
		defaultScheduler = null;
		LOG.debug("Initialization of Quartz default listener has been disabled");
	} else {
		defaultScheduler = StdSchedulerFactory.getDefaultScheduler();
		defaultScheduler.getListenerManager().addJobListener(jobGlobalListener, allJobs);
	}
	for (final Scheduler scheduler : JobInformations.getAllSchedulers()) {
		if (scheduler != defaultScheduler) {
			scheduler.getListenerManager().addJobListener(jobGlobalListener, allJobs);
		}
	}
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:19,代码来源:Quartz2Adapter.java

示例11: testToString

import org.quartz.impl.StdSchedulerFactory; //导入方法依赖的package包/类
/** Test.
 * @throws SchedulerException e */
@Test
public void testToString() throws SchedulerException {
	final Collector collector = createCollectorWithOneCounter();
	assertToStringNotEmpty("collector", collector);
	assertToStringNotEmpty("java", new JavaInformations(null, false));
	assertToStringNotEmpty("thread",
			new ThreadInformations(Thread.currentThread(),
					Arrays.asList(Thread.currentThread().getStackTrace()), 100, 1000, false,
					Parameters.getHostAddress()));
	assertToStringNotEmpty("session", new SessionInformations(new SessionTestImpl(true), true));
	assertToStringNotEmpty("memory", new MemoryInformations());
	CacheManager.getInstance().addCache("testToString");
	try {
		assertToStringNotEmpty("cache", new CacheInformations(
				CacheManager.getInstance().getEhcache("testToString"), false));
	} finally {
		CacheManager.getInstance().shutdown();
	}
	final Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
	final JobDetail job = new JobDetail("job", null, JobTestImpl.class);
	assertToStringNotEmpty("job", new JobInformations(job, null, scheduler));
	assertToStringNotEmpty("connectionInfos", new ConnectionInformations());
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:26,代码来源:TestCollector.java

示例12: scheduleJob

import org.quartz.impl.StdSchedulerFactory; //导入方法依赖的package包/类
/**
 * Schedules new quartz scheduler jobs for committing transactions and
 * backing up the database
 */
private void scheduleJob() {
	try {
		Scheduler sched = StdSchedulerFactory.getDefaultScheduler();

		// schedule commit-job
		JobDetail job = newJob(CommitJob.class).withIdentity(
				"Commit_Transaction", SCHEDULER_GROUP).build();

		SimpleTrigger trigger = newTrigger()
				.withIdentity("Commit_Transaction", SCHEDULER_GROUP)
				.withSchedule(repeatSecondlyForever(commitInterval))
				.build();

		sched.scheduleJob(job, trigger);
		logger.debug("Scheduled Commit-Job with interval {}sec.",
				commitInterval);

	} catch (SchedulerException e) {
		logger.warn("Could not create Job: {}", e.getMessage());
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:26,代码来源:MapDBPersistenceService.java

示例13: scheduleRefreshJob

import org.quartz.impl.StdSchedulerFactory; //导入方法依赖的package包/类
/**
 * Schedules a quartz job which is triggered every minute.
 */
public static void scheduleRefreshJob() {
	try {
		Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
		JobDetail job = newJob(RefreshJob.class)
		    .withIdentity(REFRESH_JOB_KEY)
		    .build();

		SimpleTrigger trigger = newTrigger()
		    .withIdentity(REFRESH_TRIGGER_KEY)
		    .withSchedule(repeatSecondlyForever(refreshInterval))
		    .build();

		sched.scheduleJob(job, trigger);
		logger.debug("Scheduled refresh job '{}' in DefaulScheduler", job.getKey());
	} catch (SchedulerException e) {
		logger.warn("Could not schedule refresh job: {}", e.getMessage());
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:22,代码来源:ConfigDispatcher.java

示例14: scheduleReconnect

import org.quartz.impl.StdSchedulerFactory; //导入方法依赖的package包/类
private void scheduleReconnect() {
	Scheduler sched;
	try {
		sched = StdSchedulerFactory.getDefaultScheduler();
		JobDetail job = newJob(ReconnectJob.class)
		    .withIdentity("Reconnect", MPD_SCHEDULER_GROUP)
		    .build();
		CronTrigger trigger = newTrigger()
		    .withIdentity("Reconnect", MPD_SCHEDULER_GROUP)
		    .withSchedule(CronScheduleBuilder.cronSchedule("0 0 0 * * ?"))
		    .build();

		sched.scheduleJob(job, trigger);
		logger.debug("Scheduled a daily MPD Reconnect of all MPDs");
	} catch (SchedulerException se) {
		logger.warn("scheduling MPD Reconnect failed", se);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:19,代码来源:MpdBinding.java

示例15: MetricsService

import org.quartz.impl.StdSchedulerFactory; //导入方法依赖的package包/类
public MetricsService() throws SchedulerException {
    // I originally had this in start() but it looks like start() and
    // the various ADD operations that are invoked after the subsystem
    // is parsed can run in separate threads, so I had a race condition
    // where something like createJob() would run before start(), resulting
    // in an NPE because the scheduler was null. Not sure of the best way
    // to do this...
    log.debug("Creating metrics scheduler");
    scheduler = StdSchedulerFactory.getDefaultScheduler();

    // Is this the most appropriate executor type?
    managementOperationExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() {
        @Override
        public Thread newThread(Runnable run) {
            Thread thread = new Thread(run);
            thread.setName("Metrics Management Client Thread");
            thread.setDaemon(true);
            return thread;
        }
    });
}
 
开发者ID:ncdc,项目名称:jboss-openshift-metrics-module,代码行数:22,代码来源:MetricsService.java


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