use of org.springframework.batch.core.Job in project head by mifos.
the class MifosBatchJob method executeInternal.
@Override
public void executeInternal(JobExecutionContext context) throws JobExecutionException {
try {
String jobName = context.getJobDetail().getName();
Job job = jobLocator.getJob(jobName);
catchUpMissedLaunches(job, context);
checkAndLaunchJob(job, getJobParametersFromContext(context), 0);
} catch (Exception ex) {
throw new JobExecutionException(ex);
}
}
use of org.springframework.batch.core.Job in project spring-boot by spring-projects.
the class JobLauncherCommandLineRunner method executeRegisteredJobs.
private void executeRegisteredJobs(JobParameters jobParameters) throws JobExecutionException {
if (this.jobRegistry != null && StringUtils.hasText(this.jobNames)) {
String[] jobsToRun = this.jobNames.split(",");
for (String jobName : jobsToRun) {
try {
Job job = this.jobRegistry.getJob(jobName);
if (this.jobs.contains(job)) {
continue;
}
execute(job, jobParameters);
} catch (NoSuchJobException ex) {
logger.debug("No job found in registry for job name: " + jobName);
continue;
}
}
}
}
use of org.springframework.batch.core.Job in project camel by apache.
the class SpringBatchEndpointTest method shouldInjectJobRegistryByReferenceName.
@Test
public void shouldInjectJobRegistryByReferenceName() throws Exception {
// Given
Job mockJob = mock(Job.class);
when(jobRegistry.getJob(eq("mockJob"))).thenReturn(mockJob);
context().addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:jobRegistryRefTest").to("spring-batch:mockJob?jobRegistry=#jobRegistry");
}
});
// When
template.sendBody("direct:jobRegistryRefTest", "Start the job, please.");
// Then
SpringBatchEndpoint batchEndpoint = context().getEndpoint("spring-batch:mockJob?jobRegistry=#jobRegistry", SpringBatchEndpoint.class);
JobRegistry batchEndpointJobRegistry = (JobRegistry) FieldUtils.readField(batchEndpoint, "jobRegistry", true);
assertSame(jobRegistry, batchEndpointJobRegistry);
}
use of org.springframework.batch.core.Job in project camel by apache.
the class SpringBatchEndpointTest method shouldConvertDateHeadersToJobParams.
@Test
public void shouldConvertDateHeadersToJobParams() throws Exception {
// Given
String headerKey = "headerKey";
Date headerValue = new Date();
// When
template.sendBodyAndHeader("direct:start", "Start the job, please.", headerKey, headerValue);
// Then
ArgumentCaptor<JobParameters> jobParameters = ArgumentCaptor.forClass(JobParameters.class);
verify(jobLauncher).run(any(Job.class), jobParameters.capture());
Date parameter = jobParameters.getValue().getDate(headerKey);
assertEquals(parameter, headerValue);
}
use of org.springframework.batch.core.Job in project camel by apache.
the class SpringBatchEndpointTest method setNullValueToJobParams.
@Test
public void setNullValueToJobParams() throws Exception {
// Given
String headerKey = "headerKey";
Date headerValue = null;
// When
template.sendBodyAndHeader("direct:start", "Start the job, please.", headerKey, headerValue);
// Then
ArgumentCaptor<JobParameters> jobParameters = ArgumentCaptor.forClass(JobParameters.class);
verify(jobLauncher).run(any(Job.class), jobParameters.capture());
Date parameter = jobParameters.getValue().getDate(headerKey);
assertEquals(parameter, headerValue);
}
Aggregations