当前位置: 首页>>代码示例>>Java>>正文


Java Trigger.getKey方法代码示例

本文整理汇总了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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:QuartzScheduler.java

示例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;
}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:39,代码来源:SchedulerUtil.java

示例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());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:AbstractTrigger.java

示例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());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:AbstractTrigger.java


注:本文中的org.quartz.Trigger.getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。