本文整理了Java中org.springframework.batch.item.ExecutionContext.getInt()
方法的一些代码示例,展示了ExecutionContext.getInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext.getInt()
方法的具体详情如下:
包路径:org.springframework.batch.item.ExecutionContext
类名称:ExecutionContext
方法名:getInt
[英]Typesafe Getter for the Integer represented by the provided key.
[中]由提供的键表示的整数的Typesafe Getter。
代码示例来源:origin: spring-projects/spring-batch
/**
* Typesafe Getter for the Integer represented by the provided key with
* default value to return if key is not represented.
*
* @param key The key to get a value for
* @param defaultInt Default to return if key is not represented
* @return The <code>int</code> value if key is represented, specified
* default otherwise
*/
public int getInt(String key, int defaultInt) {
if (!containsKey(key)) {
return defaultInt;
}
return getInt(key);
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
super.open(executionContext);
counter.set(executionContext.getInt(getExecutionContextKey("COUNT"), 0));
}
代码示例来源:origin: spring-projects/spring-batch
public void open(ExecutionContext executionContext) throws ItemStreamException {
if (executionContext.containsKey(EXPECTED)) {
localState.open(executionContext.getInt(EXPECTED), executionContext.getInt(ACTUAL));
if (!waitForResults()) {
throw new ItemStreamException("Timed out waiting for back log on open");
}
}
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
if(executionContext.containsKey(CURRENT_INDEX)){
currentIndex = executionContext.getInt(CURRENT_INDEX);
}
else{
currentIndex = 0;
}
}
代码示例来源:origin: spring-projects/spring-batch
private int extractRecordCount() {
return executionContext.getInt(ClassUtils.getShortName(StaxEventItemReader.class) + ".read.count");
}
代码示例来源: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
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
public void testUpdateAndOpenWithState() throws Exception {
ExecutionContext executionContext = new ExecutionContext();
writer.update(executionContext);
writer.open(executionContext);
assertEquals(0, executionContext.getInt(ChunkMessageChannelItemWriter.EXPECTED));
assertEquals(0, executionContext.getInt(ChunkMessageChannelItemWriter.ACTUAL));
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testUpdateAfterDelegateClose() throws Exception {
super.setUp(delegate);
tested.open(executionContext);
tested.update(executionContext);
assertEquals(0, executionContext.getInt(tested.getExecutionContextKey("resource.item.count")));
assertEquals(1, executionContext.getInt(tested.getExecutionContextKey("resource.index")));
tested.write(Arrays.asList("1", "2", "3"));
tested.update(executionContext);
assertEquals(0, executionContext.getInt(tested.getExecutionContextKey("resource.item.count")));
assertEquals(2, executionContext.getInt(tested.getExecutionContextKey("resource.index")));
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testUpdateAfterDelegateClose() throws Exception {
this.writer = new MultiResourceItemWriterBuilder<String>().delegate(this.delegate)
.resource(new FileSystemResource(this.file)).resourceSuffixCreator(this.suffixCreator)
.itemCountLimitPerResource(2).saveState(true).name("foo").build();
this.writer.update(this.executionContext);
assertEquals(0, this.executionContext.getInt(this.writer.getExecutionContextKey("resource.item.count")));
assertEquals(1, this.executionContext.getInt(this.writer.getExecutionContextKey("resource.index")));
this.writer.write(Arrays.asList("1", "2", "3"));
this.writer.update(this.executionContext);
assertEquals(0, this.executionContext.getInt(this.writer.getExecutionContextKey("resource.item.count")));
assertEquals(2, this.executionContext.getInt(this.writer.getExecutionContextKey("resource.index")));
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testSetName() throws Exception {
reader.setName("bar");
reader.read();
ExecutionContext context = new ExecutionContext();
reader.update(context);
assertEquals(1, context.getInt("bar.read.count"));
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testReadAndUpdate() throws Exception {
ExecutionContext executionContext = new ExecutionContext();
assertNotNull(reader.read());
reader.update(executionContext);
assertEquals(1, executionContext.getInt(reader.getExecutionContextKey("COUNT")));
}
代码示例来源:origin: spring-projects/spring-batch
/**
* Save restart data and restore from it.
*/
@Test
public void testRestart() throws Exception {
source.open(executionContext);
source.read();
source.update(executionContext);
assertEquals(1, executionContext.getInt(ClassUtils.getShortName(StaxEventItemReader.class) + ".read.count"));
List<XMLEvent> expectedAfterRestart = source.read();
source = createNewInputSource();
source.open(executionContext);
List<XMLEvent> afterRestart = source.read();
assertEquals(expectedAfterRestart.size(), afterRestart.size());
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testUpdate() throws Exception {
reader.read();
ExecutionContext context = new ExecutionContext();
reader.update(context);
assertEquals(1, context.size());
assertEquals(1, context.getInt("foo.read.count"));
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testCurrentItemCount() throws Exception {
reader.setCurrentItemCount(2);
reader.open(executionContext);
// read some records
reader.read();
reader.read();
// get restart data
reader.update(executionContext);
assertEquals(4, executionContext.getInt(ClassUtils.getShortName(FlatFileItemReader.class) + ".read.count"));
// close input
reader.close();
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testSaveState() throws Exception {
this.ldifReader = new LdifReaderBuilder().resource(context.getResource("classpath:/test.ldif")).name("foo").build();
ExecutionContext executionContext = new ExecutionContext();
firstRead(executionContext);
this.ldifReader.update(executionContext);
assertEquals("foo.read.count did not have the expected result", 1,
executionContext.getInt("foo.read.count"));
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testMaxItemCount() throws Exception {
reader.setMaxItemCount(2);
reader.open(executionContext);
// read some records
reader.read();
reader.read();
// get restart data
reader.update(executionContext);
assertNull(reader.read());
assertEquals(2, executionContext.getInt(ClassUtils.getShortName(FlatFileItemReader.class) + ".read.count"));
// close input
reader.close();
}
代码示例来源:origin: spring-projects/spring-batch
@Test
public void testSaveState() throws Exception {
this.mappingLdifReader = new MappingLdifReaderBuilder<LdapAttributes>()
.recordMapper(new TestMapper())
.resource(context.getResource("classpath:/test.ldif"))
.name("foo")
.build();
ExecutionContext executionContext = new ExecutionContext();
firstRead(executionContext);
this.mappingLdifReader.update(executionContext);
assertEquals("foo.read.count did not have the expected result", 1,
executionContext.getInt("foo.read.count"));
}
代码示例来源: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: spring-projects/spring-batch
/**
* Test restart at end of file.
*/
@Test
public void testRestartAtEndOfFile() throws Exception {
source.open(executionContext);
assertNotNull(source.read());
assertNotNull(source.read());
assertNull(source.read());
source.update(executionContext);
source.close();
assertEquals(3, executionContext.getInt(ClassUtils.getShortName(StaxEventItemReader.class) + ".read.count"));
source = createNewInputSource();
source.open(executionContext);
assertNull(source.read());
}
内容来源于网络,如有侵权,请联系作者删除!