List of usage examples for org.springframework.batch.core.scope.context StepContext getStepExecution
public StepExecution getStepExecution()
From source file:fr.acxio.tools.agia.file.pdf.MergePDFProcessor.java
private StepExecution getStepExecution() { StepContext context = StepSynchronizationManager.getContext(); if (context == null) { return null; }/*from w ww .j ava 2s .com*/ return context.getStepExecution(); }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.issues.tasklets.IssuesLastRunExtractorTasklet.java
/** * {@inheritDoc}//from w w w . ja v a 2 s.c o m * @see org.springframework.batch.core.step.tasklet.Tasklet#execute(org.springframework.batch.core.StepContribution, org.springframework.batch.core.scope.context.ChunkContext) */ @Override public RepeatStatus execute(final StepContribution contribution, final ChunkContext chunkContext) throws Exception { final StepContext stepContext = chunkContext.getStepContext(); final String jobName = stepContext.getJobName(); final JobParameters jobParams = stepContext.getStepExecution().getJobParameters(); final Map<String, JobParameter> currParams = new HashMap<String, JobParameter>(jobParams.getParameters()); currParams.remove("run.id"); Date lastJobRun = null; final List<JobInstance> jobInstances = jobExplorer.getJobInstances(jobName, 0, 1000); for (final JobInstance jobInstance : jobInstances) { final List<JobExecution> jobExecutions = jobExplorer.getJobExecutions(jobInstance); for (final JobExecution jobExecution : jobExecutions) { final JobParameters oldJobParams = jobExecution.getJobParameters(); final Map<String, JobParameter> oldParams = new HashMap<String, JobParameter>( oldJobParams.getParameters()); oldParams.remove("run.id"); if (ExitStatus.COMPLETED.equals(jobExecution.getExitStatus()) && oldParams.equals(currParams)) { if (lastJobRun == null || lastJobRun.before(jobExecution.getStartTime())) { lastJobRun = jobExecution.getStartTime(); } } } } if (lastJobRun != null) { stepContext.getStepExecution().getExecutionContext().put("mantis.update.last_job_run", lastJobRun); } stepContext.getStepExecution().getExecutionContext().put("mantis.update.current_job_run", Calendar.getInstance()); return RepeatStatus.FINISHED; }
From source file:org.springframework.batch.core.jsr.configuration.support.BatchPropertyBeanPostProcessor.java
private String getBeanPropertyName(String beanName) { StepContext stepContext = StepSynchronizationManager.getContext(); if (stepContext != null) { String stepName = stepContext.getStepName(); String jobName = stepContext.getStepExecution().getJobExecution().getJobInstance().getJobName(); return jobName + "." + stepName + "." + beanName.substring("scopedTarget.".length()); }/*from ww w.j a v a2s.c om*/ return beanName; }