当前位置: 首页>>代码示例>>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;未经允许,请勿转载。