类org.quartz.InterruptableJob源码实例Demo

下面列出了怎么用org.quartz.InterruptableJob的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: QuartzScheduler.java
/**
 * Interrupt 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(String fireInstanceId) throws UnableToInterruptJobException {
    List<JobExecutionContext> jobs = getCurrentlyExecutingJobs();
    
    Job job = null;
    
    for(JobExecutionContext jec : jobs) {
        if (jec.getFireInstanceId().equals(fireInstanceId)) {
            job = jec.getJobInstance();
            if (job instanceof InterruptableJob) {
                ((InterruptableJob)job).interrupt();
                return true;
            } else {
                throw new UnableToInterruptJobException(
                    "Job " + jec.getJobDetail().getKey() +
                    " can not be interrupted, since it does not implement " +                        
                    InterruptableJob.class.getName());
            }
        }                        
    }
    
    return false;
}
 
源代码2 项目: sakai   文件: JobExecutionContextWrapperBean.java
public String processActionKill() {
	if (getIsKillable()) {
		InterruptableJob job = (InterruptableJob)jec.getJobInstance();
		try {
			job.interrupt();
		} catch (UnableToInterruptJobException e) {
			log.error(e.getMessage(), e);
		}
		FacesContext.getCurrentInstance().addMessage(null, 
				new FacesMessage(FacesMessage.SEVERITY_INFO, 
						parentTool.rb.getFormattedMessage("kill_message", 
								new String[] {jec.getJobDetail().getKey().getName()}), null));
	}
	
	return "runningJobs";
}
 
源代码3 项目: sakai   文件: JobExecutionContextWrapperBean.java
public String processActionKill() {
	if (getIsKillable()) {
		InterruptableJob job = (InterruptableJob)jec.getJobInstance();
		try {
			job.interrupt();
		} catch (UnableToInterruptJobException e) {
			log.error(e.getMessage(), e);
		}
		FacesContext.getCurrentInstance().addMessage(null, 
				new FacesMessage(FacesMessage.SEVERITY_INFO, 
						parentTool.rb.getFormattedMessage("kill_message", 
								new String[] {jec.getJobDetail().getKey().getName()}), null));
	}
	
	return "runningJobs";
}
 
源代码4 项目: lams   文件: QuartzScheduler.java
/**
 * 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;
}
 
源代码5 项目: sakai   文件: SchedulerTool.java
public boolean isJobKillable(JobDetail detail) {
 if (InterruptableJob.class.isAssignableFrom(detail.getJobClass())) {
  return true;
 }
 return false;
}
 
源代码6 项目: sakai   文件: SchedulerTool.java
public boolean isJobKillable(JobDetail detail) {
 if (InterruptableJob.class.isAssignableFrom(detail.getJobClass())) {
  return true;
 }
 return false;
}
 
源代码7 项目: quartz-glass   文件: UtilsTool.java
public boolean isInterruptible(JobDetail job) {
    return InterruptableJob.class.isAssignableFrom(job.getJobClass());
}
 
 类所在包
 类方法
 同包方法