當前位置: 首頁>>代碼示例>>Java>>正文


Java JobDetail.getKey方法代碼示例

本文整理匯總了Java中org.quartz.JobDetail.getKey方法的典型用法代碼示例。如果您正苦於以下問題:Java JobDetail.getKey方法的具體用法?Java JobDetail.getKey怎麽用?Java JobDetail.getKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.quartz.JobDetail的用法示例。


在下文中一共展示了JobDetail.getKey方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRunningJob

import org.quartz.JobDetail; //導入方法依賴的package包/類
/**
 * 所有正在運行的job
 * 
 * @return
 * @throws SchedulerException
 */
public List<ScheduleJob> getRunningJob() throws SchedulerException {
    Scheduler scheduler = schedulerFactoryBean.getScheduler();
    List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
    List<ScheduleJob> jobList = new ArrayList<ScheduleJob>(executingJobs.size());
    for (JobExecutionContext executingJob : executingJobs) {
        ScheduleJob job = new ScheduleJob();
        JobDetail jobDetail = executingJob.getJobDetail();
        JobKey jobKey = jobDetail.getKey();
        Trigger trigger = executingJob.getTrigger();
        job.setName(jobKey.getName());
        job.setGroup(jobKey.getGroup());
        job.setDescription("觸發器:" + trigger.getKey());
        Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
        job.setStatus(triggerState.name());
        if (trigger instanceof CronTrigger) {
            CronTrigger cronTrigger = (CronTrigger) trigger;
            String cronExpression = cronTrigger.getCronExpression();
            job.setCron(cronExpression);
        }
        jobList.add(job);
    }
    return jobList;
}
 
開發者ID:Zigin,項目名稱:MonitorPlatform,代碼行數:30,代碼來源:JobConfigService.java

示例2: getRunningJobList

import org.quartz.JobDetail; //導入方法依賴的package包/類
@Override
public List<ScheduleJobEntity> getRunningJobList() {
	List<ScheduleJobEntity> jobList = null;
	Scheduler scheduler = schedulerFactoryBean.getScheduler();
	try {
	List<JobExecutionContext> executingJobList = scheduler.getCurrentlyExecutingJobs();
	jobList = new ArrayList<>(executingJobList.size());
	for (JobExecutionContext executingJob : executingJobList) {
		ScheduleJobEntity scheduleJob = new ScheduleJobEntity();
		JobDetail jobDetail = executingJob.getJobDetail();
		JobKey jobKey = jobDetail.getKey();
		Trigger trigger = executingJob.getTrigger();
		this.wrapScheduleJob(scheduleJob, scheduler, jobKey, trigger);
		jobList.add(scheduleJob);
	}
	} catch (Exception e) {
		logger.error("獲取計劃任務列表失敗", e);
		throw new ServiceException("獲取計劃任務列表失敗", e);
	}
	return jobList;
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:22,代碼來源:ScheduleJobServiceImpl.java

示例3: equals

import org.quartz.JobDetail; //導入方法依賴的package包/類
@Override
public boolean equals(Object obj) {
    if (!(obj instanceof JobDetail)) {
        return false;
    }

    JobDetail other = (JobDetail) obj;

    if(other.getKey() == null || getKey() == null)
        return false;
    
    if (!other.getKey().equals(getKey())) {
        return false;
    }
        
    return true;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:JobDetailImpl.java

示例4: executeScheduleJob

import org.quartz.JobDetail; //導入方法依賴的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

示例5: scheduleJob

import org.quartz.JobDetail; //導入方法依賴的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(JobDetail jobDetail,
        Trigger trigger) throws SchedulerException {
    validateState();

    if (jobDetail == null) {
        throw new SchedulerException("JobDetail cannot be null");
    }
    
    if (trigger == null) {
        throw new SchedulerException("Trigger cannot be null");
    }
    
    if (jobDetail.getKey() == null) {
        throw new SchedulerException("Job's key cannot be null");
    }

    if (jobDetail.getJobClass() == null) {
        throw new SchedulerException("Job's class cannot be null");
    }
    
    OperableTrigger trig = (OperableTrigger)trigger;

    if (trigger.getJobKey() == null) {
        trig.setJobKey(jobDetail.getKey());
    } else if (!trigger.getJobKey().equals(jobDetail.getKey())) {
        throw new SchedulerException(
            "Trigger does not reference given job!");
    }

    trig.validate();

    Calendar cal = null;
    if (trigger.getCalendarName() != null) {
        cal = resources.getJobStore().retrieveCalendar(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().storeJobAndTrigger(jobDetail, trig);
    notifySchedulerListenersJobAdded(jobDetail);
    notifySchedulerThread(trigger.getNextFireTime().getTime());
    notifySchedulerListenersSchduled(trigger);

    return ft;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:66,代碼來源:QuartzScheduler.java

示例6: interrupt

import org.quartz.JobDetail; //導入方法依賴的package包/類
/**
 * Interrupt all instances of the identified InterruptableJob executing in 
 * this Scheduler instance.
 *  
 * <p>
 * This method is not cluster aware.  That is, it will only interrupt 
 * instances of the identified InterruptableJob currently executing in this 
 * Scheduler instance, not across the entire cluster.
 * </p>
 * 
 * @see org.quartz.core.RemotableQuartzScheduler#interrupt(JobKey)
 */
public boolean interrupt(JobKey jobKey) throws UnableToInterruptJobException {

    List<JobExecutionContext> jobs = getCurrentlyExecutingJobs();
    
    JobDetail jobDetail = null;
    Job job = null;
    
    boolean interrupted = false;
    
    for(JobExecutionContext jec : jobs) {
        jobDetail = jec.getJobDetail();
        if (jobKey.equals(jobDetail.getKey())) {
            job = jec.getJobInstance();
            if (job instanceof InterruptableJob) {
                ((InterruptableJob)job).interrupt();
                interrupted = true;
            } else {
                throw new UnableToInterruptJobException(
                        "Job " + jobDetail.getKey() +
                        " can not be interrupted, since it does not implement " +                        
                        InterruptableJob.class.getName());
            }
        }                        
    }
    
    return interrupted;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:40,代碼來源:QuartzScheduler.java

示例7: doSchedule

import org.quartz.JobDetail; //導入方法依賴的package包/類
protected EventSchedulerEntry doSchedule(Event event, Trigger trigger, boolean single) {
    lock.lock();
    try {
        JobDataMap data = new JobDataMap();
        EventSchedulerJobParameters parameters = new EventSchedulerJobParameters(this, event, single);
        data.put(KEY_PARAMETERS, parameters);

        //@formatter:off
        JobDetail job = newJob(EventSchedulerJob.class)
                .withIdentity(getNextEntryId(), getName())
                .setJobData(data)
                .build();
        //@formatter:on

        try {
            scheduler.scheduleJob(job, trigger);
        } catch (SchedulerException e) {
            throw SpongeUtils.wrapException(getName(), e);
        }

        EventSchedulerEntry entry = new QuartzEventSchedulerEntry(job.getKey(), event);
        parameters.setEntry(entry);

        logger.debug("Scheduling event: {}", event);

        return entry;
    } finally {
        lock.unlock();
    }
}
 
開發者ID:softelnet,項目名稱:sponge,代碼行數:31,代碼來源:QuartzEventScheduler.java

示例8: getRunningJobList

import org.quartz.JobDetail; //導入方法依賴的package包/類
public List<ScheduleJob> getRunningJobList() throws SchedulerException{  
    List<JobExecutionContext> executingJobList = scheduler.getCurrentlyExecutingJobs();  
    List<ScheduleJob> jobList = new ArrayList<>(executingJobList.size());  
    for(JobExecutionContext executingJob : executingJobList){  
        ScheduleJob scheduleJob = new ScheduleJob();  
        JobDetail jobDetail = executingJob.getJobDetail();  
        JobKey jobKey = jobDetail.getKey();  
        Trigger trigger = executingJob.getTrigger();  
        this.wrapScheduleJob(scheduleJob,scheduler,jobKey,trigger);  
        jobList.add(scheduleJob);  
    }  
    return jobList;  
}
 
開發者ID:jiwenxing,項目名稱:springboot-quartz,代碼行數:14,代碼來源:ScheduleJobService.java

示例9: JobWrapper

import org.quartz.JobDetail; //導入方法依賴的package包/類
JobWrapper(JobDetail jobDetail) {
    this.jobDetail = jobDetail;
    key = jobDetail.getKey();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:RAMJobStore.java


注:本文中的org.quartz.JobDetail.getKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。