Package org.springframework.batch.core

Examples of org.springframework.batch.core.Job


    context.refresh();

    ClassPathXmlApplicationContext child = new ClassPathXmlApplicationContext(
        new String[] { "classpath:/test-job-context.xml" }, parent);
    Job job = child.getBean(Job.class);
    final JobExecution jobExecution = parent.getBean(JobLauncher.class).run(job, new JobParameters());

    new DirectPoller<BatchStatus>(100).poll(new Callable<BatchStatus>() {
      public BatchStatus call() throws Exception {
        BatchStatus status = jobExecution.getStatus();
View Full Code Here


    if (jobName != null) {
      missingStepNames.addAll(stepExecutionDao.findStepNamesForJobExecution(jobName, "*:partition*"));
      logger.debug("Found step executions in repository: " + missingStepNames);
    }

    Job job = null;
    try {
      job = jobLocator.getJob(jobName);
    }
    catch (NoSuchJobException e) {
      // expected
View Full Code Here

  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

  @Override
  public JobExecution launch(String jobName, JobParameters jobParameters) throws NoSuchJobException,
  JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException,
  JobParametersInvalidException {

    Job job = jobLocator.getJob(jobName);

    JobExecution lastJobExecution = jobRepository.getLastJobExecution(jobName, jobParameters);
    boolean restart = false;
    if (lastJobExecution != null) {
      BatchStatus status = lastJobExecution.getStatus();
      if (status.isUnsuccessful() && status!=BatchStatus.ABANDONED) {
        restart = true;
      }
    }

    if (job.getJobParametersIncrementer() != null && !restart) {
      jobParameters = job.getJobParametersIncrementer().getNext(jobParameters);
    }

    JobExecution jobExecution = jobLauncher.run(job, jobParameters);

    if (jobExecution.isRunning()) {
View Full Code Here

  }

  @Override
  public Collection<String> getStepNamesForJob(String jobName) throws NoSuchJobException {
    try {
      Job job = jobLocator.getJob(jobName);
      if (job instanceof StepLocator) {
        return ((StepLocator) job).getStepNames();
      }
    }
    catch (NoSuchJobException e) {
View Full Code Here

    this.jobLauncher = jobLauncher;
  }

  @ServiceActivator
  public JobExecution launch(JobLaunchRequest request) throws JobExecutionException {
    Job job = request.getJob();
    JobParameters jobParameters = request.getJobParameters();

    return jobLauncher.run(job, jobParameters);
  }
View Full Code Here

  @Test
  public void testStepNames() throws Exception {
    for (String name : stepLocators.keySet()) {
      StepLocator stepLocator = stepLocators.get(name);
      Collection<String> stepNames = stepLocator.getStepNames();
      Job job = (Job) context.getBean(name);
      String jobName = job.getName();
      assertTrue("Job has no steps: "+jobName, !stepNames.isEmpty());
      for (String registeredName : stepNames) {
        String stepName = stepLocator.getStep(registeredName).getName();
        assertEquals("Step name not equal to registered value: " + stepName + "!=" + registeredName + ", " + jobName,
            stepName, registeredName);
View Full Code Here

public class OptimisticLockingFailureTests {
  @Test
  public void testAsyncStopOfStartingJob() throws Exception {
    ApplicationContext applicationContext =
        new ClassPathXmlApplicationContext("org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests-context.xml");
    Job job = applicationContext.getBean(Job.class);
    JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);
    JobOperator jobOperator = applicationContext.getBean(JobOperator.class);

    JobExecution jobExecution = jobLauncher.run(job, new JobParametersBuilder()
        .addLong("test", 1L)
View Full Code Here

    Class<?>[] configs = new Class<?>[config.length + 1];
    System.arraycopy(config, 0, configs, 1, config.length);
    configs[0] = DataSourceConfiguration.class;
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(configs);
    Job job = jobName == null ? context.getBean(Job.class) : context.getBean(JobLocator.class).getJob(jobName);
    JobLauncher jobLauncher = context.getBean(JobLauncher.class);
    execution = jobLauncher
        .run(job, new JobParametersBuilder().addLong("run.id", (long) (Math.random() * Long.MAX_VALUE))
            .toJobParameters());
    assertEquals(status, execution.getStatus());
View Full Code Here

    Collection<String> names = registry.getJobNames();
    assertEquals(2, names.size());
    assertTrue(names.contains("test-job"));
    assertTrue(names.contains("test-job2"));

    Job job = registry.getJob("test-job");
    assertEquals("test-job", job.getName());
    job = registry.getJob("test-job2");
    assertEquals("test-job2", job.getName());
  }
View Full Code Here

TOP

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

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.