本文整理了Java中org.springframework.batch.item.ExecutionContext.put()
方法的一些代码示例,展示了ExecutionContext.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext.put()
方法的具体详情如下:
包路径:org.springframework.batch.item.ExecutionContext
类名称:ExecutionContext
方法名:put
[英]Add an Object value to the context. Putting null
value for a given key removes the key.
[中]将对象值添加到上下文中。为给定键放入null
值将删除该键。
代码示例来源:origin: spring-projects/spring-batch
/**
* Add a Double value to the context.
*
* @param key Key to add to context
* @param value Value to associate with key
*/
public void putDouble(String key, double value) {
put(key, value);
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public Map<String, ExecutionContext> partition(int gridSize) {
Map<String, ExecutionContext> partitions = super.partition(gridSize);
int i = 0;
for (ExecutionContext context : partitions.values()) {
context.put(PARTITION_KEY, PARTITION_KEY + (i++));
}
return partitions;
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void beforeJob(JobExecution jobExecution) {
ExecutionContext jobContext = jobExecution.getExecutionContext();
for (Map.Entry<String, Object> entry : jobExecutionContext.entrySet()) {
jobContext.put(entry.getKey(), entry.getValue());
}
}
} });
代码示例来源:origin: spring-projects/spring-batch
public void open(ExecutionContext executionContext) {
this.isClosed = false;
executionContext.put(HAS_BEEN_OPENED, true);
executionContext.remove(UPDATE_COUNT_KEY);
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testUpdate() throws Exception {
when(delegate.checkpointInfo()).thenReturn("checkpoint");
adapter.update(executionContext);
verify(executionContext).put("jsrReader.reader.checkpoint", "checkpoint");
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testUpdate() throws Exception {
when(delegate.checkpointInfo()).thenReturn("checkpoint");
adapter.update(executionContext);
verify(executionContext).put("jsrWriter.writer.checkpoint", "checkpoint");
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public Void doInTransaction(TransactionStatus status) {
stepExecution.getExecutionContext().put("foo", "bar");
dao.saveExecutionContext(stepExecution);
return null;
}
});
代码示例来源:origin: spring-projects/spring-batch
@Override
@Test
public void testReadAfterJumpSecondPage() throws Exception {
executionContext.put(getName() + ".start.after", Collections.<String, Object>singletonMap("ID", 4));
super.testReadAfterJumpSecondPage();
}
代码示例来源:origin: spring-projects/spring-batch
private void start(String foo) {
StepSynchronizationManager.close();
stepExecution = new StepExecution("foo", new JobExecution(11L), 123L);
ExecutionContext executionContext = new ExecutionContext();
executionContext.put("foo", foo);
executionContext.put("type", TestCollaborator.class.getName());
stepExecution.setExecutionContext(executionContext);
StepSynchronizationManager.register(stepExecution);
beanCount = beanFactory.getBeanDefinitionCount();
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testFromStepInJob() throws Exception {
Date date = new Date();
JobExecution jobExecution = MetaDataInstanceFactory.createJobExecutionWithStepExecutions(123L, Arrays.asList("foo", "bar"));
StepExecution stepExecution = jobExecution.createStepExecution("spam");
stepExecution.getExecutionContext().put("foo", date);
Date result = ExecutionContextTestUtils.getValueFromStepInJob(jobExecution, "spam", "foo");
assertEquals(date, result);
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testJobExecutionContext() throws Exception {
ExecutionContext executionContext = stepExecution.getJobExecution().getExecutionContext();
executionContext.put("foo", "bar");
assertEquals("bar", context.getJobExecutionContext().get("foo"));
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testCopyConstructor() throws Exception {
ExecutionContext context = new ExecutionContext();
context.put("foo", "bar");
ExecutionContext copy = new ExecutionContext(context);
assertEquals(copy, context);
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testGetNamedJobParameters() throws Exception {
stepExecution.getExecutionContext().put("foo", "bar");
extractor.setKeys(new String[] {"foo", "bar"});
JobParameters jobParameters = extractor.getJobParameters(null, stepExecution);
assertEquals("{foo=bar}", jobParameters.toString());
}
代码示例来源:origin: spring-projects/spring-batch
@Before
public void start() {
JobSynchronizationManager.close();
jobExecution = new JobExecution(123L);
ExecutionContext executionContext = new ExecutionContext();
executionContext.put("foo", "bar");
jobExecution.setExecutionContext(executionContext);
JobSynchronizationManager.register(jobExecution);
beanCount = beanFactory.getBeanDefinitionCount();
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void execute(StepExecution stepExecution) throws JobInterruptedException {
if (!stepExecution.getJobExecution().getExecutionContext().containsKey("STOPPED")) {
stepExecution.getJobExecution().getExecutionContext().put("STOPPED", true);
stepExecution.setStatus(BatchStatus.STOPPED);
jobRepository.update(stepExecution);
}
else {
fail("The Job should have stopped by now");
}
}
}), "end0"));
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testSimpleProperty() throws Exception {
StepExecution stepExecution = new StepExecution("step", new JobExecution(0L), 123L);
ExecutionContext executionContext = stepExecution.getExecutionContext();
executionContext.put("foo", "bar");
StepSynchronizationManager.register(stepExecution);
assertEquals("bar", simple.getName());
}
代码示例来源:origin: spring-projects/spring-batch
@Before
public void start() {
StepSynchronizationManager.close();
stepExecution = new StepExecution("foo", new JobExecution(11L), 123L);
ExecutionContext executionContext = new ExecutionContext();
executionContext.put("foo", "bar");
stepExecution.setExecutionContext(executionContext);
StepSynchronizationManager.register(stepExecution);
beanCount = beanFactory.getBeanDefinitionCount();
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testSaveUpdate() throws Exception {
StepExecution stepExecution = new StepExecution("step", new JobExecution(11L));
stepExecution.setId(123L);
stepExecution.getExecutionContext().put("foo", "bar");
dao.saveExecutionContext(stepExecution);
ExecutionContext executionContext = dao.getExecutionContext(stepExecution);
assertEquals("bar", executionContext.get("foo"));
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testCycle() throws Exception {
StepExecution stepExecution = new StepExecution("step", new JobExecution(new JobInstance(123L,
"job"), 321L, new JobParameters(), null), 11L);
stepExecution.getExecutionContext().put("foo.bar.spam", 123);
StepExecution result = getCopy(stepExecution);
assertEquals(stepExecution, result);
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testExecutionContext() throws Exception {
StepExecution stepExecution = new StepExecution("foo", new JobExecution(11L), 1L);
ExecutionContext executionContext = new ExecutionContext();
executionContext.put("name", "spam");
stepExecution.setExecutionContext(executionContext);
proxied.execute(stepExecution);
assertTrue(TestStep.getContext().attributeNames().length > 0);
String collaborator = (String) TestStep.getContext().getAttribute("collaborator");
assertNotNull(collaborator);
assertEquals("bar", collaborator);
}
内容来源于网络,如有侵权,请联系作者删除!