public boolean runJob(Properties jobProps, JobListener jobListener, JobLauncher jobLauncher)
      throws JobException {
    Preconditions.checkArgument(jobProps.containsKey(ConfigurationKeys.JOB_NAME_KEY),
        "A job must have a job name specified by job.name");
    String jobName = jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY);

    // Check if the job has been disabled
    boolean disabled = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_DISABLED_KEY, "false"));
    if (disabled) {
      LOG.info("Skipping disabled job " + jobName);
      return false;
    }

    // Launch the job
    try (Closer closer = Closer.create()) {
      closer.register(jobLauncher).launchJob(jobListener);
      boolean runOnce = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "false"));
      boolean isEarlyStopped = jobLauncher.isEarlyStopped();
      if (!isEarlyStopped && runOnce && this.scheduledJobs.containsKey(jobName)) {
        this.scheduler.getScheduler().deleteJob(this.scheduledJobs.remove(jobName));
      }

      return isEarlyStopped;

    } catch (Throwable t) {
      throw new JobException("Failed to launch and run job " + jobName, t);
    }
  }
public boolean runJob ( Properties jobProps , JobListener jobListener , JobLauncher jobLauncher ) throws JobException { Preconditions . checkArgument ( jobProps . containsKey ( ConfigurationKeys . JOB_NAME_KEY ) , "A job must have a job name specified by job.name" ) ; String jobName = jobProps . getProperty ( ConfigurationKeys . JOB_NAME_KEY ) ; boolean disabled = Boolean . valueOf ( jobProps . getProperty ( ConfigurationKeys . JOB_DISABLED_KEY , "false" ) ) ; if ( disabled ) { LOG . info ( "Skipping disabled job " + jobName ) ; return false ; } try ( Closer closer = Closer . create ( ) ) { closer . register ( jobLauncher ) . launchJob ( jobListener ) ; boolean runOnce = Boolean . valueOf ( jobProps . getProperty ( ConfigurationKeys . JOB_RUN_ONCE_KEY , "false" ) ) ; boolean isEarlyStopped = jobLauncher . isEarlyStopped ( ) ; if ( ! isEarlyStopped && runOnce && this . scheduledJobs . containsKey ( jobName ) ) { this . scheduler . getScheduler ( ) . deleteJob ( this . scheduledJobs . remove ( jobName ) ) ; } return isEarlyStopped ; } catch ( Throwable t ) { throw new JobException ( "Failed to launch and run job " + jobName , t ) ; } }
Run a job.

<p>
This method runs the job immediately without going through the Quartz scheduler.
This is particularly useful for testing.
</p>

<p>
This method does what {@link #runJob(Properties, JobListener)} does, and additionally it allows
the caller to pass in a {@link JobLauncher} instance used to launch the job to run.
</p>

@param jobProps Job configuration properties
@param jobListener {@link JobListener} used for callback, can be <em>null</em> if no callback is needed.
@param jobLauncher a {@link JobLauncher} object used to launch the job to run
@return If current job is a stop-early job based on {@link Source#isEarlyStopped()}
@throws JobException when there is anything wrong with running the job