Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobInstance


    this.jdbcTemplate = new JdbcTemplate(dataSource);
  }

  @Before
  public void onSetUpBeforeTransaction() throws Exception {
    StepExecution stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(12L,
        "testJob"), new JobParameters()));
    writer.beforeStep(stepExecution);
  }
View Full Code Here


    this.jdbcTemplate = new JdbcTemplate(dataSource);
  }

  @BeforeTransaction
  public void onSetUpBeforeTransaction() throws Exception {
    StepExecution stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(jobId,
        "testJob"), new JobParameters()));
    writer.beforeStep(stepExecution);
    writer.write(Arrays.asList("FOO", "BAR", "SPAM", "BUCKET"));
    reader.beforeStep(stepExecution);
  }
View Full Code Here

      Long id = rs.getLong(1);
      JobExecution jobExecution;
     
      JobParameters jobParameters = getJobParameters(id);

      JobInstance jobInstance = new JobInstance(rs.getLong(10), rs.getString(11));
      jobExecution = new JobExecution(jobInstance, jobParameters);
      jobExecution.setId(id);

      jobExecution.setStartTime(rs.getTimestamp(2));
      jobExecution.setEndTime(rs.getTimestamp(3));
View Full Code Here

  @RequestMapping(value = { "/jobs/{jobName}/{jobInstanceId}/executions", "/jobs/{jobName}/{jobInstanceId}" }, method = RequestMethod.GET)
  public String listForInstance(Model model, @PathVariable String jobName, @PathVariable long jobInstanceId,
      @ModelAttribute("date") Date date, Errors errors) {

    JobInstance jobInstance = null;
    try {
      jobInstance = jobService.getJobInstance(jobInstanceId);
      if (!jobInstance.getJobName().equals(jobName)) {
        errors.reject("wrong.job.name", new Object[] { jobInstanceId, jobInstance.getJobName(), jobName },
            "The JobInstance with id=" + jobInstanceId + " has the wrong name (" + jobInstance.getJobName()
            + " not " + jobName);
      }
    }
    catch (NoSuchJobInstanceException e) {
      errors.reject("no.such.job.instance", new Object[] { jobInstanceId }, "There is no such job instance ("
View Full Code Here

  }

  @Test
  public void testSimpleJob() throws Exception {

    JobInstance jobInstance = MetaDataInstanceFactory.createJobInstance("foo", 11L);
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution("foo", 11L, 123L);
    jobExecution.setEndTime(new Date());
    jobExecution.setStatus(BatchStatus.FAILED);

    jobExplorer.getJobInstances("foo", 0, 100);
View Full Code Here

  public void testSimpleJobNotFailed() throws Exception {

    thrown.expect(JobParametersNotFoundException.class);
    thrown.expectMessage("No failed or stopped execution");

    JobInstance jobInstance = MetaDataInstanceFactory.createJobInstance("foo", 11L);
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution("foo", 11L, 123L);
    jobExecution.setEndTime(new Date());
    jobExecution.setStatus(BatchStatus.COMPLETED);

    jobExplorer.getJobInstances("foo", 0, 100);
View Full Code Here

  public JobExecution restart(Long jobExecutionId) throws NoSuchJobExecutionException,
  JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException,
  NoSuchJobException, JobParametersInvalidException {

    JobExecution target = getJobExecution(jobExecutionId);
    JobInstance lastInstance = target.getJobInstance();

    Job job = jobLocator.getJob(lastInstance.getJobName());

    JobExecution jobExecution = jobLauncher.run(job, target.getJobParameters());

    if (jobExecution.isRunning()) {
      activeExecutions.add(jobExecution);
View Full Code Here

    return stepExecutionDao.countStepExecutions(jobName, stepName);
  }

  @Override
  public JobInstance getJobInstance(long jobInstanceId) throws NoSuchJobInstanceException {
    JobInstance jobInstance = jobInstanceDao.getJobInstance(jobInstanceId);
    if (jobInstance == null) {
      throw new NoSuchJobInstanceException("JobInstance with id=" + jobInstanceId + " does not exist");
    }
    return jobInstance;
  }
View Full Code Here

   * Test method for {@link SimpleJobService#getJobExecution(Long)}.
   */
  @Test
  public void testGetJobExecution() throws Exception {
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution(123L);
    JobInstance jobInstance = jobExecution.getJobInstance();
    jobExecution.setJobInstance(null);
    EasyMock.expect(jobExecutionDao.getJobExecution(123L)).andReturn(jobExecution);
    EasyMock.expect(jobInstanceDao.getJobInstance(jobExecution)).andReturn(jobInstance);
    EasyMock.expect(executionContextDao.getExecutionContext(jobExecution)).andReturn(new ExecutionContext());
    stepExecutionDao.addStepExecutions(jobExecution);
View Full Code Here

  }

  @Test
  public void testGetJobExecutionWithUnserializableExecutionContext() throws Exception {
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution(123L);
    JobInstance jobInstance = jobExecution.getJobInstance();
    jobExecution.setJobInstance(null);
    EasyMock.expect(jobExecutionDao.getJobExecution(123L)).andReturn(jobExecution);
    EasyMock.expect(jobInstanceDao.getJobInstance(jobExecution)).andReturn(jobInstance);
    EasyMock.expect(executionContextDao.getExecutionContext(jobExecution)).andThrow(
        new IllegalStateException("Planned"));
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.JobInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.