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


Java Trigger.setJobName方法代码示例

本文整理汇总了Java中org.quartz.Trigger.setJobName方法的典型用法代码示例。如果您正苦于以下问题:Java Trigger.setJobName方法的具体用法?Java Trigger.setJobName怎么用?Java Trigger.setJobName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.Trigger的用法示例。


在下文中一共展示了Trigger.setJobName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTrigger

import org.quartz.Trigger; //导入方法依赖的package包/类
/**
 * Build the cron trigger
 * 
 * @return The trigger
 * @throws Exception
 */
public Trigger getTrigger() throws Exception
{
    Trigger trigger = new CronTrigger(getBeanName(), Scheduler.DEFAULT_GROUP, getCronExpression());
    if (this.startDelay > 0)
    {
        trigger.setStartTime(new Date(System.currentTimeMillis() + this.startDelay));
    }
    JobDetail jd = super.getJobDetail();
    if (jd != null)
    {
        String jobName = super.getJobDetail().getKey().getName();
        if (jobName != null && !jobName.isEmpty())
        {
            trigger.setJobName(jobName);
        }
        String jobGroup = super.getJobDetail().getKey().getGroup();
        if (jobGroup != null && !jobGroup.isEmpty())
        {
            trigger.setJobGroup(jobGroup);
        }
    }
    return trigger;
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:30,代码来源:CronTriggerBean.java

示例2: scheduleJob

import org.quartz.Trigger; //导入方法依赖的package包/类
/**
 * <p>
 * Add the <code>{@link org.quartz.Job}</code> identified by the given
 * <code>{@link org.quartz.JobDetail}</code> to the Scheduler, and
 * associate the given <code>{@link org.quartz.Trigger}</code> with it.
 * </p>
 * 
 * <p>
 * If the given Trigger does not reference any <code>Job</code>, then it
 * will be set to reference the Job passed with it into this method.
 * </p>
 * 
 * @throws SchedulerException
 *           if the Job or Trigger cannot be added to the Scheduler, or
 *           there is an internal Scheduler error.
 */
public Date scheduleJob(SchedulingContext ctxt, JobDetail jobDetail,
        Trigger trigger) throws SchedulerException {
    validateState();

    if (jobDetail == null) {
        throw new SchedulerException("JobDetail cannot be null",
                SchedulerException.ERR_CLIENT_ERROR);
    }
    
    if (trigger == null) {
        throw new SchedulerException("Trigger cannot be null",
                SchedulerException.ERR_CLIENT_ERROR);
    }
    
    jobDetail.validate();

    if (trigger.getJobName() == null) {
        trigger.setJobName(jobDetail.getName());
        trigger.setJobGroup(jobDetail.getGroup());
    } else if (trigger.getJobName() != null
            && !trigger.getJobName().equals(jobDetail.getName())) {
        throw new SchedulerException(
            "Trigger does not reference given job!",
            SchedulerException.ERR_CLIENT_ERROR);
    } else if (trigger.getJobGroup() != null
            && !trigger.getJobGroup().equals(jobDetail.getGroup())) {
        throw new SchedulerException(
            "Trigger does not reference given job!",
            SchedulerException.ERR_CLIENT_ERROR);
    }

    trigger.validate();

    Calendar cal = null;
    if (trigger.getCalendarName() != null) {
        cal = resources.getJobStore().retrieveCalendar(ctxt,
                trigger.getCalendarName());
    }
    Date ft = trigger.computeFirstFireTime(cal);

    if (ft == null) {
        throw new SchedulerException(
                "Based on configured schedule, the given trigger will never fire.",
                SchedulerException.ERR_CLIENT_ERROR);
    }

    resources.getJobStore().storeJobAndTrigger(ctxt, jobDetail, trigger);
    notifySchedulerListenersJobAdded(jobDetail);
    notifySchedulerThread(trigger.getNextFireTime().getTime());
    notifySchedulerListenersSchduled(trigger);

    return ft;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:70,代码来源:QuartzScheduler.java


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