Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobExecutionListener


   * @see org.springframework.batch.core.JobExecutionListener#afterJob(org.springframework.batch.core.JobExecution)
   */
  @Override
  public void afterJob(JobExecution jobExecution) {
    for (Iterator<JobExecutionListener> iterator = listeners.reverse(); iterator.hasNext();) {
      JobExecutionListener listener = iterator.next();
      listener.afterJob(jobExecution);
    }
  }
View Full Code Here


   * @see org.springframework.batch.core.JobExecutionListener#beforeJob(org.springframework.batch.core.JobExecution)
   */
  @Override
  public void beforeJob(JobExecution jobExecution) {
    for (Iterator<JobExecutionListener> iterator = listeners.iterator(); iterator.hasNext();) {
      JobExecutionListener listener = iterator.next();
      listener.beforeJob(jobExecution);
    }
  }
View Full Code Here

  @Test
  public void testInterruptWithListener() throws Exception {
    step1.setProcessException(new JobInterruptedException("job interrupted!"));

    JobExecutionListener listener = mock(JobExecutionListener.class);
    listener.beforeJob(jobExecution);
    listener.afterJob(jobExecution);

    job.setJobExecutionListeners(new JobExecutionListener[] { listener });

    job.execute(jobExecution);
    assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
View Full Code Here

  @Test
  public void testWithInterface() throws Exception {
    JobListenerWithInterface delegate = new JobListenerWithInterface();
    factoryBean.setDelegate(delegate);
    JobExecutionListener listener = (JobExecutionListener) factoryBean.getObject();
    JobExecution jobExecution = new JobExecution(11L);
    listener.beforeJob(jobExecution);
    listener.afterJob(jobExecution);
    assertTrue(delegate.beforeJobCalled);
    assertTrue(delegate.afterJobCalled);
  }
View Full Code Here

  @Test
  public void testWithAnnotations() throws Exception {
    AnnotatedTestClass delegate = new AnnotatedTestClass();
    factoryBean.setDelegate(delegate);
    JobExecutionListener listener = (JobExecutionListener) factoryBean.getObject();
    JobExecution jobExecution = new JobExecution(11L);
    listener.beforeJob(jobExecution);
    listener.afterJob(jobExecution);
    assertTrue(delegate.beforeJobCalled);
    assertTrue(delegate.afterJobCalled);
  }
View Full Code Here

      @Override
      public int getOrder() {
        return 3;
      }
    };
    JobExecutionListener listener = JobListenerFactoryBean.getListener(delegate);
    assertTrue("Listener is not of correct type", listener instanceof Ordered);
    assertEquals(3, ((Ordered) listener).getOrder());
  }
View Full Code Here

      public void aMethod() {
        executed = true;
      }
    };
    factoryBean.setDelegate(delegate);
    JobExecutionListener listener = (JobExecutionListener) factoryBean.getObject();
    listener.afterJob(new JobExecution(1L));
    assertTrue(delegate.isExecuted());
  }
View Full Code Here

        executed = true;
        assertEquals(new Long(25), jobExecution.getId());
      }
    };
    factoryBean.setDelegate(delegate);
    JobExecutionListener listener = (JobExecutionListener) factoryBean.getObject();
    listener.afterJob(new JobExecution(25L));
    assertTrue(delegate.isExecuted());
  }
View Full Code Here

    };
    factoryBean.setDelegate(delegate);
    Map<String, String> metaDataMap = new HashMap<String, String>();
    metaDataMap.put(AFTER_JOB.getPropertyName(), "aMethod");
    factoryBean.setMetaDataMap(metaDataMap);
    JobExecutionListener listener = (JobExecutionListener) factoryBean.getObject();
    listener.afterJob(new JobExecution(1L));
    assertTrue(delegate.isExecuted());
  }
View Full Code Here

    };
    factoryBean.setDelegate(delegate);
    Map<String, String> metaDataMap = new HashMap<String, String>();
    metaDataMap.put(AFTER_JOB.getPropertyName(), "aMethod");
    factoryBean.setMetaDataMap(metaDataMap);
    JobExecutionListener listener = (JobExecutionListener) factoryBean.getObject();
    listener.afterJob(new JobExecution(25L));
    assertTrue(delegate.isExecuted());
  }
View Full Code Here

TOP

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

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.