org.quartz.impl.triggers.AbstractTrigger Java Examples
The following examples show how to use
org.quartz.impl.triggers.AbstractTrigger.
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 | 4 votes |
public void addReminderJob(TaskReminder reminder,ProcessInstance processInstance,Task task) { JobKey jobKey=new JobKey(JOB_NAME_PREFIX+reminder.getId(),JOB_GROUP_PREFIX); try { if(scheduler.checkExists(jobKey)){ return; } AbstractTrigger<? extends Trigger> trigger=null; if(reminder.getType().equals(ReminderType.Once)){ SimpleTriggerImpl simpleTrigger=new SimpleTriggerImpl(); simpleTrigger.setRepeatCount(0); trigger=simpleTrigger; long executeTime=reminder.getStartDate().getTime()+10000; long now=(new Date()).getTime(); if(executeTime<=now){ return; } }else{ CronTriggerImpl cronTrigger=new CronTriggerImpl(); cronTrigger.setCronExpression(reminder.getCron()); trigger=cronTrigger; } trigger.setName("trigger_"+reminder.getId()); trigger.setStartTime(reminder.getStartDate()); ReminderJobDetail jobDetail=new ReminderJobDetail(); jobDetail.setJobClass(ReminderJob.class); ReminderHandler handler=(ReminderHandler)applicationContext.getBean(reminder.getReminderHandlerBean()); jobDetail.setReminderHandlerBean(handler); if(task==null){ task=taskService.getTask(reminder.getTaskId()); } jobDetail.setTask(task); jobDetail.setProcessInstance(processService.getProcessInstanceById(task.getProcessInstanceId())); jobDetail.setKey(jobKey); Calendar calendar=getCalendar(reminder,processInstance,task); if(calendar!=null){ String calendarName=REMINDER_CALENDAR_PREFIX+reminder.getId(); scheduler.addCalendar(calendarName, calendar,false, false); trigger.setCalendarName(calendarName); } scheduler.scheduleJob(jobDetail, trigger); } catch (Exception e) { throw new RuntimeException(e); } }