在下面的代码中,dataMigrator.loadProperties(); 和 dataMigrator.init(); 做了一些初始化,我不想在下一次执行作业时再做这样的初始化,因为它每 10 分钟运行一次。DataMigrator 的某些对象的初始化应该只进行一次。能做到吗?
import org.quartz.StatefulJob;
public class DataMigratorJob implements StatefulJob
{
void init(DataMigrator dataMigrator) {
dataMigrator.loadProperties();
dataMigrator.init(); //dataMigrator basic required objects will be initialized
}
public void execute(JobExecutionContext context)
throws JobExecutionException {
DataMigrator dataMigrator = new DataMigrator();
init(dataMigrator);
dataMigrator.run();
System.out.println("Hello Quartz!"+ new Date());
}
}