当前位置: 首页>>代码示例>>Java>>正文


Java ExecutionContext.put方法代码示例

本文整理汇总了Java中org.springframework.batch.item.ExecutionContext.put方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutionContext.put方法的具体用法?Java ExecutionContext.put怎么用?Java ExecutionContext.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.batch.item.ExecutionContext的用法示例。


在下文中一共展示了ExecutionContext.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
 * Taskletのエントリポイント
 *
 * @param contribution ステップの実行状態
 * @param chunkContext チャンクの実行状態
 * @return ステータス(終了)
 * @throws Exception 予期しない例外
 */
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    Map<String, Object> jobParameters = chunkContext.getStepContext().getJobParameters();

    // ジョブ起動パラメータの取得
    LOGGER.info("FirstTasklet has been executed. job param is {}", jobParameters);

    ExecutionContext executionContext = chunkContext.getStepContext()
                                            .getStepExecution()
                                            .getJobExecution()
                                            .getExecutionContext();
    // ステップ間の情報引き継ぎはJobExecutionのExecutionContextを取得する。(StepExecutionのExecutionContextではダメ)
    executionContext.put("message", "foobar");
    return RepeatStatus.FINISHED; // このステップはこれで終了
}
 
开发者ID:yggd,项目名称:springbatch-showcase,代码行数:24,代码来源:FirstTasklet.java

示例2: execute

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
 * Executes the task as specified by the taskName with the associated
 * properties and arguments.
 * @param contribution mutable state to be passed back to update the current step execution
 * @param chunkContext contains the task-execution-id used by the listener.
 * @return Repeat status of FINISHED.
 */
@Override
public RepeatStatus execute(StepContribution contribution,
		ChunkContext chunkContext) throws Exception {
	String tmpTaskName = this.taskName.substring(0,
			this.taskName.lastIndexOf('_'));

	List<String> args = this.arguments;

	ExecutionContext stepExecutionContext = chunkContext.getStepContext().getStepExecution().
			getExecutionContext();
	if(stepExecutionContext.containsKey("task-arguments")) {
		args = (List<String>) stepExecutionContext.get("task-arguments");
	}

	long executionId = this.taskOperations.launch(tmpTaskName,
			this.properties, args);

	stepExecutionContext.put("task-execution-id", executionId);
	stepExecutionContext.put("task-arguments", args);

	waitForTaskToComplete(executionId);

	return RepeatStatus.FINISHED;
}
 
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:32,代码来源:TaskLauncherTasklet.java

示例3: execute

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
 * @param contribution Set the step contribution
 * @param chunkContext Set the chunk context
 * @return the repeat status
 * @throws Exception if there is a problem deleting the resources
 */
public final RepeatStatus execute(final StepContribution contribution,
		final ChunkContext chunkContext)
				throws Exception {
	UUID uuid1 = UUID.randomUUID();
	String temporaryFileName = harvesterSpoolDirectory + File.separator
			+ uuid1.toString() + ".xml";

	File temporaryFile = new File(temporaryFileName);
	ExecutionContext executionContext = chunkContext.getStepContext()
			.getStepExecution().getJobExecution().getExecutionContext();
	executionContext.put("startindex", 0);
	executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
	executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
	return RepeatStatus.FINISHED;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:22,代码来源:SetTemporaryFilenamesTasklet.java

示例4: execute

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
 * @param contribution Set the step contribution
 * @param chunkContext Set the chunk context
 * @return the repeat status
 * @throws Exception if there is a problem deleting the resources
 */
public final RepeatStatus execute(final StepContribution contribution, final ChunkContext chunkContext)
		throws Exception {
	UUID uuid = UUID.randomUUID();
	String unpackDirectoryName = harvesterSpoolDirectory + File.separator
			+ uuid.toString();
	String temporaryFileName = harvesterSpoolDirectory + File.separator
			+ uuid.toString() + ".zip";

	File unpackDirectory = new File(unpackDirectoryName);
	unpackDirectory.mkdir();
	File temporaryFile = new File(temporaryFileName);
	ExecutionContext executionContext = chunkContext.getStepContext()
			.getStepExecution().getJobExecution().getExecutionContext();
	executionContext.put("temporary.file.name",temporaryFile.getAbsolutePath());
	executionContext.put("unpack.directory.name",unpackDirectory.getAbsolutePath());
	executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
	return RepeatStatus.FINISHED;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:25,代码来源:SetTemporaryFilenamesTasklet.java

示例5: testWriteUrlToFile

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
 * @throws Exception
 */
@Test
public void testWriteUrlToFile() throws Exception {
	String expectedXml = "<?xml version='1.0' encoding='UTF-8'?><urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap\"><url><loc>http://build.e-monocot.org/test/identifier</loc><lastmod>1986-07-11T22:15:00.000+01:00</lastmod></url></urlset>";
	ExecutionContext executionContext = new ExecutionContext();
	executionContext.put("query.string", "from Taxon");
	writer.open(executionContext);
	ArrayList<Url> items = new ArrayList<Url>();
	Url data = new Url();
	data.setLastmod(ISODateTimeFormat.dateTime().print(new DateTime(1986, 07, 11, 22, 15, 00, 00)));
	data.setLoc(new URL("http://build.e-monocot.org/test/identifier"));
	items.add(data);
	writer.write(items);
	writer.close();
	assertTrue("The file should exist and be readable", tempFile.exists() && tempFile.isReadable());
	assertEquals("The XML produced didn't match expected XML", expectedXml, FileUtils.readFileToString(tempFile.getFile()));
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:20,代码来源:StaxWriterTest.java

示例6: execute

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
 * @param contribution Set the step contribution
 * @param chunkContext Set the chunk context
 * @return the repeat status
 * @throws Exception if there is a problem deleting the resources
 */
public final RepeatStatus execute(final StepContribution contribution, final ChunkContext chunkContext) throws Exception {
	UUID uuid = UUID.randomUUID();
	String unpackDirectoryName = harvesterSpoolDirectory + File.separator + uuid.toString();
	String temporaryFileName = harvesterSpoolDirectory + File.separator + uuid.toString() + ".zip";

	File unpackDirectory = new File(unpackDirectoryName);
	unpackDirectory.mkdir();
	File temporaryFile = new File(temporaryFileName);
	ExecutionContext executionContext = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext();
	executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
	executionContext.put("unpack.directory.name", unpackDirectory.getAbsolutePath());
	executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
	log.debug("setting temporary.file.name to {}", temporaryFile.getAbsolutePath());
	log.debug("execution context: {}", executionContext);
	return RepeatStatus.FINISHED;
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:23,代码来源:SetTemporaryFilenamesTasklet.java

示例7: partitioner

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
@Bean
public Partitioner partitioner() {
	return new Partitioner() {
		@Override
		public Map<String, ExecutionContext> partition(int gridSize) {

			Map<String, ExecutionContext> partitions = new HashMap<>(gridSize);

			for(int i = 0; i < GRID_SIZE; i++) {
				ExecutionContext context1 = new ExecutionContext();
				context1.put("partitionNumber", i);

				partitions.put("partition" + i, context1);
			}

			return partitions;
		}
	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-task,代码行数:20,代码来源:JobConfiguration.java

示例8: testExecutionContext

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
@Test
public void testExecutionContext() {
	ExecutionContext executionContext = new ExecutionContext();
	executionContext.put("hello", "world");
	JobExecutionEvent jobExecutionEvent = new JobExecutionEvent();
	assertNotNull(jobExecutionEvent.getExecutionContext());
	jobExecutionEvent.setExecutionContext(executionContext);
	assertEquals("world", jobExecutionEvent.getExecutionContext().getString("hello"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-task,代码行数:10,代码来源:JobExecutionEventTests.java

示例9: getStepExecution

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
private StepExecution getStepExecution() {
	JobExecution jobExecution = new JobExecution(1L, null, "hi");
	final StepExecution stepExecution = new StepExecution("step1", jobExecution);
	jobExecution.createStepExecution("step1");
	final ExecutionContext executionContext = stepExecution.getExecutionContext();

	executionContext.putInt("counter", 1234);
	executionContext.putDouble("myDouble", 1.123456d);
	executionContext.putLong("Josh", 4444444444L);
	executionContext.putString("awesomeString", "Yep");
	executionContext.put("hello", "world");
	executionContext.put("counter2", 9999);

	return stepExecution;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:16,代码来源:StepExecutionJacksonMixInTests.java

示例10: setExecutionContext

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
private void setExecutionContext(ExecutionContext executionContext, JobParameters jobParameters, String fileName,String downloadType, String extension) {
	logger.debug(jobParameterName + " Setting download.fields to " + jobParameters.getString(jobParameterName));
	executionContext.put("download.fields", jobParameters.getString(jobParameterName));
	File workDirectory = new File(outputDirectory.getFile(),jobParameters.getString("download.file"));
	if(!workDirectory.exists()) {
		workDirectory.mkdir();
		executionContext.put("working.directory", workDirectory.getAbsolutePath());
	}
	File downloadFile =  new File(workDirectory,fileName);
	executionContext.put("download.file", downloadFile.getAbsolutePath());
	executionContext.put("download.type", downloadType);
	executionContext.put("download.extension", extension);
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:14,代码来源:ExposeParametersDecider.java

示例11: execute

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
 * @param contribution Set the step contribution
 * @param chunkContext Set the chunk context
 * @return the repeat status
 * @throws Exception if there is a problem deleting the resources
 */
public final RepeatStatus execute(final StepContribution contribution,
		final ChunkContext chunkContext)
				throws Exception {
	ExecutionContext executionContext = chunkContext.getStepContext()
			.getStepExecution().getJobExecution().getExecutionContext();
	UUID uuid = UUID.randomUUID();
	String taxonFileName = harvesterSpoolDirectory + File.separator
			+ uuid.toString() +  "-taxon.xml";
	String imageFileName = harvesterSpoolDirectory + File.separator
			+ uuid.toString() +  "-image.xml";
	String outputFileName = harvesterSpoolDirectory + File.separator
			+ uuid.toString() +  "-output.json";
	String inputFileName = harvesterSpoolDirectory + File.separator
			+ uuid.toString() + "-input.xml";

	File taxonFile = new File(taxonFileName);
	executionContext.put("taxon.file.name", taxonFile.getAbsolutePath());
	File imageFile = new File(imageFileName);
	executionContext.put("image.file.name", imageFile.getAbsolutePath());
	File inputFile = new File(inputFileName);
	executionContext.put("input.file.name", inputFile.getAbsolutePath());
	File outputFile = new File(outputFileName);
	executionContext.put("output.file.name", outputFile.getAbsolutePath());
	executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());

	return RepeatStatus.FINISHED;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:34,代码来源:SetTemporaryFilenamesTasklet.java

示例12: execute

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
 * @param contribution Set the step contribution
 * @param chunkContext Set the chunk context
 * @return the repeat status
 * @throws Exception if there is a problem deleting the resources
 */
public  RepeatStatus execute( StepContribution contribution, ChunkContext chunkContext)
		throws Exception {
	UUID uuid = UUID.randomUUID();
	String temporaryFileName = harvesterSpoolDirectory + File.separator
			+ uuid.toString() + "." + extension;

	File temporaryFile = new File(temporaryFileName);
	ExecutionContext executionContext = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext();
	executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
	executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
	return RepeatStatus.FINISHED;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:19,代码来源:SetTemporaryFilenameTasklet.java

示例13: getJobExecution

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
public static JobExecution getJobExecution() {
	JobInstance jobInstance = new JobInstance(Math.abs(new Random(100L).nextLong()), "sampleJob");
	JobExecution jobExecution = new JobExecution(jobInstance, 123L, JobParametersTestUtils.getJobParameters(), "abc");
	jobExecution.createStepExecution("sampleStep1");
	jobExecution.createStepExecution("sampleStep2");
	ExecutionContext ec = new ExecutionContext();
	ec.put("testName", "testValue");
	jobExecution.setExecutionContext(ec);
	return jobExecution;
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:11,代码来源:JobExecutionTestUtils.java

示例14: testStoreInteger

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
@Transactional
@Test
public void testStoreInteger() {
    ExecutionContext ec = new ExecutionContext();
    ec.put("intValue", 343232);
    stepExecution.setExecutionContext(ec);
    dao.saveExecutionContext(stepExecution);
    ExecutionContext restoredEc = dao.getExecutionContext(stepExecution);
    assertEquals(ec, restoredEc);
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:11,代码来源:MarkLogicExecutionContextDaoTests.java

示例15: execute

import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
 * @param contribution Set the step contribution
 * @param chunkContext Set the chunk context
 * @return the repeat status
 * @throws Exception if there is a problem deleting the resources
 */
public  RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
	UUID uuid = UUID.randomUUID();
	String temporaryFileName = harvesterSpoolDirectory + File.separator + uuid.toString() + "." + extension;

	File temporaryFile = new File(temporaryFileName);
	ExecutionContext executionContext = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext();
	executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
	executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
	log.debug("setting temporary.file.name to {}", temporaryFile.getAbsolutePath());
	return RepeatStatus.FINISHED;
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:18,代码来源:SetTemporaryFilenameTasklet.java


注:本文中的org.springframework.batch.item.ExecutionContext.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。