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