List of usage examples for org.springframework.batch.core StepExecution getExecutionContext
public ExecutionContext getExecutionContext()
From source file:com.vmware.bdd.manager.TestClusteringJobs.java
public static String stepsToString(Collection<StepExecution> ses) { StringBuilder sb = new StringBuilder(); for (StepExecution se : ses) { if (sb.length() > 0) { sb.append(", "); }/*from w w w.j av a2 s . c om*/ sb.append(se.getStepName()).append(":").append(se.getStatus()).append("-") .append(se.getExecutionContext()); } return sb.toString(); }
From source file:de.langmi.spring.batch.examples.complex.aggregating.AggregatedItemWriter.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { LOG.debug("afterStep"); stepExecution.getExecutionContext().put("real.write.count", count); return stepExecution.getExitStatus(); }
From source file:io.spring.batch.DownloadingStepExecutionListener.java
@Override public void beforeStep(StepExecution stepExecution) { String fileName = (String) stepExecution.getExecutionContext().get("fileName"); Resource resource = this.resourceLoader.getResource(fileName); try {//from www. ja v a2s. c om File file = File.createTempFile("input", ".csv"); StreamUtils.copy(resource.getInputStream(), new FileOutputStream(file)); stepExecution.getExecutionContext().put("localFile", file.getAbsolutePath()); System.out.println(">> downloaded file : " + file.getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); } }
From source file:batch.OutputFileListener.java
@BeforeStep public void createOutputNameFromInput(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); }/*from w w w.j a v a2 s. c om*/ if (!executionContext.containsKey(outputKeyName)) { executionContext.putString(outputKeyName, path + FilenameUtils.getBaseName(inputName) + ".csv"); } }
From source file:mpg.biochem.de.interbase.batch.OutputFileListener.java
@BeforeStep public void createOutputNameFromInput(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); }// ww w. j a v a 2s .c o m if (!executionContext.containsKey(outputKeyName)) { executionContext.putString(outputKeyName, path + FilenameUtils.getBaseName(inputName) + ".mapped.tab"); } }
From source file:lcn.module.batch.web.guide.listener.SkipCheckingListener.java
/** * Step ? stepName? Context? put // w w w . j a v a 2 s.c o m */ @BeforeStep public void saveStepName(StepExecution stepExecution) { stepExecution.getExecutionContext().put("stepName", stepExecution.getStepName()); }
From source file:com.cat.ic.listener.impl.OutputFileListenerMVNO.java
@BeforeStep public void createOutputNameFromInput(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); }/*from w w w . j a v a 2 s. c o m*/ if (!executionContext.containsKey(outputKeyName)) { executionContext.putString(outputKeyName, path + FilenameUtils.getName(inputName) + ".mvno"); } log.info("[" + executionContext.getString(outputKeyName) + "]"); }
From source file:de.langmi.spring.batch.examples.complex.file.renamefile.partition.extrastep.PropagateFileNamesListener.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { // get business key String businessKey = (String) stepExecution.getExecutionContext() .get(BatchConstants.CONTEXT_NAME_BUSINESS_KEY); this.fileNames.put(outputFile, businessKey); return stepExecution.getExitStatus(); }
From source file:egovframework.rte.bat.core.listener.EgovOutputFileListener.java
/** * stepExecutionContext? inputKeyName ? ? outputKeyName? put * /*from ww w . j a v a 2 s . c o m*/ * @param stepExecution */ @BeforeStep public void createOutputNameFromInput(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); } if (!executionContext.containsKey(outputKeyName)) { executionContext.putString(outputKeyName, path + FilenameUtils.getBaseName(inputName) + ".csv"); } }
From source file:de.langmi.spring.batch.examples.complex.file.renamefile.partition.RenameFileListener.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { // get business key String businessKey = (String) stepExecution.getExecutionContext() .get(BatchConstants.CONTEXT_NAME_BUSINESS_KEY); try {//from w ww . ja v a2 s . c o m String path = this.outputFileResource.getFile().getParent(); String newFilePathAndName = path + File.separator + businessKey + ".txt"; FileUtils.copyFile(outputFileResource.getFile(), new File(newFilePathAndName)); LOG.info("copied:" + this.outputFileResource.getFile().getPath() + " to:" + newFilePathAndName); // deletion here is not good, the itemstream will be closed after // this afterStep method is called // so get it deleted on jvm exit this.outputFileResource.getFile().deleteOnExit(); LOG.info("deleteOnExit for:" + this.outputFileResource.getFile().getPath()); } catch (Exception ex) { return new ExitStatus(ExitStatus.FAILED.getExitCode(), ex.getMessage()); } return stepExecution.getExitStatus(); }