See this question right here, the OP has the solution to this in his question.
The jobListener
is a little bit different
@Override
public void beforeJob(JobExecution jobExecution) {
JobParameters jobParameters = jobExecution.getJobParameters();
//check params etc
if (!shouldExecute) {
jobExecution.stop();
jobExecution.setExitStatus(new ExitStatus("STOPPED", "Invalid state."));
return;
}
}