Class AbstractPagingItemReader<T>
java.lang.Object
org.springframework.batch.item.ItemStreamSupport
org.springframework.batch.item.support.AbstractItemStreamItemReader<T>
org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>
org.springframework.batch.item.database.AbstractPagingItemReader<T>
- All Implemented Interfaces:
- ItemReader<T>,- ItemStream,- ItemStreamReader<T>,- org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
- JdbcPagingItemReader,- JpaPagingItemReader
public abstract class AbstractPagingItemReader<T>
extends AbstractItemCountingItemStreamItemReader<T>
implements org.springframework.beans.factory.InitializingBean
Abstract 
ItemStreamReader for to extend when
 reading database records in a paging fashion.
 
 Implementations should execute queries using paged requests of a size specified in
 setPageSize(int). Additional pages are requested when needed as
 AbstractItemCountingItemStreamItemReader.read() method is called, returning an object corresponding to current
 position.
 
- Since:
- 2.0
- Author:
- Thomas Risberg, Dave Syer, Mahmoud Ben Hassine
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidCheck mandatory properties.protected voiddoClose()Close the resources opened inAbstractItemCountingItemStreamItemReader.doOpen().protected voiddoOpen()Open resources necessary to start reading input.protected TdoRead()Read next item from input.protected abstract voidintgetPage()The current page number.intThe page size configured for this reader.protected voidjumpToItem(int itemIndex) Move to the given item index.voidsetPageSize(int pageSize) The number of rows to retrieve at a time.Methods inherited from class org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReaderclose, getCurrentItemCount, isSaveState, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, updateMethods inherited from class org.springframework.batch.item.ItemStreamSupportgetExecutionContextKey, getName, setExecutionContextName, setName
- 
Field Details- 
loggerprotected org.apache.commons.logging.Log logger
- 
results
 
- 
- 
Constructor Details- 
AbstractPagingItemReaderpublic AbstractPagingItemReader()
 
- 
- 
Method Details- 
getPagepublic int getPage()The current page number.- Returns:
- the current page
 
- 
getPageSizepublic int getPageSize()The page size configured for this reader.- Returns:
- the page size
 
- 
setPageSizepublic void setPageSize(int pageSize) The number of rows to retrieve at a time.- Parameters:
- pageSize- the number of rows to fetch per page
 
- 
afterPropertiesSetCheck mandatory properties.- Specified by:
- afterPropertiesSetin interface- org.springframework.beans.factory.InitializingBean
- Throws:
- Exception
- See Also:
- 
- InitializingBean.afterPropertiesSet()
 
 
- 
doReadDescription copied from class:AbstractItemCountingItemStreamItemReaderRead next item from input.- Specified by:
- doReadin class- AbstractItemCountingItemStreamItemReader<T>
- Returns:
- an item or nullif the data source is exhausted
- Throws:
- Exception- Allows subclasses to throw checked exceptions for interpretation by the framework
 
- 
doReadPageprotected abstract void doReadPage()
- 
doOpenDescription copied from class:AbstractItemCountingItemStreamItemReaderOpen resources necessary to start reading input.- Specified by:
- doOpenin class- AbstractItemCountingItemStreamItemReader<T>
- Throws:
- Exception- Allows subclasses to throw checked exceptions for interpretation by the framework
 
- 
doCloseDescription copied from class:AbstractItemCountingItemStreamItemReaderClose the resources opened inAbstractItemCountingItemStreamItemReader.doOpen().- Specified by:
- doClosein class- AbstractItemCountingItemStreamItemReader<T>
- Throws:
- Exception- Allows subclasses to throw checked exceptions for interpretation by the framework
 
- 
jumpToItemDescription copied from class:AbstractItemCountingItemStreamItemReaderMove to the given item index. Subclasses should override this method if there is a more efficient way of moving to given index than re-reading the input usingAbstractItemCountingItemStreamItemReader.doRead().- Overrides:
- jumpToItemin class- AbstractItemCountingItemStreamItemReader<T>
- Parameters:
- itemIndex- index of item (0 based) to jump to.
- Throws:
- Exception- Allows subclasses to throw checked exceptions for interpretation by the framework
 
 
-