@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;
    }
  }
Ejemplo n.º 2
0
 @Override
 public void open(ExecutionContext executionContext) throws ItemStreamException {
   counter.set(executionContext.getInt(getKey("COUNT"), 0));
 }