Package org.springframework.batch.core.launch

Examples of org.springframework.batch.core.launch.JobLauncher.run()


    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


  }

  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

    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();
  }

  @SuppressWarnings("unchecked")
View Full Code Here

        log.info("Batch Tweet Influencers Hive Job Running");
        context.registerShutdownHook();

        JobLauncher jobLauncher = context.getBean(JobLauncher.class);
        Job job = context.getBean(Job.class);
        jobLauncher.run(job, new JobParameters());

    }
}
View Full Code Here

    final Message<JobLaunchRequest> message = MessageBuilder.withPayload(new JobLaunchRequest(new JobSupport("testJob"),
    new JobParameters())).build();

    final JobLauncher jobLauncher = mock(JobLauncher.class);
    when(jobLauncher.run(any(Job.class), any(JobParameters.class)))
      .thenThrow(new JobParametersInvalidException("This is a JobExecutionException."));

    JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(jobLauncher);

    try {
View Full Code Here

    final Message<JobLaunchRequest> message = MessageBuilder.withPayload(new JobLaunchRequest(new JobSupport("testJob"),
    new JobParameters())).build();

    final JobLauncher jobLauncher = mock(JobLauncher.class);
    when(jobLauncher.run(any(Job.class), any(JobParameters.class)))
      .thenThrow(new JobParametersInvalidException("This is a JobExecutionException."));

    JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(jobLauncher);

    try {
View Full Code Here

        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)
        .toJobParameters());

    Thread.sleep(1000);
View Full Code Here

    assertTrue("Should only be one StepExecution but got: " + numStepExecutions, numStepExecutions == 1);
    assertTrue("Step name for execution should be step1 but got: " + stepName, "step1".equals(stepName));
    assertTrue("Step execution status should be STOPPED but got: " + stepExecutionStatus, stepExecutionStatus.equals(BatchStatus.STOPPED));
    assertTrue("Job execution status should be STOPPED but got:" + jobExecutionStatus, jobExecutionStatus.equals(BatchStatus.STOPPED));

    JobExecution restartJobExecution = jobLauncher.run(job, new JobParametersBuilder()
        .addLong("test", 1L)
        .toJobParameters());

    while(restartJobExecution.isRunning()) {
      // wait for async launched job to complete execution
View Full Code Here

    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());
    assertEquals(stepExecutionCount, execution.getStepExecutions().size());
    JobExplorer jobExplorer = context.getBean(JobExplorer.class);
View Full Code Here

    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(jobName, Job.class);
    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());
    assertEquals(stepExecutionCount, execution.getStepExecutions().size());
    context.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.