org.springframework.batch.item.ExecutionContext.putInt()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.springframework.batch.item.ExecutionContext.putInt()方法的一些代码示例,展示了ExecutionContext.putInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext.putInt()方法的具体详情如下:
包路径:org.springframework.batch.item.ExecutionContext
类名称:ExecutionContext
方法名:putInt

ExecutionContext.putInt介绍

[英]Adds an Integer value to the context.
[中]将整数值添加到上下文中。

代码示例

代码示例来源:origin: spring-projects/spring-batch

public void update(ExecutionContext executionContext) throws ItemStreamException {
  executionContext.putInt(EXPECTED, localState.expected.intValue());
  executionContext.putInt(ACTUAL, localState.actual.intValue());
}

代码示例来源:origin: spring-projects/spring-batch

@Override
  public void update(ExecutionContext executionContext) throws ItemStreamException {
    executionContext.putInt(CURRENT_INDEX, currentIndex);
  }
}

代码示例来源:origin: spring-projects/spring-batch

@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
  super.update(executionContext);
  if (saveState) {
    Assert.notNull(executionContext, "ExecutionContext must not be null");
    executionContext.putInt(getExecutionContextKey(READ_COUNT), currentItemCount);
    if (maxItemCount < Integer.MAX_VALUE) {
      executionContext.putInt(getExecutionContextKey(READ_COUNT_MAX), maxItemCount);
    }
  }
}

代码示例来源:origin: spring-projects/spring-batch

@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
      super.update(executionContext);
  executionContext.putInt(getExecutionContextKey("COUNT"), counter.get());
}

代码示例来源:origin: spring-projects/spring-batch

@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
  super.update(executionContext);
  if (saveState) {
    if (opened) {
      delegate.update(executionContext);
    }
    executionContext.putInt(getExecutionContextKey(CURRENT_RESOURCE_ITEM_COUNT), currentResourceItemCount);
    executionContext.putInt(getExecutionContextKey(RESOURCE_INDEX_KEY), resourceIndex);
  }
}

代码示例来源:origin: spring-projects/spring-batch

@Override
public Map<String, ExecutionContext> partition(int gridSize) {
  Map<String, ExecutionContext> partition = super.partition(gridSize);
  int total = 8; // The number of items in the ExampleItemReader
  int range = total/gridSize;
  int i = 0;
  for (ExecutionContext context : partition.values()) {
    int min = (i++)*range;
    int max = Math.min(total, i * range);
    context.putInt("min", min);
    context.putInt("max", max);
  }
  return partition;
}

代码示例来源:origin: spring-projects/spring-batch

public void update(ExecutionContext executionContext) {
  if (!executionContext.containsKey(UPDATE_COUNT_KEY)) {
    executionContext.putInt(UPDATE_COUNT_KEY, 0);
  }
  executionContext.putInt(UPDATE_COUNT_KEY, executionContext.getInt(UPDATE_COUNT_KEY) + 1);
}

代码示例来源:origin: spring-projects/spring-batch

@Override
  public void update(ExecutionContext executionContext) {
            super.update(executionContext);
    executionContext.putInt("counter", count++);
  }
});

代码示例来源:origin: spring-projects/spring-batch

/**
 * Store the current resource index and position in the resource.
 */
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
  super.update(executionContext);
  if (saveState) {
    executionContext.putInt(getExecutionContextKey(RESOURCE_KEY), currentResource);
    delegate.update(executionContext);
  }
}

代码示例来源:origin: spring-projects/spring-batch

public void update(ExecutionContext executionContext) {
  if (!executionContext.containsKey(UPDATE_COUNT_KEY)) {
    executionContext.putInt(UPDATE_COUNT_KEY, 0);
  }
  executionContext.putInt(UPDATE_COUNT_KEY
    , executionContext.getInt(UPDATE_COUNT_KEY) + 1
  );
}

代码示例来源:origin: spring-projects/spring-batch

@Test(expected = ItemStreamException.class)
public void testOpenWithErrorInReader() {
  monitor.setItemReader(new ItemReader<String>() {
    @Override
    public String read() throws Exception, UnexpectedInputException, ParseException {
      throw new IllegalStateException("Expected");
    }
  });
  ExecutionContext executionContext = new ExecutionContext();
  executionContext.putInt(ChunkMonitor.class.getName() + ".OFFSET", 2);
  monitor.open(executionContext);
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testCurrentItemCountFromContext() throws Exception {
  reader.setCurrentItemCount(2);
  executionContext.putInt(reader.getClass().getSimpleName() + ".read.count", 3);
  reader.open(executionContext);
  // read some records
  assertEquals("testLine4", reader.read());
  // close input
  reader.close();
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testOpen() {
  ExecutionContext executionContext = new ExecutionContext();
  executionContext.putInt(ChunkMonitor.class.getName() + ".OFFSET", 2);
  monitor.open(executionContext);
  assertEquals(2, count);
  assertEquals(0, monitor.getOffset());
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testMaxItemCountFromContext() throws Exception {
  reader.setMaxItemCount(2);
  executionContext.putInt(reader.getClass().getSimpleName() + ".read.count.max", Integer.MAX_VALUE);
  reader.open(executionContext);
  // read some records
  reader.read();
  reader.read();
  assertNotNull(reader.read());
  // close input
  reader.close();
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testReadToEndWithMax() throws Exception {
  ExecutionContext context = new ExecutionContext();
  context.putInt("foo.read.count.max", 1);
  reader.open(context);
  reader.read();
  assertNull(reader.read());
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testGetNamedIntJobParameters() throws Exception {
  stepExecution.getExecutionContext().putInt("foo",11);
  extractor.setKeys(new String[] {"foo(int)", "bar"});
  JobParameters jobParameters = extractor.getJobParameters(null, stepExecution);
  assertEquals("{foo=11}", jobParameters.toString());
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testUpdateWithMax() throws Exception {
  ExecutionContext context = new ExecutionContext();
  context.putInt("foo.read.count.max", 1);
  reader.open(context);
  reader.update(context);
  assertEquals(2, context.size());
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testReadAfterOpen() throws Exception {
  ExecutionContext executionContext = new ExecutionContext();
  executionContext.putInt(reader.getExecutionContextKey("COUNT"), 1);
  reader.open(executionContext);
  assertNotNull(reader.read());
  assertNull(reader.read());
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testReadAfterJumpSecondPage() throws Exception {
  executionContext.putInt(getName()+".read.count", 3);
  ((ItemStream)tested).open(executionContext);
  Foo foo5 = tested.read();
  Assert.assertEquals(5, foo5.getValue());
  Object o = tested.read();
  Assert.assertNull(o);
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testReadAfterJumpFirstPage() throws Exception {
  executionContext.putInt(getName()+".read.count", 2);
  ((ItemStream)tested).open(executionContext);
  Foo foo4 = tested.read();
  Assert.assertEquals(4, foo4.getValue());
  Foo foo5 = tested.read();
  Assert.assertEquals(5, foo5.getValue());
  Object o = tested.read();
  Assert.assertNull(o);
}

相关文章