Java Code Examples for org.quartz.impl.triggers.CronTriggerImpl#setName()

The following examples show how to use org.quartz.impl.triggers.CronTriggerImpl#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchedulerServiceImpl.java    From uflo with Apache License 2.0 6 votes vote down vote up
private void initScanReminderJob(){
	CronTriggerImpl trigger=new CronTriggerImpl();
	trigger.setName("UfloScanReminderTrigger");
	trigger.setKey(new TriggerKey("UfloScanReminderTrigger"));
	try {
		trigger.setCronExpression(SCAN_REMINDER_CRON);
		ScanReminderJob job=new ScanReminderJob();
		ScanReminderJobDetail detail=new ScanReminderJobDetail();
		detail.setSchedulerService(this);
		detail.setTaskService(taskService);
		detail.setReminderTaskList(reminderTaskList);
		detail.setJobClass(job.getClass());
		detail.setKey(new JobKey("UfloScanReminderJob"));
		scheduler.scheduleJob(detail, trigger);
	} catch (Exception e1) {
		throw new RuntimeException(e1);
	}
}
 
Example 2
Source File: CronTriggerFactoryBean.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws ParseException {
	Assert.notNull(this.cronExpression, "Property 'cronExpression' is required");

	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}
	if (this.timeZone == null) {
		this.timeZone = TimeZone.getDefault();
	}

	CronTriggerImpl cti = new CronTriggerImpl();
	cti.setName(this.name != null ? this.name : toString());
	cti.setGroup(this.group);
	if (this.jobDetail != null) {
		cti.setJobKey(this.jobDetail.getKey());
	}
	cti.setJobDataMap(this.jobDataMap);
	cti.setStartTime(this.startTime);
	cti.setCronExpression(this.cronExpression);
	cti.setTimeZone(this.timeZone);
	cti.setCalendarName(this.calendarName);
	cti.setPriority(this.priority);
	cti.setMisfireInstruction(this.misfireInstruction);
	cti.setDescription(this.description);
	this.cronTrigger = cti;
}
 
Example 3
Source File: CronTriggerFactoryBean.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws ParseException {
	Assert.notNull(this.cronExpression, "Property 'cronExpression' is required");

	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}
	if (this.timeZone == null) {
		this.timeZone = TimeZone.getDefault();
	}

	CronTriggerImpl cti = new CronTriggerImpl();
	cti.setName(this.name != null ? this.name : toString());
	cti.setGroup(this.group);
	if (this.jobDetail != null) {
		cti.setJobKey(this.jobDetail.getKey());
	}
	cti.setJobDataMap(this.jobDataMap);
	cti.setStartTime(this.startTime);
	cti.setCronExpression(this.cronExpression);
	cti.setTimeZone(this.timeZone);
	cti.setCalendarName(this.calendarName);
	cti.setPriority(this.priority);
	cti.setMisfireInstruction(this.misfireInstruction);
	cti.setDescription(this.description);
	this.cronTrigger = cti;
}
 
Example 4
Source File: CronTriggerFactoryBean.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws ParseException {
	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}
	if (this.timeZone == null) {
		this.timeZone = TimeZone.getDefault();
	}

	CronTriggerImpl cti = new CronTriggerImpl();
	cti.setName(this.name);
	cti.setGroup(this.group);
	if (this.jobDetail != null) {
		cti.setJobKey(this.jobDetail.getKey());
	}
	cti.setJobDataMap(this.jobDataMap);
	cti.setStartTime(this.startTime);
	cti.setCronExpression(this.cronExpression);
	cti.setTimeZone(this.timeZone);
	cti.setCalendarName(this.calendarName);
	cti.setPriority(this.priority);
	cti.setMisfireInstruction(this.misfireInstruction);
	cti.setDescription(this.description);
	this.cronTrigger = cti;
}
 
Example 5
Source File: CFCronTriggerRunner.java    From NewsRecommendSystem with MIT License 5 votes vote down vote up
public void task(List<Long> users,String cronExpression) throws SchedulerException
{
    // Initiate a Schedule Factory
    SchedulerFactory schedulerFactory = new StdSchedulerFactory();
    // Retrieve a scheduler from schedule factory
    Scheduler scheduler = schedulerFactory.getScheduler();
    
    // Initiate JobDetail with job name, job group, and executable job class
    JobDetailImpl jobDetailImpl = 
    	new JobDetailImpl();
    jobDetailImpl.setJobClass(CFJob.class);
    jobDetailImpl.setKey(new JobKey("CFJob1"));
    jobDetailImpl.getJobDataMap().put("users", users);
    // Initiate CronTrigger with its name and group name
    CronTriggerImpl cronTriggerImpl = new CronTriggerImpl();
    cronTriggerImpl.setName("CFCronTrigger1");
    try {
        // setup CronExpression
        CronExpression cexp = new CronExpression(cronExpression);
        // Assign the CronExpression to CronTrigger
        cronTriggerImpl.setCronExpression(cexp);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // schedule a job with JobDetail and Trigger
    scheduler.scheduleJob(jobDetailImpl, cronTriggerImpl);
    
    // start the scheduler
    scheduler.start();
}
 
Example 6
Source File: HRCronTriggerRunner.java    From NewsRecommendSystem with MIT License 5 votes vote down vote up
public void task(List<Long> users,String cronExpression) throws SchedulerException
{
    // Initiate a Schedule Factory
    SchedulerFactory schedulerFactory = new StdSchedulerFactory();
    // Retrieve a scheduler from schedule factory
    Scheduler scheduler = schedulerFactory.getScheduler();
    
    // Initiate JobDetail with job name, job group, and executable job class
    JobDetailImpl jobDetailImpl = 
    	new JobDetailImpl();
    jobDetailImpl.setJobClass(HRJob.class);
    jobDetailImpl.setKey(new JobKey("HRJob1"));
    jobDetailImpl.getJobDataMap().put("users",users);
    // Initiate CronTrigger with its name and group name
    CronTriggerImpl cronTriggerImpl = new CronTriggerImpl();
    cronTriggerImpl.setName("HRCronTrigger1");
    
    try {
        // setup CronExpression
        CronExpression cexp = new CronExpression(cronExpression);
        // Assign the CronExpression to CronTrigger
        cronTriggerImpl.setCronExpression(cexp);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // schedule a job with JobDetail and Trigger
    scheduler.scheduleJob(jobDetailImpl, cronTriggerImpl);
    
    // start the scheduler
    scheduler.start();
}
 
Example 7
Source File: CBCronTriggerRunner.java    From NewsRecommendSystem with MIT License 5 votes vote down vote up
public void task(List<Long> users,String cronExpression) throws SchedulerException
{
    // Initiate a Schedule Factory
    SchedulerFactory schedulerFactory = new StdSchedulerFactory();
    // Retrieve a scheduler from schedule factory
    Scheduler scheduler = schedulerFactory.getScheduler();
    
    // Initiate JobDetail with job name, job group, and executable job class
    JobDetailImpl jobDetailImpl = 
    	new JobDetailImpl();
    jobDetailImpl.setJobClass(CBJob.class);
    jobDetailImpl.setKey(new JobKey("CBJob1"));
    jobDetailImpl.getJobDataMap().put("users", users);
    // Initiate CronTrigger with its name and group name
    CronTriggerImpl cronTriggerImpl = new CronTriggerImpl();
    cronTriggerImpl.setName("CBCronTrigger1");
    
    try {
        // setup CronExpression
        CronExpression cexp = new CronExpression(cronExpression);
        // Assign the CronExpression to CronTrigger
        cronTriggerImpl.setCronExpression(cexp);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // schedule a job with JobDetail and Trigger
    scheduler.scheduleJob(jobDetailImpl, cronTriggerImpl);
    
    // start the scheduler
    scheduler.start();
}
 
Example 8
Source File: HeartbeatDetectionJob.java    From uflo with Apache License 2.0 5 votes vote down vote up
private Trigger buildHeartJobTrigger() {
	CronTriggerImpl trigger=new CronTriggerImpl();
	trigger.setName("UfloHeartJobTrigger");
	try {
		trigger.setCronExpression(heartJobCronExpression);
		return trigger;
	} catch (ParseException e) {
		throw new RuntimeException(e);
	}
}
 
Example 9
Source File: InstanceDetection.java    From uflo with Apache License 2.0 5 votes vote down vote up
private Trigger initTrigger(){
	CronTriggerImpl trigger=new CronTriggerImpl();
	trigger.setName("UfloHeartbeatTrigger");
	trigger.setKey(new TriggerKey("UfloHeartbeatTrigger"));
	try {
		trigger.setCronExpression(detectionCron);
		return trigger;
	} catch (ParseException e1) {
		throw new RuntimeException(e1);
	}
}
 
Example 10
Source File: CronTriggerFactoryBean.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws ParseException {
	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}
	if (this.timeZone == null) {
		this.timeZone = TimeZone.getDefault();
	}

	CronTriggerImpl cti = new CronTriggerImpl();
	cti.setName(this.name);
	cti.setGroup(this.group);
	cti.setJobKey(this.jobDetail.getKey());
	cti.setJobDataMap(this.jobDataMap);
	cti.setStartTime(this.startTime);
	cti.setCronExpression(this.cronExpression);
	cti.setTimeZone(this.timeZone);
	cti.setCalendarName(this.calendarName);
	cti.setPriority(this.priority);
	cti.setMisfireInstruction(this.misfireInstruction);
	cti.setDescription(this.description);
	this.cronTrigger = cti;
}