/**
  * Check if the scheduler is stopped.
  *
  * @throws JobSchedulerException thrown if the scheduler status cannot be checked
  */
 public boolean isStopped() throws JobSchedulerException {
   try {
     return scheduler.isShutdown();
   } catch (SchedulerException e) {
     throw new JobSchedulerException(
         "An exception occurred during checking if the scheduler is stopped", e);
   }
 }
示例#2
0
  public static void startJob(String jobName, Job job, String time)
      throws SchedulerException, ParseException {
    Scheduler sched = sf.getScheduler();

    JobDetail jobDetail = new JobDetail();
    jobDetail.setName(jobName);
    jobDetail.setGroup(JOB_GROUP_NAME);
    jobDetail.setJobClass(job.getClass());

    CronTrigger trigger = new CronTrigger(jobName, TRIGGER_GROUP_NAME);
    trigger.setCronExpression(time);
    sched.scheduleJob(jobDetail, trigger);

    if (!sched.isShutdown()) {
      sched.start();
    }
  }