Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobInstance


    Assert.state(getJobInstance(jobName, jobParameters) == null,
        "JobInstance must not already exist");

    Long jobId = jobIncrementer.nextLongValue();

    JobInstance jobInstance = new JobInstance(jobId, jobName);
    jobInstance.incrementVersion();

    Object[] parameters = new Object[] { jobId, jobName,
        jobKeyGenerator.generateKey(jobParameters), jobInstance.getVersion() };
    getJdbcTemplate().update(
        getQuery(CREATE_JOB_INSTANCE),
        parameters,
        new int[] { Types.BIGINT, Types.VARCHAR, Types.VARCHAR,
          Types.INTEGER });
View Full Code Here


    public JobInstanceRowMapper() {
    }

    @Override
    public JobInstance mapRow(ResultSet rs, int rowNum) throws SQLException {
      JobInstance jobInstance = new JobInstance(rs.getLong(1), rs.getString(2));
      // should always be at version=0 because they never get updated
      jobInstance.incrementVersion();
      return jobInstance;
    }
View Full Code Here

  @Override
  protected void setUp() throws Exception {

    JobParameters jobParameters = new JobParametersBuilder().addLong("commit.interval", 2L).toJobParameters();
    jobInstance = new JobInstance(new Long(0), "testJob");
    JobExecution jobExecution = new JobExecution(jobInstance, jobParameters);
    Step step = new StepSupport("bar");
    stepExecution = jobExecution.createStepExecution(step.getName());
    policy.beforeStep(stepExecution);
View Full Code Here

    return result;
  }

  protected boolean getStartable(StepExecution stepExecution, ExecutionContext context) throws JobExecutionException {

    JobInstance jobInstance = stepExecution.getJobExecution().getJobInstance();
    String stepName = stepExecution.getStepName();
    StepExecution lastStepExecution = jobRepository.getLastStepExecution(jobInstance, stepName);

    boolean isRestart = (lastStepExecution != null && lastStepExecution.getStatus() != BatchStatus.COMPLETED);
View Full Code Here

    jsrJobOperator.getJobExecutions(jobInstance);
  }

  @Test
  public void testGetJobInstanceRoseyScenario() {
    JobInstance instance = new JobInstance(1L, "my job");
    JobExecution execution = new JobExecution(5L);
    execution.setJobInstance(instance);

    when(jobExplorer.getJobExecution(5L)).thenReturn(execution);
    when(jobExplorer.getJobInstance(1L)).thenReturn(instance);
View Full Code Here

    assertEquals("my job", jobInstance.getJobName());
  }

  @Test(expected=NoSuchJobExecutionException.class)
  public void testGetJobInstanceNoExecution() {
    JobInstance instance = new JobInstance(1L, "my job");
    JobExecution execution = new JobExecution(5L);
    execution.setJobInstance(instance);

    jsrJobOperator.getJobInstance(5L);
  }
View Full Code Here

  }

  @Test
  public void testGetJobInstancesRoseyScenario() {
    List<JobInstance> instances = new ArrayList<JobInstance>();
    instances.add(new JobInstance(1L, "myJob"));
    instances.add(new JobInstance(2L, "myJob"));
    instances.add(new JobInstance(3L, "myJob"));

    when(jobExplorer.getJobInstances("myJob", 0, 3)).thenReturn(instances);

    List<javax.batch.runtime.JobInstance> jobInstances = jsrJobOperator.getJobInstances("myJob", 0, 3);
View Full Code Here

    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());
  }
View Full Code Here

  }

  @Test
  public void testStop() throws Throwable {
    String[] args = new String[] { jobPath, "-stop", jobName };
    StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(3L, jobName));
    CommandLineJobRunner.main(args);
    assertEquals(0, StubSystemExiter.status);
  }
View Full Code Here

  }

  @Test
  public void testStopFailed() throws Throwable {
    String[] args = new String[] { jobPath, "-stop", jobName };
    StubJobExplorer.jobInstances = Arrays.asList(new JobInstance(0L, jobName));
    CommandLineJobRunner.main(args);
    assertEquals(1, StubSystemExiter.status);
  }
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.