List of usage examples for org.springframework.batch.core JobInstance JobInstance
public JobInstance(Long id, String jobName)
From source file:org.springframework.batch.core.step.item.FaultTolerantStepFactoryBeanNonBufferingTests.java
@Before public void setUp() throws Exception { factory.setBeanName("stepName"); factory.setJobRepository(new JobRepositorySupport()); factory.setTransactionManager(new ResourcelessTransactionManager()); factory.setCommitInterval(2);/*from w w w .j a va 2s.c om*/ factory.setItemReader(reader); factory.setItemWriter(writer); Map<Class<? extends Throwable>, Boolean> skippableExceptions = new HashMap<Class<? extends Throwable>, Boolean>(); skippableExceptions.put(SkippableException.class, true); skippableExceptions.put(SkippableRuntimeException.class, true); factory.setSkippableExceptionClasses(skippableExceptions); factory.setSkipLimit(2); factory.setIsReaderTransactionalQueue(true); JobInstance jobInstance = new JobInstance(new Long(1), "skipJob"); jobExecution = new JobExecution(jobInstance, new JobParameters()); }
From source file:org.springframework.xd.dirt.rest.BatchJobsController.java
/** * Return a paged collection of job instances for a given job. * //www . j av a 2 s. c o m * @param jobName name of the batch job * @param startJobInstance start index for the job instance * @param pageSize page size for the list * @return collection of JobInstnaces by job name */ @RequestMapping(value = "/{jobName}/instances", method = RequestMethod.GET) @ResponseBody @ResponseStatus(HttpStatus.OK) public Collection<JobInstance> instancesForJob(@PathVariable String jobName, @RequestParam(defaultValue = "0") int startJobInstance, @RequestParam(defaultValue = "20") int pageSize) { String fullName = jobName + ".job"; try { Collection<JobInstance> jobInstances = jobService.listJobInstances(fullName, startJobInstance, pageSize); // need to pass simple name back to the client List<JobInstance> result = new ArrayList<JobInstance>(); for (JobInstance jobInstance : jobInstances) { JobInstance simpleInstance = new JobInstance(jobInstance.getId(), jobName); simpleInstance.setVersion(jobInstance.getVersion()); result.add(simpleInstance); } // TODO: Need to add the jobExecutions for each jobInstance return result; } catch (NoSuchJobException e) { throw new NoSuchBatchJobException(jobName); } }