@Override
  public void open(ExecutionContext executionContext) throws ItemStreamException {
    super.open(executionContext);
    try {
      doOpen();
    } catch (Exception e) {
      throw new ItemStreamException("Failed to initialize the reader", e);
    }
    if (!isSaveState()) {
      return;
    }

    if (executionContext.containsKey(getExecutionContextKey(READ_COUNT_MAX))) {
      maxItemCount = executionContext.getInt(getExecutionContextKey(READ_COUNT_MAX));
    }

    if (executionContext.containsKey(getExecutionContextKey(READ_COUNT))) {
      int itemCount = executionContext.getInt(getExecutionContextKey(READ_COUNT));

      if (itemCount < maxItemCount) {
        try {
          jumpToItem(itemCount);
        } catch (Exception e) {
          throw new ItemStreamException("Could not move to stored position on restart", e);
        }
      }
      currentItemCount = itemCount;
    }
  }
 @Override
 public void close() throws ItemStreamException {
   super.close();
   currentItemCount = 0;
   try {
     doClose();
   } catch (Exception e) {
     throw new ItemStreamException("Error while closing item reader", e);
   }
 }
 @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);
     }
   }
 }