org.springframework.batch.item.ItemReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-batch-infrastructure
Show all versions of spring-batch-infrastructure
The Spring Batch Infrastructure is a set of low-level components, interfaces and tools for batch processing applications and optimisations.
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.item;
/**
* Strategy interface for providing the data.
*
* Implementations are expected to be stateful and will be called multiple times
* for each batch, with each call to {@link #read()} returning a different value
* and finally returning null
when all input data is
* exhausted.
*
* Implementations need *not* be thread safe and clients of a {@link ItemReader}
* need to be aware that this is the case.
*
* A richer interface (e.g. with a look ahead or peek) is not feasible because
* we need to support transactions in an asynchronous batch.
*
* @author Rob Harrop
* @author Dave Syer
* @author Lucas Ward
* @since 1.0
*/
public interface ItemReader {
/**
* Reads a piece of input data and advance to the next one. Implementations
* must return null
at the end of the input
* data set. In a transactional setting, caller might get the same item
* twice from successive calls (or otherwise), if the first call was in a
* transaction that rolled back.
*
* @throws Exception if an underlying resource is unavailable.
*/
T read() throws Exception, UnexpectedInputException, ParseException;
}