This should be really easy. I\'m using Quartz running under Apache Tomcat 6.0.18, and I have a jobs.xml file which sets up my scheduled job that runs every minute.
W
Slight variation to scaramouche's solution.
List<JobExecutionContext> jobs = jobExecutionContext.getScheduler().getCurrentlyExecutingJobs();
for (JobExecutionContext job : jobs) {
if (job.getTrigger().equals(jobExecutionContext.getTrigger()) && !job.getFireInstanceId().equals(jobExecutionContext.getFireInstanceId()) {
logger.info("There's another instance running, so leaving" + this);
return;
}
}
scaramouche's solution fails when there is a single instance used for all JobExecutions( returning the singleton using a custom JobFactory class, rather than calling newInstance() for each execution)