@Override public void update(ExecutionContext executionContext) throws ItemStreamException { super.update(executionContext); if (saveState) { Assert.notNull(executionContext, "ExecutionContext must not be null"); executionContext.putInt(getExecutionContextKey(WRITE_COUNT), currentItemCount); if (maxItemCount < Integer.MAX_VALUE) { executionContext.putInt(getExecutionContextKey(WRITE_COUNT_MAX), maxItemCount); } } }
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { super.open(executionContext); try { doOpen(); } catch (Exception e) { throw new ItemStreamException("Failed to initialize the writer", e); } if (!isSaveState()) { return; } if (executionContext.containsKey(getExecutionContextKey(WRITE_COUNT_MAX))) { maxItemCount = executionContext.getInt(getExecutionContextKey(WRITE_COUNT_MAX)); } if (executionContext.containsKey(getExecutionContextKey(WRITE_COUNT))) { int itemCount = executionContext.getInt(getExecutionContextKey(WRITE_COUNT)); currentItemCount = itemCount; if (itemCount < maxItemCount) { try { jumpToItem(itemCount); } catch (Exception e) { throw new ItemStreamException("Could not move to stored position on restart", e); } } } }