public abstract class AbstractPagingItemReader<T> extends AbstractItemCountingItemStreamItemReader<T> implements org.springframework.beans.factory.InitializingBean
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.
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
protected java.util.List<T> |
results |
Constructor and Description |
---|
AbstractPagingItemReader() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Check mandatory properties.
|
protected void |
doClose()
Close the resources opened in
AbstractItemCountingItemStreamItemReader.doOpen() . |
protected abstract void |
doJumpToPage(int itemIndex) |
protected void |
doOpen()
Open resources necessary to start reading input.
|
protected T |
doRead()
Read next item from input.
|
protected abstract void |
doReadPage() |
int |
getPage()
The current page number.
|
int |
getPageSize()
The page size configured for this reader.
|
protected void |
jumpToItem(int itemIndex)
Move to the given item index.
|
void |
setPageSize(int pageSize)
The number of rows to retrieve at a time.
|
close, getCurrentItemCount, isSaveState, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, update
getExecutionContextKey, setExecutionContextName, setName
protected org.apache.commons.logging.Log logger
protected volatile java.util.List<T> results
public int getPage()
public int getPageSize()
public void setPageSize(int pageSize)
pageSize
- the number of rows to fetch per pagepublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
InitializingBean.afterPropertiesSet()
protected T doRead() throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
doRead
in class AbstractItemCountingItemStreamItemReader<T>
null
if the data source is exhaustedjava.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkprotected abstract void doReadPage()
protected void doOpen() throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
doOpen
in class AbstractItemCountingItemStreamItemReader<T>
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkprotected void doClose() throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
AbstractItemCountingItemStreamItemReader.doOpen()
.doClose
in class AbstractItemCountingItemStreamItemReader<T>
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkprotected void jumpToItem(int itemIndex) throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
AbstractItemCountingItemStreamItemReader.doRead()
.jumpToItem
in class AbstractItemCountingItemStreamItemReader<T>
itemIndex
- index of item (0 based) to jump to.java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkprotected abstract void doJumpToPage(int itemIndex)