本文整理匯總了Java中org.quartz.Trigger.getKey方法的典型用法代碼示例。如果您正苦於以下問題:Java Trigger.getKey方法的具體用法?Java Trigger.getKey怎麽用?Java Trigger.getKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.quartz.Trigger
的用法示例。
在下文中一共展示了Trigger.getKey方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: scheduleJob
import org.quartz.Trigger; //導入方法依賴的package包/類
/**
* <p>
* Schedule the given <code>{@link org.quartz.Trigger}</code> with the
* <code>Job</code> identified by the <code>Trigger</code>'s settings.
* </p>
*
* @throws SchedulerException
* if the indicated Job does not exist, or the Trigger cannot be
* added to the Scheduler, or there is an internal Scheduler
* error.
*/
public Date scheduleJob(Trigger trigger)
throws SchedulerException {
validateState();
if (trigger == null) {
throw new SchedulerException("Trigger cannot be null");
}
OperableTrigger trig = (OperableTrigger)trigger;
trig.validate();
Calendar cal = null;
if (trigger.getCalendarName() != null) {
cal = resources.getJobStore().retrieveCalendar(trigger.getCalendarName());
if(cal == null) {
throw new SchedulerException(
"Calendar not found: " + trigger.getCalendarName());
}
}
Date ft = trig.computeFirstFireTime(cal);
if (ft == null) {
throw new SchedulerException(
"Based on configured schedule, the given trigger '" + trigger.getKey() + "' will never fire.");
}
resources.getJobStore().storeTrigger(trig, false);
notifySchedulerThread(trigger.getNextFireTime().getTime());
notifySchedulerListenersSchduled(trigger);
return ft;
}
示例2: executeScheduleJob
import org.quartz.Trigger; //導入方法依賴的package包/類
/**
* 執行計劃任務
* @param job
* @param trigger
* @return
* @throws SchedulerException
*/
public static ScheduleJobResult executeScheduleJob(JobDetail job, Trigger trigger) throws SchedulerException {
ScheduleJobResult scheduleJobResult = new ScheduleJobResult();
//判斷是否滿足計劃任務的創建條件
if(job.getKey() == null || trigger.getKey() == null || job.getJobDataMap() == null){
scheduleJobResult.setScheduleJobStatus(ScheduleJobStatus.FAILED);
//不滿足計劃任務的創建條件,返回scheduleJobResult值類
return scheduleJobResult;
}
scheduleJobResult.setJobDetail(job);
scheduleJobResult.setTrigger(trigger);
//開始分配計劃任務
Scheduler scheduler = SchedulerFactory.getScheduler();
//開始判斷是否存在相同的計劃任務
if(scheduler.checkExists(job.getKey())){
log.info("存在相同的計劃任務:{}",job.getKey());
scheduler.deleteJob(job.getKey());
scheduleJobResult.setJobKey(job.getKey());
scheduleJobResult.setTriggerKey(trigger.getKey());
scheduleJobResult.setScheduleJobStatus(ScheduleJobStatus.ISEXIST);
scheduler.scheduleJob(job,trigger);
scheduler.start();
}else{
scheduler.scheduleJob(job,trigger);
scheduler.start();
scheduleJobResult.setJobKey(job.getKey());
scheduleJobResult.setTriggerKey(trigger.getKey());
scheduleJobResult.setScheduleJobStatus(ScheduleJobStatus.SUCCESS);
}
//計劃任務分配成功
return scheduleJobResult;
}
示例3: compareTo
import org.quartz.Trigger; //導入方法依賴的package包/類
/**
* <p>
* Compare the next fire time of this <code>Trigger</code> to that of
* another by comparing their keys, or in other words, sorts them
* according to the natural (i.e. alphabetical) order of their keys.
* </p>
*/
public int compareTo(Trigger other) {
if(other.getKey() == null && getKey() == null)
return 0;
if(other.getKey() == null)
return -1;
if(getKey() == null)
return 1;
return getKey().compareTo(other.getKey());
}
示例4: equals
import org.quartz.Trigger; //導入方法依賴的package包/類
/**
* Trigger equality is based upon the equality of the TriggerKey.
*
* @return true if the key of this Trigger equals that of the given Trigger.
*/
@Override
public boolean equals(Object o) {
if(!(o instanceof Trigger))
return false;
Trigger other = (Trigger)o;
return !(other.getKey() == null || getKey() == null) && getKey().equals(other.getKey());
}