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


Java CronTrigger.setJobName方法代碼示例

本文整理匯總了Java中org.quartz.CronTrigger.setJobName方法的典型用法代碼示例。如果您正苦於以下問題:Java CronTrigger.setJobName方法的具體用法?Java CronTrigger.setJobName怎麽用?Java CronTrigger.setJobName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.quartz.CronTrigger的用法示例。


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

示例1: scheduleBatchEmailReminders

import org.quartz.CronTrigger; //導入方法依賴的package包/類
@Override
public void scheduleBatchEmailReminders() throws Exception {
    String emailBatchGroup = "Email Batch";
    String dailyCron = ConfigContext.getCurrentContextConfig()
            .getProperty(KewApiConstants.DAILY_EMAIL_CRON_EXPRESSION);
    if (!StringUtils.isBlank(dailyCron)) {
        LOG.info("Scheduling Daily Email batch with cron expression: " + dailyCron);
        CronTrigger dailyTrigger = new CronTrigger(DAILY_TRIGGER_NAME, emailBatchGroup, dailyCron);
        JobDetail dailyJobDetail = new JobDetail(DAILY_JOB_NAME, emailBatchGroup, DailyEmailJob.class);
        dailyTrigger.setJobName(dailyJobDetail.getName());
        dailyTrigger.setJobGroup(dailyJobDetail.getGroup());
        addJobToScheduler(dailyJobDetail);
        addTriggerToScheduler(dailyTrigger);
    } else {
        LOG.warn("No " + KewApiConstants.DAILY_EMAIL_CRON_EXPRESSION
                + " parameter was configured.  Daily Email batch was not scheduled!");
    }

    String weeklyCron = ConfigContext.getCurrentContextConfig().getProperty(
            KewApiConstants.WEEKLY_EMAIL_CRON_EXPRESSION);
    if (!StringUtils.isBlank(weeklyCron)) {
        LOG.info("Scheduling Weekly Email batch with cron expression: " + weeklyCron);
        CronTrigger weeklyTrigger = new CronTrigger(WEEKLY_TRIGGER_NAME, emailBatchGroup, weeklyCron);
        JobDetail weeklyJobDetail = new JobDetail(WEEKLY_JOB_NAME, emailBatchGroup, WeeklyEmailJob.class);
        weeklyTrigger.setJobName(weeklyJobDetail.getName());
        weeklyTrigger.setJobGroup(weeklyJobDetail.getGroup());
        addJobToScheduler(weeklyJobDetail);
        addTriggerToScheduler(weeklyTrigger);
    } else {
        LOG.warn("No " + KewApiConstants.WEEKLY_EMAIL_CRON_EXPRESSION
                + " parameter was configured.  Weekly Email batch was not scheduled!");
    }
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:34,代碼來源:ActionListEmailServiceImpl.java

示例2: scheduleBatchEmailReminders

import org.quartz.CronTrigger; //導入方法依賴的package包/類
@Override
public void scheduleBatchEmailReminders() throws Exception {
    sendDailyReminderCalled = false;
    sendWeeklyReminderCalled = false;
    LOG.info("Scheduling Batch Email Reminders.");
    String emailBatchGroup = "Email Batch";
    String dailyCron = ConfigContext.getCurrentContextConfig()
            .getProperty(KewApiConstants.DAILY_EMAIL_CRON_EXPRESSION);
    if (!StringUtils.isBlank(dailyCron)) {
        LOG.info("Scheduling Daily Email batch with cron expression: " + dailyCron);
        CronTrigger dailyTrigger = new CronTrigger(DAILY_TRIGGER_NAME, emailBatchGroup, dailyCron);
        JobDetail dailyJobDetail = new JobDetail(DAILY_JOB_NAME, emailBatchGroup, DailyEmailJob.class);
        dailyTrigger.setJobName(dailyJobDetail.getName());
        dailyTrigger.setJobGroup(dailyJobDetail.getGroup());
        sendDailyReminderCalled = true;
    } else {
        LOG.warn("No " + KewApiConstants.DAILY_EMAIL_CRON_EXPRESSION
                + " parameter was configured.  Daily Email batch was not scheduled!");
    }

    String weeklyCron = ConfigContext.getCurrentContextConfig().getProperty(
            KewApiConstants.WEEKLY_EMAIL_CRON_EXPRESSION);
    if (!StringUtils.isBlank(weeklyCron)) {
        LOG.info("Scheduling Weekly Email batch with cron expression: " + weeklyCron);
        CronTrigger weeklyTrigger = new CronTrigger(WEEKLY_TRIGGER_NAME, emailBatchGroup, weeklyCron);
        JobDetail weeklyJobDetail = new JobDetail(WEEKLY_JOB_NAME, emailBatchGroup, WeeklyEmailJob.class);
        weeklyTrigger.setJobName(weeklyJobDetail.getName());
        weeklyTrigger.setJobGroup(weeklyJobDetail.getGroup());
        sendWeeklyReminderCalled = true;
    } else {
        LOG.warn("No " + KewApiConstants.WEEKLY_EMAIL_CRON_EXPRESSION
                + " parameter was configured.  Weekly Email batch was not scheduled!");
    }
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:35,代碼來源:MockEmailNotificationServiceImpl.java

示例3: scheduleBatchEmailReminders

import org.quartz.CronTrigger; //導入方法依賴的package包/類
public void scheduleBatchEmailReminders() throws Exception {
    String emailBatchGroup = "Email Batch";
    String dailyCron = ConfigContext.getCurrentContextConfig()
            .getProperty(KewApiConstants.DAILY_EMAIL_CRON_EXPRESSION);
    if (!StringUtils.isBlank(dailyCron)) {
        LOG.info("Scheduling Daily Email batch with cron expression: " + dailyCron);
        CronTrigger dailyTrigger = new CronTrigger(DAILY_TRIGGER_NAME, emailBatchGroup, dailyCron);
        JobDetail dailyJobDetail = new JobDetail(DAILY_JOB_NAME, emailBatchGroup, DailyEmailJob.class);
        dailyTrigger.setJobName(dailyJobDetail.getName());
        dailyTrigger.setJobGroup(dailyJobDetail.getGroup());
        addJobToScheduler(dailyJobDetail);
        addTriggerToScheduler(dailyTrigger);
    } else {
        LOG.warn("No " + KewApiConstants.DAILY_EMAIL_CRON_EXPRESSION
                + " parameter was configured.  Daily Email batch was not scheduled!");
    }

    String weeklyCron = ConfigContext.getCurrentContextConfig().getProperty(
            KewApiConstants.WEEKLY_EMAIL_CRON_EXPRESSION);
    if (!StringUtils.isBlank(weeklyCron)) {
        LOG.info("Scheduling Weekly Email batch with cron expression: " + weeklyCron);
        CronTrigger weeklyTrigger = new CronTrigger(WEEKLY_TRIGGER_NAME, emailBatchGroup, weeklyCron);
        JobDetail weeklyJobDetail = new JobDetail(WEEKLY_JOB_NAME, emailBatchGroup, WeeklyEmailJob.class);
        weeklyTrigger.setJobName(weeklyJobDetail.getName());
        weeklyTrigger.setJobGroup(weeklyJobDetail.getGroup());
        addJobToScheduler(weeklyJobDetail);
        addTriggerToScheduler(weeklyTrigger);
    } else {
        LOG.warn("No " + KewApiConstants.WEEKLY_EMAIL_CRON_EXPRESSION
                + " parameter was configured.  Weekly Email batch was not scheduled!");
    }
}
 
開發者ID:aapotts,項目名稱:kuali_rice,代碼行數:33,代碼來源:ActionListEmailServiceImpl.java

示例4: testSchedulerFactoryBeanWithPlainQuartzObjects

import org.quartz.CronTrigger; //導入方法依賴的package包/類
@Test
public void testSchedulerFactoryBeanWithPlainQuartzObjects() throws Exception {
	JobFactory jobFactory = new AdaptableJobFactory();

	TestBean tb = new TestBean("tb", 99);
	JobDetail jobDetail0 = new JobDetail();
	jobDetail0.setJobClass(Job.class);
	jobDetail0.setName("myJob0");
	jobDetail0.setGroup(Scheduler.DEFAULT_GROUP);
	jobDetail0.getJobDataMap().put("testBean", tb);
	assertEquals(tb, jobDetail0.getJobDataMap().get("testBean"));

	CronTrigger trigger0 = new CronTrigger();
	trigger0.setName("myTrigger0");
	trigger0.setGroup(Scheduler.DEFAULT_GROUP);
	trigger0.setJobName("myJob0");
	trigger0.setJobGroup(Scheduler.DEFAULT_GROUP);
	trigger0.setStartTime(new Date());
	trigger0.setCronExpression("0/1 * * * * ?");

	TestMethodInvokingTask task1 = new TestMethodInvokingTask();
	MethodInvokingJobDetailFactoryBean mijdfb = new MethodInvokingJobDetailFactoryBean();
	mijdfb.setName("myJob1");
	mijdfb.setGroup(Scheduler.DEFAULT_GROUP);
	mijdfb.setTargetObject(task1);
	mijdfb.setTargetMethod("doSomething");
	mijdfb.afterPropertiesSet();
	JobDetail jobDetail1 = mijdfb.getObject();

	SimpleTrigger trigger1 = new SimpleTrigger();
	trigger1.setName("myTrigger1");
	trigger1.setGroup(Scheduler.DEFAULT_GROUP);
	trigger1.setJobName("myJob1");
	trigger1.setJobGroup(Scheduler.DEFAULT_GROUP);
	trigger1.setStartTime(new Date());
	trigger1.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
	trigger1.setRepeatInterval(20);

	final Scheduler scheduler = mock(Scheduler.class);
	given(scheduler.scheduleJob(trigger0)).willReturn(new Date());
	given(scheduler.scheduleJob(trigger1)).willReturn(new Date());

	SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() {
		@Override
		protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) {
			return scheduler;
		}
	};
	schedulerFactoryBean.setJobFactory(jobFactory);
	schedulerFactoryBean.setJobDetails(new JobDetail[] {jobDetail0, jobDetail1});
	schedulerFactoryBean.setTriggers(new Trigger[] {trigger0, trigger1});
	try {
		schedulerFactoryBean.afterPropertiesSet();
		schedulerFactoryBean.start();
	}
	finally {
		schedulerFactoryBean.destroy();
	}

	verify(scheduler).setJobFactory(jobFactory);
	verify(scheduler).getJobDetail("myJob0", Scheduler.DEFAULT_GROUP);
	verify(scheduler).getJobDetail("myJob1", Scheduler.DEFAULT_GROUP);
	verify(scheduler).getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP);
	verify(scheduler).getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP);
	verify(scheduler).addJob(jobDetail0, true);
	verify(scheduler).addJob(jobDetail1, true);
	verify(scheduler).scheduleJob(trigger0);
	verify(scheduler).scheduleJob(trigger1);
	verify(scheduler).start();
	verify(scheduler).shutdown(false);
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:72,代碼來源:QuartzSupportTests.java


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