org.quartz.InterruptableJob Java Examples
The following examples show how to use
org.quartz.InterruptableJob.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuartzScheduler.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example #2
Source File: JobExecutionContextWrapperBean.java From sakai with Educational Community License v2.0 | 6 votes |
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"; }
Example #3
Source File: JobExecutionContextWrapperBean.java From sakai with Educational Community License v2.0 | 6 votes |
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"; }
Example #4
Source File: QuartzScheduler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #5
Source File: SchedulerTool.java From sakai with Educational Community License v2.0 | 4 votes |
public boolean isJobKillable(JobDetail detail) { if (InterruptableJob.class.isAssignableFrom(detail.getJobClass())) { return true; } return false; }
Example #6
Source File: SchedulerTool.java From sakai with Educational Community License v2.0 | 4 votes |
public boolean isJobKillable(JobDetail detail) { if (InterruptableJob.class.isAssignableFrom(detail.getJobClass())) { return true; } return false; }
Example #7
Source File: UtilsTool.java From quartz-glass with Apache License 2.0 | 4 votes |
public boolean isInterruptible(JobDetail job) { return InterruptableJob.class.isAssignableFrom(job.getJobClass()); }