private JobParameters getNextJobParameters(Job job) throws JobParametersNotFoundException { String jobIdentifier = job.getName(); JobParameters jobParameters; List<JobInstance> lastInstances = jobExplorer.getJobInstances(jobIdentifier, 0, 1); JobParametersIncrementer incrementer = job.getJobParametersIncrementer(); if (incrementer == null) { throw new JobParametersNotFoundException( "No job parameters incrementer found for job=" + jobIdentifier); } if (lastInstances.isEmpty()) { jobParameters = incrementer.getNext(new JobParameters()); if (jobParameters == null) { throw new JobParametersNotFoundException( "No bootstrap parameters found from incrementer for job=" + jobIdentifier); } } else { jobParameters = incrementer.getNext(lastInstances.get(0).getJobParameters()); } return jobParameters; }
@Override public void runner() { // job runner log.info("RUNNER: PymkMain"); try { Job job = (Job) PymkMain.getContext().getBean("pymkJob"); JobParameters params = new JobParametersBuilder().addString("task", job.getName()).toJobParameters(); jobLauncher.run(job, params); } catch (Exception e) { e.printStackTrace(); } // TaskScheduler scheduler = PymkMain.getContext().getBean("scheduler", TaskScheduler.class); // scheduler.schedule(new Runnable() { // public void run() { // System.out.println(new Date()); // } // }, new Date()); // PymkDbSyncMain r1 = PymkMain.getContext().getBean("pymkDbSyncMain", PymkDbSyncMain.class); // r1.runner(); // AddressBookMain r2 = PymkMain.getContext().getBean("addressBookMain", AddressBookMain.class); // r2.runner(); }