Example usage for org.springframework.batch.core JobExecution getStatus

List of usage examples for org.springframework.batch.core JobExecution getStatus

Introduction

In this page you can find the example usage for org.springframework.batch.core JobExecution getStatus.

Prototype

public BatchStatus getStatus() 

Source Link

Usage

From source file:com.apress.prospringintegration.springbatch.integration.Main.java

public static void main(String[] args) throws Throwable {
    ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(
            "integration.xml");
    classPathXmlApplicationContext.start();

    JobLauncher jobLauncher = (JobLauncher) classPathXmlApplicationContext.getBean("jobLauncher");
    Job job = (Job) classPathXmlApplicationContext.getBean("importData");

    JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
    jobParametersBuilder.addDate("date", new Date());
    jobParametersBuilder.addString("input.file", "registrations");
    JobParameters jobParameters = jobParametersBuilder.toJobParameters();

    JobExecution jobExecution = jobLauncher.run(job, jobParameters);

    BatchStatus batchStatus = jobExecution.getStatus();
    while (batchStatus.isRunning()) {
        System.out.println("Still running...");
        Thread.sleep(1000);/* w  w w . j av a  2 s. c  o m*/
    }

    System.out.println("Exit status: " + jobExecution.getExitStatus().getExitCode());
    JobInstance jobInstance = jobExecution.getJobInstance();
    System.out.println("job instance Id: " + jobInstance.getId());
}

From source file:org.devware.batch.main.Launcher.java

public static void main(String arg[]) {

    String[] springConfig = { "org/devware/config/context/readerConfig.xml",
            "org/devware/config/context/writerConfig.xml", "org/devware/config/context/processorConfig.xml",
            "org/devware/config/datasource/datasource.xml" };

    ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

    JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");

    Job job = (Job) context.getBean("ExcelReaderJob");

    try {//from w  ww. ja v a  2s  .co m
        JobExecution execution = jobLauncher.run(job, new JobParameters());

        System.out.println("Exit Status : " + execution.getStatus());
    } catch (Exception e) {
        //  
        e.printStackTrace();
    }

    System.out.println("Done");

}

From source file:com.mkyong.AppJobAllExport.java

/**
 * @param args the command line arguments
 *//* www.  j  a  va2 s. co m*/
public static void main(String[] args) {
    fLogger.log(Level.INFO, "Export all csv to mysql");
    String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml",
            "spring/batch/jobs/csvexport/job-all-export.xml" };

    ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

    JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
    Job job = (Job) context.getBean("exportJob");

    try {
        JobExecution execution = jobLauncher.run(job, new JobParameters());
        fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus());
    } catch (JobParametersInvalidException e) {
        e.getMessage();
    } catch (JobExecutionAlreadyRunningException e) {
        e.getMessage();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.getMessage();
    } catch (JobRestartException e) {
        e.getMessage();
    }
    fLogger.log(Level.INFO, "Done");
}

From source file:com.mkyong.AppJobAllImport.java

/**
 * @param args the command line arguments
 *//* w w w  . j  a va2  s  .  c  om*/
public static void main(String[] args) {
    fLogger.log(Level.INFO, "Import all csv to mysql");
    String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml",
            "spring/batch/jobs/csvimport/job-all-import.xml" };

    ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

    JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
    Job job = (Job) context.getBean("importJob");

    try {
        JobExecution execution = jobLauncher.run(job, new JobParameters());
        fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus());
    } catch (JobParametersInvalidException e) {
        e.getMessage();
    } catch (JobExecutionAlreadyRunningException e) {
        e.getMessage();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.getMessage();
    } catch (JobRestartException e) {
        e.getMessage();
    }
    fLogger.log(Level.INFO, "Done");
}

From source file:pl.mariuszczarny.springbatchforslask.main.AppJobAllImport.java

/**
 * @param args the command line arguments
 *///from ww w . j  av  a 2  s.c  o  m
public static void main(String[] args) {
    fLogger.log(Level.INFO, "Import all csv to mysql");
    String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml",
            "spring/batch/jobs/job-all-import.xml" };

    ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

    JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
    Job job = (Job) context.getBean("importJob");

    try {
        JobExecution execution = jobLauncher.run(job, new JobParameters());
        fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus());
    } catch (JobParametersInvalidException e) {
        e.getMessage();
    } catch (JobExecutionAlreadyRunningException e) {
        e.getMessage();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.getMessage();
    } catch (JobRestartException e) {
        e.getMessage();
    }
    fLogger.log(Level.INFO, "Done");
}

From source file:com.mkyong.AppJobCityImport.java

/**
 * @param args the command line arguments
 *//*ww w  .j av a  2 s  .  c  o m*/
public static void main(String[] args) {
    fLogger.log(Level.INFO, "Import city csv from mysql");
    String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml",
            "spring/batch/jobs/csvimport/job-city-import.xml" };

    ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

    JobLauncher jobCityLauncher = (JobLauncher) context.getBean("jobLauncher");
    Job cityJob = (Job) context.getBean("cityImportJob");

    try {
        JobExecution execution = jobCityLauncher.run(cityJob, new JobParameters());
        fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus());
    } catch (JobParametersInvalidException e) {
        e.getMessage();
    } catch (JobExecutionAlreadyRunningException e) {
        e.getMessage();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.getMessage();
    } catch (JobRestartException e) {
        e.getMessage();
    }
    fLogger.log(Level.INFO, "Done");
}

From source file:pl.mariuszczarny.springbatchforslask.main.fromcsv.ArrangeExport.java

/**
 * @param args the command line arguments
 *///from   w ww  .  j a v a 2 s. c o  m
public static void main(String[] args) {
    fLogger.log(Level.INFO, "Import city csv from mysql");
    String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml",
            "spring/batch/jobs/fromdb/city.xml" };

    ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

    JobLauncher jobCityLauncher = (JobLauncher) context.getBean("jobLauncher");
    Job cityJob = (Job) context.getBean("cityImportJob");

    try {
        JobExecution execution = jobCityLauncher.run(cityJob, new JobParameters());
        fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus());
    } catch (JobParametersInvalidException e) {
        e.getMessage();
    } catch (JobExecutionAlreadyRunningException e) {
        e.getMessage();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.getMessage();
    } catch (JobRestartException e) {
        e.getMessage();
    }
    fLogger.log(Level.INFO, "Done");
}

From source file:pl.mariuszczarny.springbatchforslask.main.fromdb.ClubImport.java

/**
 * @param args the command line arguments
 *///from   w ww  .ja  v a2 s.  c o  m
public static void main(String[] args) {
    fLogger.log(Level.INFO, "Import club csv from mysql");
    String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml",
            "spring/batch/jobs/fromdb/club.xml" };

    ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

    JobLauncher jobCityLauncher = (JobLauncher) context.getBean("jobLauncher");
    Job clubJob = (Job) context.getBean("clubImportJob");

    try {
        JobExecution execution = jobCityLauncher.run(clubJob, new JobParameters());
        fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus());
    } catch (JobParametersInvalidException e) {
        e.getMessage();
    } catch (JobExecutionAlreadyRunningException e) {
        e.getMessage();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.getMessage();
    } catch (JobRestartException e) {
        e.getMessage();
    }
    fLogger.log(Level.INFO, "Done");
}

From source file:com.mkyong.AppJobReportImport.java

/**
 * @param args the command line arguments
 *//* w w w.  j  ava 2  s  .c  o  m*/
public static void main(String[] args) {
    fLogger.log(Level.INFO, "Import report csv from mysql");
    String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml",
            "spring/batch/jobs/csvimport/job-report-import.xml" };

    ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

    JobLauncher jobCityLauncher = (JobLauncher) context.getBean("jobLauncher");
    Job reportJob = (Job) context.getBean("reportImportJob");

    try {
        JobExecution execution = jobCityLauncher.run(reportJob, new JobParameters());
        fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus());
    } catch (JobParametersInvalidException e) {
        e.getMessage();
    } catch (JobExecutionAlreadyRunningException e) {
        e.getMessage();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.getMessage();
    } catch (JobRestartException e) {
        e.getMessage();
    }
    fLogger.log(Level.INFO, "Done");
}

From source file:pl.mariuszczarny.springbatchforslask.main.fromdb.CoachImport.java

/**
 * @param args the command line arguments
 *///from ww w.j a v  a  2  s . c  o  m
public static void main(String[] args) {
    fLogger.log(Level.INFO, "Import coach csv from mysql");
    String[] springConfig = { "spring/batch/config/database.xml", "spring/batch/config/context.xml",
            "spring/batch/jobs/fromdb/coach.xml" };

    ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

    JobLauncher jobCoachLauncher = (JobLauncher) context.getBean("jobLauncher");
    Job coachJob = (Job) context.getBean("coachImportJob");

    try {
        JobExecution execution = jobCoachLauncher.run(coachJob, new JobParameters());
        fLogger.log(Level.INFO, "Exit Status : {0}", execution.getStatus());
    } catch (JobParametersInvalidException e) {
        e.getMessage();
    } catch (JobExecutionAlreadyRunningException e) {
        e.getMessage();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.getMessage();
    } catch (JobRestartException e) {
        e.getMessage();
    }
    fLogger.log(Level.INFO, "Done");
}