本文整理了Java中org.springframework.batch.item.ExecutionContext.putLong()
方法的一些代码示例,展示了ExecutionContext.putLong()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext.putLong()
方法的具体详情如下:
包路径:org.springframework.batch.item.ExecutionContext
类名称:ExecutionContext
方法名:putLong
[英]Adds a Long value to the context.
[中]向上下文添加长值。
代码示例来源:origin: spring-projects/spring-batch
public void update(ExecutionContext executionContext) throws ItemStreamException {
executionContext.putLong("POSITION", index);
}
代码示例来源:origin: spring-projects/spring-batch
/**
* Get the restart data.
*
* @param executionContext the batch context.
*
* @see org.springframework.batch.item.ItemStream#update(ExecutionContext)
*/
@Override
public void update(ExecutionContext executionContext) {
super.update(executionContext);
if (saveState) {
Assert.notNull(executionContext, "ExecutionContext must not be null");
executionContext.putLong(getExecutionContextKey(RESTART_DATA_NAME), getPosition());
executionContext.putLong(getExecutionContextKey(WRITE_STATISTICS_NAME), currentRecordCount);
if (!unclosedHeaderCallbackElements.isEmpty()) {
executionContext.put(getExecutionContextKey(UNCLOSED_HEADER_CALLBACK_ELEMENTS_NAME),
unclosedHeaderCallbackElements);
}
}
}
代码示例来源:origin: spring-projects/spring-batch
/**
* @see ItemStream#update(ExecutionContext)
*/
@Override
public void update(ExecutionContext executionContext) {
super.update(executionContext);
if (state == null) {
throw new ItemStreamException("ItemStream not open or already closed.");
}
Assert.notNull(executionContext, "ExecutionContext must not be null");
if (saveState) {
try {
executionContext.putLong(getExecutionContextKey(RESTART_DATA_NAME), state.position());
}
catch (IOException e) {
throw new ItemStreamException("ItemStream does not return current position properly", e);
}
executionContext.putLong(getExecutionContextKey(WRITTEN_STATISTICS_NAME), state.linesWritten);
}
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
super.update(executionContext);
executionContext.putLong(getExecutionContextKey("POSITION"), index);
}
代码示例来源:origin: spring-projects/spring-batch
context.putLong(key, splitSize);
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testInvalidCast() {
context.putLong("1", 1);
try {
context.getDouble("1");
fail();
}
catch (ClassCastException ex) {
// expected
}
}
代码示例来源:origin: spring-projects/spring-batch
@Transactional
@Test
public void testUpdateStepContext() {
ExecutionContext ctx = new ExecutionContext(Collections.<String, Object> singletonMap("key", "value"));
stepExecution.setExecutionContext(ctx);
contextDao.saveExecutionContext(stepExecution);
ctx.putLong("longKey", 7);
contextDao.updateExecutionContext(stepExecution);
ExecutionContext retrieved = contextDao.getExecutionContext(stepExecution);
assertEquals(ctx, retrieved);
assertEquals(7, retrieved.getLong("longKey"));
}
代码示例来源:origin: spring-projects/spring-batch
@Transactional
@Test
public void testUpdateContext() {
ExecutionContext ctx = new ExecutionContext(Collections
.<String, Object> singletonMap("key", "value"));
jobExecution.setExecutionContext(ctx);
contextDao.saveExecutionContext(jobExecution);
ctx.putLong("longKey", 7);
contextDao.updateExecutionContext(jobExecution);
ExecutionContext retrieved = contextDao.getExecutionContext(jobExecution);
assertEquals(ctx, retrieved);
assertEquals(7, retrieved.getLong("longKey"));
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testGetNamedLongJobParameters() throws Exception {
stepExecution.getExecutionContext().putLong("foo",11L);
extractor.setKeys(new String[] {"foo(long)", "bar"});
JobParameters jobParameters = extractor.getJobParameters(null, stepExecution);
assertEquals("{foo=11}", jobParameters.toString());
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testSerialization() {
TestSerializable s = new TestSerializable();
s.value = 7;
context.putString("1", "testString1");
context.putString("2", "testString2");
context.putLong("3", 3);
context.putDouble("4", 4.4);
context.put("5", s);
context.putInt("6", 6);
byte[] serialized = SerializationUtils.serialize(context);
ExecutionContext deserialized = (ExecutionContext) SerializationUtils.deserialize(serialized);
assertEquals(context, deserialized);
assertEquals(7, ((TestSerializable) deserialized.get("5")).value);
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testNormalUsage() {
context.putString("1", "testString1");
context.putString("2", "testString2");
context.putLong("3", 3);
context.putDouble("4", 4.4);
context.putInt("5", 5);
assertEquals("testString1", context.getString("1"));
assertEquals("testString2", context.getString("2"));
assertEquals("defaultString", context.getString("55", "defaultString"));
assertEquals(4.4, context.getDouble("4"), 0);
assertEquals(5.5, context.getDouble("55", 5.5), 0);
assertEquals(3, context.getLong("3"));
assertEquals(5, context.getLong("55", 5));
assertEquals(5, context.getInt("5"));
assertEquals(6, context.getInt("55", 6));
}
代码示例来源:origin: xuminwlt/j360-dubbo-app-all
@Override
public void beforeStep(StepExecution stepExecution) {
//使用环境容器自定义变量
stepExecution.getExecutionContext().putLong("id", 100L);
}
代码示例来源:origin: cmlbeliever/SpringBatch
/**
* STEP参数保存
*
* @param exitStatus
*/
public void saveStepParameter(String key, long Value) {
this.getExecutionContext().putLong(key, Value);
}
代码示例来源:origin: pl.edu.icm.synat/synat-importer-yadda
protected void processBeforeStep(Map<String, String> stateMap, StepExecution execution) {
Map<String, Object> executionContext = context.getContext(execution.getJobExecution());
if (executionContext.containsKey(IMPORT_INITIALIZATION_STATUS)) {
return;
}
String lastTimestamp = stateMap.get(HBASE_LAST_TIMESTAMP);
executionContext.put(HBASE_CURRENT_TIMESTAMP, System.currentTimeMillis());
executionContext.put(IMPORT_INITIALIZATION_STATUS, true);
if (!StringUtils.isBlank(lastTimestamp)) {
execution.getJobExecution().getExecutionContext().putLong(HBASE_LAST_TIMESTAMP, Long.parseLong(lastTimestamp));
}
}
代码示例来源:origin: cmlbeliever/SpringBatch
/**
* STEP参数保存
*
* @param exitStatus
*/
public void saveStepParameter(String key, long Value) {
this.stepExecution.getJobExecution().getExecutionContext().putLong(key, Value);
}
代码示例来源:origin: cmlbeliever/SpringBatch
/**
* STEP参数保存
*
* @param exitStatus
*/
public void saveStepParameter(String key, long Value) {
this.stepExecution.getJobExecution().getExecutionContext().putLong(key, Value);
}
代码示例来源:origin: cmlbeliever/SpringBatch
/**
* STEP参数保存
*
* @param exitStatus
*/
public void saveStepParameter(String key, long Value) {
this.stepExecution.getJobExecution().getExecutionContext().putLong(key, Value);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Get the restart data.
*
* @param executionContext the batch context.
*
* @see org.springframework.batch.item.ItemStream#update(ExecutionContext)
*/
@Override
public void update(ExecutionContext executionContext) {
super.update(executionContext);
if (saveState) {
Assert.notNull(executionContext, "ExecutionContext must not be null");
executionContext.putLong(getExecutionContextKey(RESTART_DATA_NAME), getPosition());
executionContext.putLong(getExecutionContextKey(WRITE_STATISTICS_NAME), currentRecordCount);
if (!unclosedHeaderCallbackElements.isEmpty()) {
executionContext.put(getExecutionContextKey(UNCLOSED_HEADER_CALLBACK_ELEMENTS_NAME),
unclosedHeaderCallbackElements);
}
}
}
代码示例来源:origin: apache/servicemix-bundles
/**
* @see ItemStream#update(ExecutionContext)
*/
@Override
public void update(ExecutionContext executionContext) {
super.update(executionContext);
if (state == null) {
throw new ItemStreamException("ItemStream not open or already closed.");
}
Assert.notNull(executionContext, "ExecutionContext must not be null");
if (saveState) {
try {
executionContext.putLong(getExecutionContextKey(RESTART_DATA_NAME), state.position());
}
catch (IOException e) {
throw new ItemStreamException("ItemStream does not return current position properly", e);
}
executionContext.putLong(getExecutionContextKey(WRITTEN_STATISTICS_NAME), state.linesWritten);
}
}
代码示例来源:origin: org.springframework.batch/spring-batch-core
context.putLong(key, splitSize);
内容来源于网络,如有侵权,请联系作者删除!