Package org.springframework.batch.core.launch

Examples of org.springframework.batch.core.launch.JobLauncher


  public static List<JobExecution> startJobs(ListableBeanFactory bf) {
    return startJobs(bf, new JobParameters());
  }

  public static List<JobExecution> startJobs(ListableBeanFactory bf, JobParameters params) {
    JobLauncher launcher = bf.getBean(JobLauncher.class);
    Map<String, Job> jobs = bf.getBeansOfType(Job.class);

    List<JobExecution> executions = new ArrayList<JobExecution>(jobs.size());
    for (Map.Entry<String, Job> entry : jobs.entrySet()) {
      RuntimeException e = null;
      try {
        JobExecution jobExec = launcher.run(entry.getValue(), params);
        executions.add(jobExec);
        if (jobExec.getStatus().equals(BatchStatus.FAILED)) {
          e = new BeanInitializationException("Failed executing job " + entry.getKey());
        }
      } catch (Exception ex) {
View Full Code Here


    return executions;
  }

  public static JobExecution startJob(ListableBeanFactory lbf, String jobName) throws Exception {
    Job job = lbf.getBean(jobName, Job.class);
    JobLauncher launcher = lbf.getBean(JobLauncher.class);
    return launcher.run(job, new JobParameters());
  }
View Full Code Here

  }

  @Test
  public void testWithinJob() throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/org/springframework/data/hadoop/fs/HdfsItemWriterTest-context.xml");
    JobLauncher launcher = context.getBean(JobLauncher.class);
    Job job = context.getBean(Job.class);

    JobParameters jobParameters = new JobParametersBuilder().toJobParameters();

    JobExecution execution = launcher.run(job, jobParameters);
    assertTrue("status was: " + execution.getStatus(), execution.getStatus() == BatchStatus.COMPLETED);
    context.close();
  }
View Full Code Here

        // When
        template.sendBody("direct:launcherRefTest", "Start the job, please.");

        // Then
        SpringBatchEndpoint batchEndpoint = context().getEndpoint("spring-batch:mockJob?jobLauncherRef=alternativeJobLauncher", SpringBatchEndpoint.class);
        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
        assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
    }
View Full Code Here

        // When
        camelContext.start();

        // Then
        SpringBatchEndpoint batchEndpoint = camelContext.getEndpoint("spring-batch:mockJob", SpringBatchEndpoint.class);
        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
        assertSame(jobLauncher, batchEndpointJobLauncher);
    }
View Full Code Here

            }
        });

        // Then
        SpringBatchEndpoint batchEndpoint = context().getEndpoint("customBatchComponent:mockJob", SpringBatchEndpoint.class);
        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
        assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
    }
View Full Code Here

        }
    }

    private JobLauncher resolveJobLauncher() {
        if (jobLauncherRef != null) {
            JobLauncher jobLauncher = getCamelContext().getRegistry().lookup(jobLauncherRef, JobLauncher.class);
            if (jobLauncher == null) {
                throw new IllegalStateException(String.format("No JobLauncher named %s found in the registry.", jobLauncherRef));
            }
            return jobLauncher;
        }
View Full Code Here

        // When
        template.sendBody("direct:launcherRefTest", "Start the job, please.");

        // Then
        SpringBatchEndpoint batchEndpoint = context().getEndpoint("spring-batch:mockJob?jobLauncherRef=alternativeJobLauncher", SpringBatchEndpoint.class);
        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
        assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
    }
View Full Code Here

        // When
        camelContext.start();

        // Then
        SpringBatchEndpoint batchEndpoint = camelContext.getEndpoint("spring-batch:mockJob", SpringBatchEndpoint.class);
        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
        assertSame(jobLauncher, batchEndpointJobLauncher);
    }
View Full Code Here

            }
        });

        // Then
        SpringBatchEndpoint batchEndpoint = context().getEndpoint("customBatchComponent:mockJob", SpringBatchEndpoint.class);
        JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
        assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
    }
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.launch.JobLauncher

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.