Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobExecution


  @RequestMapping(value = "/jobs/executions/{jobExecutionId}", method = RequestMethod.GET)
  public String detail(Model model, @PathVariable Long jobExecutionId, @ModelAttribute("date") Date date,
      Errors errors) {

    try {
      JobExecution jobExecution = jobService.getJobExecution(jobExecutionId);
      model.addAttribute(new JobExecutionInfo(jobExecution, timeZone));
      String jobName = jobExecution.getJobInstance().getJobName();
      Collection<String> stepNames = new HashSet<String>(jobService.getStepNamesForJob(jobName));
      Collection<StepExecution> stepExecutions = new ArrayList<StepExecution>(jobExecution.getStepExecutions());
      Collection<StepExecutionInfo> stepExecutionInfos = new ArrayList<StepExecutionInfo>();

      for (String name : stepNames) {
        boolean found = false;
        for (Iterator<StepExecution> iterator = stepExecutions.iterator(); iterator.hasNext();) {
View Full Code Here


  @RequestMapping(value = "/jobs/executions/{jobExecutionId}/execution-context", method = RequestMethod.GET)
  public String getExecutionContext(Model model, @PathVariable Long jobExecutionId, @ModelAttribute("date") Date date,
                    Errors errors) {
    try {
      JobExecution jobExecution = jobService.getJobExecution(jobExecutionId);
      Map<String, Object> executionMap = new HashMap<String, Object>();

      for (Map.Entry<String, Object> entry : jobExecution.getExecutionContext().entrySet()) {
        executionMap.put(entry.getKey(), entry.getValue());
      }

      model.addAttribute("jobExecutionContext", objectMapper.writeValueAsString(executionMap));
      model.addAttribute("jobExecutionId", jobExecutionId);
View Full Code Here

    String params = launchRequest.jobParameters;

    JobParameters jobParameters = jobParametersExtractor.fromString(params);

    try {
      JobExecution jobExecution = jobService.launch(jobName, jobParameters);
      model.addAttribute(new JobExecutionInfo(jobExecution, timeZone));
    }
    catch (NoSuchJobException e) {
      errors.reject("no.such.job", new Object[] { jobName }, "No such job: " + jobName);
    }
View Full Code Here

  }

  @Override
  public StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId)
      throws NoSuchJobExecutionException, NoSuchStepExecutionException {
    JobExecution jobExecution = getJobExecution(jobExecutionId);
    StepExecution stepExecution = stepExecutionDao.getStepExecution(jobExecution, stepExecutionId);
    if (stepExecution == null) {
      throw new NoSuchStepExecutionException("There is no StepExecution with jobExecutionId=" + jobExecutionId
          + " and id=" + stepExecutionId);
    }
View Full Code Here

   */
  @Scheduled(fixedDelay = 60000)
  public void removeInactiveExecutions() {

    for (Iterator<JobExecution> iterator = activeExecutions.iterator(); iterator.hasNext();) {
      JobExecution jobExecution = iterator.next();
      try {
        jobExecution = getJobExecution(jobExecution.getId());
      }
      catch (NoSuchJobExecutionException e) {
        logger.error("Unexpected exception loading JobExecution", e);
      }
      if (!jobExecution.isRunning()) {
        iterator.remove();
      }
    }

  }
View Full Code Here

  @Qualifier("jobs/executions.rss")
  private View view;

  @Test
  public void testLaunchedJobExecutions() throws Exception {
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution();
    jobExecution.setEndTime(new Date());
    model.put("baseUrl", "http://localhost:8080/springsource");
    model.put("jobExecutions", Arrays.asList(new JobExecutionInfo(jobExecution, TimeZone.getTimeZone("GMT"))));
    model.put("currentTime", new Date());
    view.render(model, request, response);
    String content = response.getContentAsString();
View Full Code Here

    assertTrue(content.contains("id=12"));
  }

  @Test
  public void testUnfinishedJobExecutions() throws Exception {
    JobExecution jobExecution1 = MetaDataInstanceFactory.createJobExecution();
    JobExecution jobExecution2 = MetaDataInstanceFactory.createJobExecution(13L);
    jobExecution2.setEndTime(new Date());
    model.put("baseUrl", "http://localhost:8080/springsource");
    model.put("jobExecutions", Arrays.asList(new JobExecutionInfo(jobExecution1,
        TimeZone.getTimeZone("GMT")), new JobExecutionInfo(jobExecution2,
            TimeZone.getTimeZone("GMT"))));
    model.put("currentTime", new Date());
View Full Code Here

  @Qualifier("jobs/execution.json")
  private View view;

  @Test
  public void testLaunchViewWithJobExecutionInfo() throws Exception {
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecutionWithStepExecutions(123L, Arrays.asList(
        "foo", "bar"));
    model.put("jobExecutionInfo", new JobExecutionInfo(jobExecution, TimeZone.getDefault()));
    model.put("baseUrl", "http://localhost:8080/springsource");
    view.render(model, request, response);
    String content = response.getContentAsString();
View Full Code Here

        .get("jobExecution.stepExecutions.bar.resource"));
  }

  @Test
  public void testLaunchViewWithJobAndStepExecutionInfo() throws Exception {
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecutionWithStepExecutions(123L, Arrays.asList(
        "foo", "bar"));
    model.put("jobExecutionInfo", new JobExecutionInfo(jobExecution, TimeZone.getDefault()));
    model.put("stepExecutionInfos", Arrays.asList(new StepExecutionInfo(jobExecution.getStepExecutions().iterator()
        .next(), TimeZone.getTimeZone("GMT")), new StepExecutionInfo("job", 123L, "bar", TimeZone.getTimeZone("GMT"))));
    model.put("baseUrl", "http://localhost:8080/springsource");
    view.render(model, request, response);
    String content = response.getContentAsString();
    // System.err.println(content);
View Full Code Here

    exporter.getStepCount();
  }
 
  @Test
  public void testMBeanCreation() throws Exception {
    JobExecution jobExecution = jobRepository.createJobExecution("foo", new JobParameters());
    jobRepository.add(jobExecution.createStepExecution("step"));
    init();
    // System.err.println(server.queryNames(new ObjectName("*:type=JobExecution,name=foo,*"), null));
    assertEquals(2, server.queryNames(new ObjectName("*:type=JobExecution,name=foo,*"), null).size());
    assertEquals(1, server.queryNames(new ObjectName("*:type=JobExecution,name=foo,step=step,*"), null).size());
  }
View Full Code Here

TOP

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

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.