Search in sources :

Example 1 with BatchStatus

use of org.springframework.batch.core.BatchStatus in project head by mifos.

the class MifosBatchJob method launchJob.

/**
     * A method responsible for the actual launch of the Spring Batch job.
     * @param job Job class
     * @param jobParameters Job parameters
     * @return Batch computation status
     * @throws BatchJobException when something goes wrong
     */
private BatchStatus launchJob(Job job, JobParameters jobParameters) throws BatchJobException {
    BatchStatus exitStatus = BatchStatus.UNKNOWN;
    JobExecution jobExecution = null;
    try {
        batchJobStarted();
        requiresExclusiveAccess();
        jobExecution = jobLauncher.run(job, jobParameters);
        exitStatus = jobExecution.getStatus();
    } catch (JobInstanceAlreadyCompleteException jiace) {
        exitStatus = BatchStatus.COMPLETED;
        return exitStatus;
    } catch (Exception ex) {
        throw new BatchJobException(ex);
    } finally {
        batchJobFinished();
    }
    return exitStatus;
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) JobInstanceAlreadyCompleteException(org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException) BatchJobException(org.mifos.framework.components.batchjobs.exceptions.BatchJobException) BatchStatus(org.springframework.batch.core.BatchStatus) ParseException(java.text.ParseException) BatchJobException(org.mifos.framework.components.batchjobs.exceptions.BatchJobException) JobExecutionException(org.quartz.JobExecutionException) JobInstanceAlreadyCompleteException(org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException)

Example 2 with BatchStatus

use of org.springframework.batch.core.BatchStatus in project pinpoint by naver.

the class AlarmJobTest method main.

public static void main(String[] args) throws Exception {
    GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext("/applicationContext-test.xml");
    JobLauncherTestUtils testLauncher = applicationContext.getBean(JobLauncherTestUtils.class);
    JobExecution jobExecution = testLauncher.launchJob(getParameters());
    BatchStatus status = jobExecution.getStatus();
    assertEquals(BatchStatus.COMPLETED, status);
    applicationContext.close();
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) BatchStatus(org.springframework.batch.core.BatchStatus) JobLauncherTestUtils(org.springframework.batch.test.JobLauncherTestUtils) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 3 with BatchStatus

use of org.springframework.batch.core.BatchStatus in project pinpoint by naver.

the class AlarmJobTest method main.

public static void main(String[] args) throws Exception {
    GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext("/applicationContext-test.xml");
    JobLauncherTestUtils testLauncher = applicationContext.getBean(JobLauncherTestUtils.class);
    JobExecution jobExecution = testLauncher.launchJob(getParameters());
    BatchStatus status = jobExecution.getStatus();
    assertEquals(BatchStatus.COMPLETED, status);
    applicationContext.close();
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) BatchStatus(org.springframework.batch.core.BatchStatus) JobLauncherTestUtils(org.springframework.batch.test.JobLauncherTestUtils) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Aggregations

BatchStatus (org.springframework.batch.core.BatchStatus)3 JobExecution (org.springframework.batch.core.JobExecution)3 JobLauncherTestUtils (org.springframework.batch.test.JobLauncherTestUtils)2 GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)2 ParseException (java.text.ParseException)1 BatchJobException (org.mifos.framework.components.batchjobs.exceptions.BatchJobException)1 JobExecutionException (org.quartz.JobExecutionException)1 JobInstanceAlreadyCompleteException (org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException)1