Example usage for org.springframework.batch.core.configuration JobRegistry getJob

List of usage examples for org.springframework.batch.core.configuration JobRegistry getJob

Introduction

In this page you can find the example usage for org.springframework.batch.core.configuration JobRegistry getJob.

Prototype

Job getJob(@Nullable String name) throws NoSuchJobException;

Source Link

Document

Locates a Job at runtime.

Usage

From source file:org.sbq.batch.scheduled.CalculateOnlineMetricsScheduledJob.java

@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
    JobRegistry jobRegistry = getJobRegistry();
    JobLauncher jobLauncher = getJobLauncher();
    Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
    parameters.put("scheduledFireTime", new JobParameter(context.getScheduledFireTime()));
    try {/*from  ww w .  j a v  a2 s  . com*/
        jobLauncher.run(jobRegistry.getJob("calculateOnlineMetricsJob"), new JobParameters(parameters));
    } catch (Exception e) {
        throw new JobExecutionException(e);
    }
}

From source file:org.sbq.batch.scheduled.CalculateEventMetricsScheduledJob.java

@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
    JobRegistry jobRegistry = getJobRegistry();
    JobLauncher jobLauncher = getJobLauncher();
    long finishedAt = context.getMergedJobDataMap().getLong("finishedAt");
    Date startingFrom = new Date(finishedAt);
    Date endingAt = new Date();
    Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
    parameters.put("startingFrom", new JobParameter(startingFrom));
    parameters.put("endingAt", new JobParameter(endingAt));
    try {/*www.j a va2s  .c  o m*/
        jobLauncher.run(jobRegistry.getJob("calculateEventMetricsJob"), new JobParameters(parameters));
        context.getMergedJobDataMap().putAsString("finishedAt", endingAt.getTime());
    } catch (Exception e) {
        throw new JobExecutionException(e);
    }
}

From source file:org.springframework.data.hadoop.admin.service.SimpleWorkflowService.java

private boolean isJobRegistered(String jobName) {
    boolean result = true;
    JobRegistry jobRegistry = context.getBean("jobRegistry", JobRegistry.class);
    try {/*from  w w w. j a  v a2s. c  o m*/
        Job job = jobRegistry.getJob(jobName);
        if (job == null) {
            result = false;
        }
    } catch (NoSuchJobException e) {
        result = false;
    }
    return result;
}