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 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
public int getPage()
public int getPageSize()
public void setPageSize(int pageSize)
pageSize
- the number of rows to fetch per pagepublic void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
InitializingBean.afterPropertiesSet()
protected T doRead() throws Exception
AbstractItemCountingItemStreamItemReader
doRead
in class AbstractItemCountingItemStreamItemReader<T>
Exception
protected abstract void doReadPage()
protected void doOpen() throws Exception
AbstractItemCountingItemStreamItemReader
doOpen
in class AbstractItemCountingItemStreamItemReader<T>
Exception
protected void doClose() throws Exception
AbstractItemCountingItemStreamItemReader
AbstractItemCountingItemStreamItemReader.doOpen()
.doClose
in class AbstractItemCountingItemStreamItemReader<T>
Exception
protected void jumpToItem(int itemIndex) throws Exception
AbstractItemCountingItemStreamItemReader
AbstractItemCountingItemStreamItemReader.doRead()
.jumpToItem
in class AbstractItemCountingItemStreamItemReader<T>
Exception
protected abstract void doJumpToPage(int itemIndex)
Copyright © 2014 Pivotal. All rights reserved.