Package org.springframework.batch.core

Examples of org.springframework.batch.core.Job


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

  }
View Full Code Here


   */
  @Test
  public void testCreateRepository() throws Exception {
    tested.afterPropertiesSet();
    JobRepository repository = tested.getObject();
    Job job = new JobSupport("jobName");
    JobParameters jobParameters = new JobParameters();

    repository.createJobExecution(job.getName(), jobParameters);

    try {
      repository.createJobExecution(job.getName(), jobParameters);
      fail("Expected JobExecutionAlreadyRunningException");
    }
    catch (JobExecutionAlreadyRunningException e) {
      // expected
    }
View Full Code Here

  @Override
  public Map<String, String> getConfigurations() {
    Map<String, String> result = new HashMap<String, String>(configurations);
    for (String jobName : registry.getJobNames()) {
      try {
        Job configuration = registry.getJob(jobName);
        String name = configuration.getName();
        if (!configurations.containsKey(name)) {
          result.put(name, "<unknown path>: " + configuration);
        }
      }
      catch (NoSuchJobException e) {
View Full Code Here

   * java.lang.String)
   */
  @Override
  public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (bean instanceof Job) {
      Job job = (Job) bean;
      try {
        String groupName = this.groupName;
        if (beanFactory != null && beanFactory.containsBean(beanName)) {
          groupName = getGroupName(beanFactory.getBeanDefinition(beanName), job);
        }
View Full Code Here

    for (String name : names) {

      if (!autoRegistrationDetected) {

        Job job = (Job) context.getBean(name);
        String jobName = job.getName();

        // On reload try to unregister first
        if (unregister) {
          logger.debug("Unregistering job: " + jobName + " from context: " + context.getDisplayName());
          doUnregister(jobName);
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(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());
View Full Code Here

    //setup
    String jobName = "test_job";
    JobRepository jobRepository = mock(JobRepository.class);
    JobParameters parameters = new JobParametersBuilder().addLong("runtime", System.currentTimeMillis()).toJobParameters();
    JobExecution jobExecution = mock(JobExecution.class);
    Job job = mock(Job.class);
    JobParametersValidator validator = mock(JobParametersValidator.class);
    StepExecution stepExecution = mock(StepExecution.class);

    when(job.getName()).thenReturn(jobName);
    when(job.isRestartable()).thenReturn(true);
    when(job.getJobParametersValidator()).thenReturn(validator);
    when(jobRepository.getLastJobExecution(jobName, parameters)).thenReturn(jobExecution);
    when(stepExecution.getStatus()).thenReturn(BatchStatus.UNKNOWN);
    when(jobExecution.getStepExecutions()).thenReturn(Arrays.asList(stepExecution));

    //setup launcher
View Full Code Here

        }
        jobParameters = jobExecution.getJobParameters();
        jobName = jobExecution.getJobInstance().getJobName();
      }

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

    logger.info("Checking status of job execution with id=" + executionId);

    JobExecution jobExecution = findExecutionById(executionId);

    String jobName = jobExecution.getJobInstance().getJobName();
    Job job = jobRegistry.getJob(jobName);
    JobParameters parameters = jobExecution.getJobParameters();

    logger.info(String.format("Attempting to resume job with name=%s and parameters=%s", jobName, parameters));
    try {
      return jobLauncher.run(job, parameters).getId();
View Full Code Here

      throw new JobInstanceAlreadyExistsException(String.format(
          "Cannot start a job instance that already exists with name=%s and parameters=%s", jobName,
          parameters));
    }

    Job job = jobRegistry.getJob(jobName);

    logger.info(String.format("Attempting to launch job with name=%s and parameters=%s", jobName, parameters));
    try {
      return jobLauncher.run(job, jobParameters).getId();
    }
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.