I am using Quartz scheduler in java web application.
My question is an extension to How to pass instance variables into Quartz job
I followed the Accepted answer in the above post & could pass instance variable to my quartz job. But after restarting the web server, the passed instance variable is not retained (i.e., it is null)
public class SimpleJob implements Job {
@Override
public void execute(JobExecutionContext context)
throws JobExecutionException {
SchedulerContext schedulerContext = null;
try {
schedulerContext = context.getScheduler().getContext();
} catch (SchedulerException e1) {
e1.printStackTrace();
}
ExternalInstance externalInstance =
(ExternalInstance) schedulerContext.get("ExternalInstance");
System.out.println(externalInstance); //Will print "null" after web server restart
float avg = externalInstance.calculateAvg();
}
}
How can I retain the "ExternalInstance" even after web server restart?
Thank you very much in advance.