Package org.springframework.batch.core

Examples of org.springframework.batch.core.Job


  public Long startNextInstance(String jobName) throws NoSuchJobException, JobParametersNotFoundException,
  UnexpectedJobExecutionException, JobParametersInvalidException {

    logger.info("Locating parameters for next instance of job with name=" + jobName);

    Job job = jobRegistry.getJob(jobName);
    List<JobInstance> lastInstances = jobExplorer.getJobInstances(jobName, 0, 1);

    JobParametersIncrementer incrementer = job.getJobParametersIncrementer();
    if (incrementer == null) {
      throw new JobParametersNotFoundException("No job parameters incrementer found for job=" + jobName);
    }

    JobParameters parameters;
View Full Code Here


    }
    jobExecution.setStatus(BatchStatus.STOPPING);
    jobRepository.update(jobExecution);

    try {
      Job job = jobRegistry.getJob(jobExecution.getJobInstance().getJobName());
      if (job instanceof StepLocator) {//can only process as StepLocator is the only way to get the step object
        //get the current stepExecution
        for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
          if (stepExecution.getStatus().isRunning()) {
            try {
View Full Code Here

        public void run() {
          JsrJobContextFactoryBean factoryBean = null;
          try {
            factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME);
            factoryBean.setJobExecution(jobExecution);
            final Job job = batchContext.getBean(Job.class);

            if(!job.isRestartable()) {
              throw new JobRestartException("Job " + jobName + " is not restartable");
            }

            semaphore.release();
            // Initialization of the JobExecution for job level dependencies
            jobRegistry.register(job, jobExecution);
            job.execute(jobExecution);
            jobRegistry.remove(jobExecution);
          }
          catch (Exception e) {
            exceptionHolder.add(e);
          } finally {
View Full Code Here

        public void run() {
          JsrJobContextFactoryBean factoryBean = null;
          try {
            factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME);
            factoryBean.setJobExecution(jobExecution);
            final Job job = batchContext.getBean(Job.class);
            semaphore.release();
            // Initialization of the JobExecution for job level dependencies
            jobRegistry.register(job, jobExecution);
            job.execute(jobExecution);
            jobRegistry.remove(jobExecution);
          }
          catch (Exception e) {
            exceptionHolder.add(e);
          } finally {
View Full Code Here

    }
    jobExecution.setStatus(BatchStatus.STOPPING);
    jobRepository.update(jobExecution);

    try {
      Job job = jobRegistry.getJob(jobExecution.getId());
      if (job instanceof StepLocator) {//can only process as StepLocator is the only way to get the step object
        //get the current stepExecution
        for (org.springframework.batch.core.StepExecution stepExecution : jobExecution.getStepExecutions()) {
          if (stepExecution.getStatus().isRunning()) {
            try {
View Full Code Here

    JobParameters jobParameters = getJobParametersFromJobMap(jobDataMap);
    JobExecution jobExecution = null;
    try {
      // 放入defaultIncrementer要確保不會有重覆的Parameters出現
      jobParameters = defaultIncrementer.getNext(jobParameters);
      Job job = jobLocator.getJob(jobName);
      if (job.getJobParametersIncrementer() != null) {
        jobParameters = job.getJobParametersIncrementer().getNext(
            jobParameters);
      }
      jobExecution = jobLauncher.run(job, jobParameters);
      context.put(K_JobExecution, jobExecution);
      batchService.updateExecution(jobExecution.getId(),
View Full Code Here

  private void jobRegistryLoad(BatchJob job) {
    org.springframework.core.io.Resource resource = batchSrv
        .getJobResource(job);
    ApplicationContext context = createApplicationContextFactory(
        CapAppContext.getApplicationContext(), resource);
    Job j = context.getBean(job.getJobId(), Job.class);
    jobRegistry.unregister(j.getName());
    try {
      jobRegistry.register(new ReferenceJobFactory(j));
    } catch (DuplicateJobException e) {
      e.getMessage();
    }
View Full Code Here

  @Test
  public void testBuildWithStopAndRestart() throws Exception {
    SimpleJobBuilder builder = new JobBuilder("flow").repository(jobRepository).start(fails);
    builder.on("FAILED").stopAndRestart(step2);
    Job job = builder.build();
    job.execute(execution);
    assertEquals(BatchStatus.STOPPED, execution.getStatus());
    assertEquals(1, execution.getStepExecutions().size());
    execution = jobRepository.createJobExecution("flow", new JobParameters());
    job.execute(execution);
    assertEquals(BatchStatus.COMPLETED, execution.getStatus());
    assertEquals(1, execution.getStepExecutions().size());
    assertEquals("step2", execution.getStepExecutions().iterator().next().getStepName());
  }
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

public class InteralBeanStepScopeIntegrationTests {

  @Test
  public void testCommitIntervalJobParameter() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("/org/springframework/batch/core/scope/context/CommitIntervalJobParameter-context.xml");
    Job job = context.getBean(Job.class);
    JobLauncher launcher = context.getBean(JobLauncher.class);

    JobExecution execution = launcher.run(job, new JobParametersBuilder().addLong("commit.interval", 1l).toJobParameters());

    assertEquals(BatchStatus.COMPLETED, execution.getStatus());
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.