我想要做的是读取带有一堆批处理文件(和参数)的文件,并为每个条目创建一个石英作业。我知道我遗漏了一些明显的东西,但我似乎无法在谷歌的任何地方找到如何做到这一点。我发现的一切都表明,必须为每个无法从外部构建的工作编写一个新类。我似乎找不到如何创建可以传递给调度程序的类的实例。
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...
}
}