我想要做的就是用一堆批處理文件(和參數)讀取一個文件,併爲每個條目創建一個石英作業。我知道我錯過了一些明顯的東西,但我似乎無法找到如何在谷歌的任何地方做到這一點。我發現的一切都表明,對於不能外部構建的每項工作,必須對新班級進行編碼。我似乎無法找到如何創建一個我可以傳入調度程序的類的實例。如何將作業對象實例傳遞給quartz調度程序
public class MyJob implements Job{
private String[] jobArgs = null;
public MyJob(String[] jobArgs){
this.jobArgs = jobArgs;
}
public void execute(JobExecutionContext arg0) throws JobExecutionException{
ExternalProcess ep - new ExternalProcess();
try{
ep.runExecutableCommand(jobargs);
}catch(Exception e){...}
}
}
public class JobScheduler {
...
List<String[]> jobArgList = loadJobListFromDisk();
List<MyJob> = new ArrayList<MyJob>();
for(String[] jobArgs : jobList){
MyJob myJob = new MyJob(jobArgs);
// Is it possible to pass in a reference to an instance somehow
// instead of letting the scheduler create the instance based on
// the class definition? I know this syntax doesn't work, but this
// is the general idea of what I'm trying to do.
JobDetail jobDetail = JobBuilder.newJob(myJob).withIdentity...
}
}