class ResourcesItemReader extends AbstractItemStreamItemReader<Resource> {

	private static final String COUNT_KEY = "COUNT";

	private Resource[] resources = new Resource[0];

	private final AtomicInteger counter = new AtomicInteger(0);

	public ResourcesItemReader() {
		/*
		 * Initialize the name for the key in the execution context.
		 */
		this.setExecutionContextName(getClass().getName());
	}

	/**
	 * The resources to serve up as items. Hint: use a pattern to configure.
	 * @param resources the resources
	 */
	public void setResources(Resource[] resources) {
		this.resources = Arrays.asList(resources).toArray(new Resource[resources.length]);
	}

	/**
	 * Increments a counter and returns the next {@link Resource} instance from the input,
	 * or {@code null} if none remain.
	 */
	@Override
	@Nullable
	public synchronized Resource read() throws Exception {<FILL_FUNCTION_BODY>}

	@Override
	public void open(ExecutionContext executionContext) throws ItemStreamException {
		super.open(executionContext);
		counter.set(executionContext.getInt(getExecutionContextKey(COUNT_KEY), 0));
	}

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

}

		int index = counter.incrementAndGet() - 1;
		if (index >= resources.length) {
			return null;
		}
		return resources[index];
	
<methods>public non-sealed void <init>() <variables>