本文整理了Java中org.springframework.batch.core.Job
类的一些代码示例,展示了Job
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job
类的具体详情如下:
包路径:org.springframework.batch.core.Job
类名称:Job
[英]Batch domain object representing a job. Job is an explicit abstraction representing the configuration of a job specified by a developer. It should be noted that restart policy is applied to the job as a whole and not to a step.
[中]表示作业的批处理域对象。作业是一个显式抽象,表示开发人员指定的作业配置。应该注意的是,重新启动策略应用于整个作业,而不是一个步骤。
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testRestart() throws Exception {
JobParametersBuilder paramBuilder = new JobParametersBuilder();
paramBuilder.addDate("value", new Date());
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters());
job.execute(jobExecution);
jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters());
job.execute(jobExecution);
int count = jobRepository.getStepExecutionCount(jobExecution.getJobInstance(), "simpleJob.step1");
assertEquals(2, count);
}
}
代码示例来源:origin: spring-projects/spring-batch
Assert.state(this.jobExplorer != null, "A JobExplorer is required to get next job parameters");
Assert.notNull(job, "Job must not be null");
Assert.notNull(job.getJobParametersIncrementer(), "No job parameters incrementer found for job=" + job.getName());
String name = job.getName();
JobParameters nextParameters;
List<JobInstance> lastInstances = this.jobExplorer.getJobInstances(name, 0, 1);
JobParametersIncrementer incrementer = job.getJobParametersIncrementer();
if (lastInstances.isEmpty()) {
代码示例来源:origin: spring-projects/spring-batch
private void testRestartStepExecutionInvalidStatus(BatchStatus status) throws Exception {
String jobName = "test_job";
JobRepository jobRepository = mock(JobRepository.class);
JobParameters parameters = new JobParametersBuilder().addLong("runtime", System.currentTimeMillis()).toJobParameters();
JobExecution jobExecution = mock(JobExecution.class);
Job job = mock(Job.class);
JobParametersValidator validator = mock(JobParametersValidator.class);
StepExecution stepExecution = mock(StepExecution.class);
when(job.getName()).thenReturn(jobName);
when(job.isRestartable()).thenReturn(true);
when(job.getJobParametersValidator()).thenReturn(validator);
when(jobRepository.getLastJobExecution(jobName, parameters)).thenReturn(jobExecution);
when(stepExecution.getStatus()).thenReturn(status);
when(jobExecution.getStepExecutions()).thenReturn(Arrays.asList(stepExecution));
//setup launcher
jobLauncher = new SimpleJobLauncher();
jobLauncher.setJobRepository(jobRepository);
//run
jobLauncher.run(job, parameters);
}
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void run() {
JsrJobContextFactoryBean factoryBean = null;
try {
factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME);
factoryBean.setJobExecution(jobExecution);
final Job job = batchContext.getBean(Job.class);
if(!job.isRestartable()) {
throw new JobRestartException("Job " + jobName + " is not restartable");
}
semaphore.release();
// Initialization of the JobExecution for job level dependencies
jobRegistry.register(job, jobExecution);
job.execute(jobExecution);
jobRegistry.remove(jobExecution);
}
catch (Exception e) {
exceptionHolder.add(e);
} finally {
if(factoryBean != null) {
factoryBean.close();
}
batchContext.close();
if(semaphore.availablePermits() == 0) {
semaphore.release();
}
}
}
});
代码示例来源:origin: spring-projects/spring-batch
/**
* Just return the name of instance passed in on initialization.
*
* @see JobFactory#getJobName()
*/
@Override
public String getJobName() {
return job.getName();
}
代码示例来源:origin: spring-projects/spring-batch
@Override
@Nullable
public JobParametersIncrementer getJobParametersIncrementer() {
return delegate.getJobParametersIncrementer();
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void run() {
job.execute(jobExecution);
}
}).start();
代码示例来源:origin: spring-projects/spring-batch
@Override
public boolean isRestartable() {
return delegate.isRestartable();
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public JobParametersValidator getJobParametersValidator() {
return delegate.getJobParametersValidator();
}
代码示例来源:origin: spring-projects/spring-batch
/**
* Just return the name of instance passed in on initialization.
*
* @see JobFactory#getJobName()
*/
@Override
public String getJobName() {
return job.getName();
}
代码示例来源:origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core
@Override
public JobParametersIncrementer getJobParametersIncrementer() {
return delegate.getJobParametersIncrementer();
}
代码示例来源:origin: spring-projects/spring-batch
@Around("execution(void org.springframework.batch.core.Job+.execute(*)) && target(job) && args(jobExecution)")
public void execute(Job job, JobExecution jobExecution) {
JobSynchronizationManager.register(jobExecution);
try {
job.execute(jobExecution);
}
finally {
JobSynchronizationManager.release();
}
}
代码示例来源:origin: org.springframework.batch/spring-batch-core
@Override
public boolean isRestartable() {
return delegate.isRestartable();
}
代码示例来源:origin: org.springframework.batch/spring-batch-core
@Override
public JobParametersValidator getJobParametersValidator() {
return delegate.getJobParametersValidator();
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testSplitJob() throws Exception {
assertNotNull(job);
JobExecution jobExecution = jobRepository.createJobExecution(job.getName(), new JobParameters());
job.execute(jobExecution);
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
assertEquals(4, jobExecution.getStepExecutions().size());
ArrayList<String> names = new ArrayList<>(((StepLocator) job).getStepNames());
Collections.sort(names);
assertEquals("[s1, s2, s3, s4]", names.toString());
}
代码示例来源:origin: spring-projects/spring-batch
public JobExecution run(Job job, JobParameters jobParameters){
jobs.add(job);
parameters.add(jobParameters);
return new JobExecution(new JobInstance(jobId.getAndIncrement(), job.getName()), jobParameters);
}
代码示例来源:origin: spring-projects/spring-batch
JobExecution lastExecution = jobRepository.getLastJobExecution(job.getName(), jobParameters);
if (lastExecution != null) {
if (!job.isRestartable()) {
throw new JobRestartException("JobInstance already exists and is not restartable");
job.getJobParametersValidator().validate(jobParameters);
jobExecution = jobRepository.createJobExecution(job.getName(), jobParameters);
代码示例来源:origin: org.springframework.batch/org.springframework.batch.core
public JobParametersIncrementer getJobParametersIncrementer() {
return delegate.getJobParametersIncrementer();
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void afterPropertiesSet() throws Exception {
JobExecution jobExecution = new JobExecution(11L);
job.execute(jobExecution);
// expect no errors
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public boolean isRestartable() {
return delegate.isRestartable();
}
内容来源于网络,如有侵权,请联系作者删除!