javax.batch.api.chunk
Interface ItemReader<T>

Type Parameters:
T - specifies the item type returned by this reader.
All Known Implementing Classes:
AbstractItemReader

public interface ItemReader<T>

ItemReader defines the batch artifact that reads from a stream of item for chunk processing.


Method Summary
 Serializable checkpointInfo()
          The checkpointInfo method returns the current checkpoint position for this reader.
 void close()
          The close method marks the end of use of the item stream.
 void open(Serializable checkpoint)
          The open method prepare the reader to read items.
 T readItem()
          The readitem method returns the next item from the stream.
 

Method Detail

open

void open(Serializable checkpoint)
          throws Exception
The open method prepare the reader to read items. The input parameter represents the last checkpoint for this reader in a given job instance. The checkpoint data is defined by this reader and is provided by the checkpointInfo method. The checkpoint data instructs the reader where to reposition the stream upon job restart. A checkpoint value of null means reposition from the start of stream or rely on an application managed means of determining whether to position for start or restart. The persistent area of the StepContext may be used to implement application managed stream repositioning.

Parameters:
checkpoint - specifies the last checkpoint
Throws:
Exception - is thrown for any errors.

close

void close()
           throws Exception
The close method marks the end of use of the item stream. The reader is free to do any cleanup necessary on the stream.

Throws:
Exception - is thrown for any errors.

readItem

T readItem()
           throws Exception
The readitem method returns the next item from the stream. It returns null to indicate end of stream.

Returns:
next item or null
Throws:
Exception - is thrown for any errors.

checkpointInfo

Serializable checkpointInfo()
                            throws Exception
The checkpointInfo method returns the current checkpoint position for this reader. It is called before a chunk checkpoint is committed.

Returns:
checkpoint data
Throws:
Exception - is thrown for any errors.


Copyright © 2013. All Rights Reserved.