當前位置: 首頁>>代碼示例>>Java>>正文


Java JobExecution.getExecutionContext方法代碼示例

本文整理匯總了Java中org.springframework.batch.core.JobExecution.getExecutionContext方法的典型用法代碼示例。如果您正苦於以下問題:Java JobExecution.getExecutionContext方法的具體用法?Java JobExecution.getExecutionContext怎麽用?Java JobExecution.getExecutionContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.batch.core.JobExecution的用法示例。


在下文中一共展示了JobExecution.getExecutionContext方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: afterJob

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Override
public void afterJob(final JobExecution jobExecution) {
    if (ExitStatus.COMPLETED.equals(jobExecution.getExitStatus())) {
        final ExecutionContext executionContext = jobExecution.getExecutionContext();
        final String inputFile = executionContext.getString(LHHuntingClubBatchConfig.KEY_INPUT_FILE, null);

        if (inputFile != null) {
            final Path path = Paths.get(inputFile);

            try {
                LOG.info("Deleting temporary file: {}", inputFile);
                Files.deleteIfExists(path);

            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            LOG.warn("Input file not found in context");
        }
    }
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:22,代碼來源:LHHuntingClubCSVCleaner.java

示例2: AdaptedJobExecution

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
public AdaptedJobExecution(JobExecution jobExecution) {
    this.id = jobExecution.getId();
    if (jobExecution.getVersion() == null) {
        jobExecution.setVersion(0);
    } else {
        this.version = jobExecution.getVersion();
    }
    this.jobInstance = jobExecution.getJobInstance();
    this.jobParameters = jobExecution.getJobParameters();
    this.createDateTime = jobExecution.getCreateTime();
    this.endDateTime = jobExecution.getEndTime();
    this.lastUpdatedDateTime = jobExecution.getLastUpdated();
    this.startDateTime = jobExecution.getStartTime();
    if (jobExecution.getStatus() == null) {
        this.status = BatchStatus.STARTING.toString();
    } else {
        this.status = jobExecution.getStatus().toString();
    }
    this.exitStatus = jobExecution.getExitStatus().toString();
    for (StepExecution step : jobExecution.getStepExecutions()) {
        stepExecutions.add(step);
    }
    this.executionContext = jobExecution.getExecutionContext();
}
 
開發者ID:marklogic-community,項目名稱:marklogic-spring-batch,代碼行數:25,代碼來源:AdaptedJobExecution.java

示例3: JobExecutionEvent

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
/**
 * Constructor for the StepExecution to initialize the DTO.
 *
 * @param original the StepExecution to build this DTO around.
 */
public JobExecutionEvent(JobExecution original) {
	this.jobParameters = new JobParametersEvent(original.getJobParameters().getParameters());
	this.jobInstance = new JobInstanceEvent(original.getJobInstance().getId(), original.getJobInstance().getJobName());
	for(StepExecution stepExecution : original.getStepExecutions()){
		stepExecutions.add(new StepExecutionEvent(stepExecution));
	}
	this.status = original.getStatus();
	this.startTime = original.getStartTime();
	this.createTime = original.getCreateTime();
	this.endTime = original.getEndTime();
	this.lastUpdated = original.getLastUpdated();
	this.exitStatus = new ExitStatus(original.getExitStatus());
	this.executionContext = original.getExecutionContext();
	this.failureExceptions = original.getFailureExceptions();
	this.jobConfigurationName = original.getJobConfigurationName();
	this.setId(original.getId());
	this.setVersion(original.getVersion());
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-task,代碼行數:24,代碼來源:JobExecutionEvent.java

示例4: decide

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Override
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
	if (jobExecution.getJobInstance().getJobParameters().getString(jobParameterName) != null) {
		ExecutionContext executionContext = jobExecution.getExecutionContext();
		JobParameters jobParameters = jobExecution.getJobInstance().getJobParameters();
		if(jobParameterName.equals("download.taxon")) {
			setExecutionContext(executionContext,jobParameters,"taxon.txt","org.emonocot.model.Taxon", "http://rs.tdwg.org/dwc/terms/Taxon");
		} else if(jobParameterName.equals("download.description")) {
			setExecutionContext(executionContext,jobParameters,"description.txt","org.emonocot.model.Description", "http://rs.gbif.org/terms/1.0/Description");
		} else if(jobParameterName.equals("download.distribution")) {
			setExecutionContext(executionContext,jobParameters,"distribution.txt","org.emonocot.model.Distribution", "http://rs.gbif.org/terms/1.0/Distribution");
		} else if(jobParameterName.equals("download.image")) {
			setExecutionContext(executionContext,jobParameters,"image.txt","org.emonocot.model.Image", "http://rs.gbif.org/terms/1.0/Image");
		} else if(jobParameterName.equals("download.reference")) {
			setExecutionContext(executionContext,jobParameters,"reference.txt","org.emonocot.model.Reference", "http://rs.gbif.org/terms/1.0/Reference");
		} else if(jobParameterName.equals("download.typeAndSpecimen")) {
			setExecutionContext(executionContext,jobParameters,"typeAndSpecimen.txt","org.emonocot.model.TypeAndSpecimen", "http://rs.gbif.org/terms/1.0/TypesAndSpecimen");
		} else if(jobParameterName.equals("download.measurementOrFact")) {
			setExecutionContext(executionContext,jobParameters,"measurementOrFact.txt","org.emonocot.model.MeasurementOrFact", "http://rs.tdwg.org/dwc/terms/MeasurementOrFact");
		} else if(jobParameterName.equals("download.vernacularName")) {
			setExecutionContext(executionContext,jobParameters,"vernacularName.txt","org.emonocot.model.VernacularName","http://rs.gbif.org/terms/1.0/VernacularName");
		} else if(jobParameterName.equals("download.identifier")) {
			setExecutionContext(executionContext,jobParameters,"identifier.txt","org.emonocot.model.Identifier", "http://rs.gbif.org/terms/1.0/Identifier");
		}
		return new FlowExecutionStatus("true");
	} else {
		return new FlowExecutionStatus("false");
	}
}
 
開發者ID:RBGKew,項目名稱:eMonocot,代碼行數:30,代碼來源:ExposeParametersDecider.java

示例5: step2

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Bean
@JobScope
public Step step2(StepBuilderFactory stepBuilderFactory) {
    ItemReader<String> reader = new ItemReader<String>() {
        int i = 0;

        @Override
        public String read() throws Exception {
            i++;
            return i == 1 ? "hello" : null;
        }
    };


    ItemWriter<String> writer = new ItemWriter<String>() {
        String someString;

        @BeforeStep
        public void beforeStep(StepExecution stepExecution) {
            JobExecution jobExecution = stepExecution.getJobExecution();
            ExecutionContext jobContext = jobExecution.getExecutionContext();
            this.someString = jobContext.getString("someKey");
        }

        @Override
        public void write(List<? extends String> items) throws Exception {
            logger.info("Step 2: " + someString);
            for (String item : items) {
                logger.info("step2: " + item);
            }
        }

    };


    return stepBuilderFactory.get("step2")
            .<String, String>chunk(10)
            .reader(reader)
            .writer(writer)
            .listener(writer)
            .build();
}
 
開發者ID:marklogic-community,項目名稱:marklogic-spring-batch,代碼行數:43,代碼來源:YourTwoStepJobConfig.java

示例6: decide

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Override
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
	if (jobExecution.getJobParameters().getString(jobParameterName) != null) {
		ExecutionContext executionContext = jobExecution.getExecutionContext();
		JobParameters jobParameters = jobExecution.getJobParameters();
		if(jobParameterName.equals("download.taxon")) {
			setExecutionContext(executionContext,jobParameters,"taxon.txt","org.emonocot.model.Taxon", "http://rs.tdwg.org/dwc/terms/Taxon");
		} else if(jobParameterName.equals("download.description")) {
			setExecutionContext(executionContext,jobParameters,"description.txt","org.emonocot.model.Description", "http://rs.gbif.org/terms/1.0/Description");
		} else if(jobParameterName.equals("download.distribution")) {
			setExecutionContext(executionContext,jobParameters,"distribution.txt","org.emonocot.model.Distribution", "http://rs.gbif.org/terms/1.0/Distribution");
		} else if(jobParameterName.equals("download.image")) {
			setExecutionContext(executionContext,jobParameters,"image.txt","org.emonocot.model.Image", "http://rs.gbif.org/terms/1.0/Image");
		} else if(jobParameterName.equals("download.reference")) {
			setExecutionContext(executionContext,jobParameters,"reference.txt","org.emonocot.model.Reference", "http://rs.gbif.org/terms/1.0/Reference");
		} else if(jobParameterName.equals("download.typeAndSpecimen")) {
			setExecutionContext(executionContext,jobParameters,"typeAndSpecimen.txt","org.emonocot.model.TypeAndSpecimen", "http://rs.gbif.org/terms/1.0/TypesAndSpecimen");
		} else if(jobParameterName.equals("download.measurementOrFact")) {
			setExecutionContext(executionContext,jobParameters,"measurementOrFact.txt","org.emonocot.model.MeasurementOrFact", "http://rs.tdwg.org/dwc/terms/MeasurementOrFact");
		} else if(jobParameterName.equals("download.vernacularName")) {
			setExecutionContext(executionContext,jobParameters,"vernacularName.txt","org.emonocot.model.VernacularName","http://rs.gbif.org/terms/1.0/VernacularName");
		} else if(jobParameterName.equals("download.identifier")) {
			setExecutionContext(executionContext,jobParameters,"identifier.txt","org.emonocot.model.Identifier", "http://rs.gbif.org/terms/1.0/Identifier");
		}
		return new FlowExecutionStatus("true");
	} else {
		return new FlowExecutionStatus("false");
	}
}
 
開發者ID:RBGKew,項目名稱:powop,代碼行數:30,代碼來源:ExposeParametersDecider.java


注:本文中的org.springframework.batch.core.JobExecution.getExecutionContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。