|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.core.step.item.SimpleItemHandler org.springframework.batch.core.step.item.ItemSkipPolicyItemHandler
public class ItemSkipPolicyItemHandler
ItemHandler
that implements skip behavior. It delegates to
setItemSkipPolicy(ItemSkipPolicy)
to decide whether skip should be called or not.
If exception is thrown while reading the item, skip is called on the
ItemReader
. If exception is thrown while writing the item, skip is
called on both ItemReader
and ItemWriter
.
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
---|---|
ItemSkipPolicyItemHandler(ItemReader itemReader,
ItemWriter itemWriter)
|
Method Summary | |
---|---|
protected void |
doWriteWithSkip(Object item,
StepContribution contribution)
|
void |
mark()
Implementations should delegate to an ItemReader . |
protected Object |
read(StepContribution contribution)
Tries to read the item from the reader, in case of exception skip the item if the skip policy allows, otherwise re-throw. |
void |
registerSkipListener(SkipListener listener)
Register a listener for callbacks at the appropriate stages in a skip process. |
void |
setItemKeyGenerator(ItemKeyGenerator itemKeyGenerator)
Public setter for the ItemKeyGenerator . |
void |
setItemSkipPolicy(ItemSkipPolicy itemSkipPolicy)
|
void |
setSkipCacheCapacity(int skipCacheCapacity)
Public setter for the capacity of the skipped item cache. |
void |
setSkipListeners(SkipListener[] listeners)
Register some SkipListener s with the handler. |
protected void |
write(Object item,
StepContribution contribution)
Tries to write the item using the writer. |
Methods inherited from class org.springframework.batch.core.step.item.SimpleItemHandler |
---|
clear, doRead, doWrite, flush, handle, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log logger
Constructor Detail |
---|
public ItemSkipPolicyItemHandler(ItemReader itemReader, ItemWriter itemWriter)
itemReader
- itemWriter
- Method Detail |
---|
public void setSkipListeners(SkipListener[] listeners)
SkipListener
s with the handler. Each will get the
callbacks in the order specified at the correct stage if a skip occurs.
listeners
- public void registerSkipListener(SkipListener listener)
listener
- a SkipListener
public void setItemKeyGenerator(ItemKeyGenerator itemKeyGenerator)
ItemKeyGenerator
. Defaults to just return
the item, and since it will be used before a write operation.
Implementations must ensure that items always have the same key when they
are read from the ItemReader
(so if the item is mutable and the
reader does any buffering the key generator might need to take care to
only use data that do not change on write).
itemKeyGenerator
- the ItemKeyGenerator
to set. If null
resets to default value.public void setItemSkipPolicy(ItemSkipPolicy itemSkipPolicy)
itemSkipPolicy
- public void setSkipCacheCapacity(int skipCacheCapacity)
skipCacheCapacity
- the capacity to setprotected Object read(StepContribution contribution) throws Exception
read
in class SimpleItemHandler
contribution
- current StepContribution holding skipped items count
Exception
protected void write(Object item, StepContribution contribution) throws Exception
write
in class SimpleItemHandler
item
- item to writecontribution
- current StepContribution holding skipped items count
Exception
protected final void doWriteWithSkip(Object item, StepContribution contribution) throws Exception
item
- contribution
-
Exception
public void mark() throws MarkFailedException
ItemHandler
ItemReader
.
mark
in interface ItemHandler
mark
in class SimpleItemHandler
MarkFailedException
ItemReader.mark()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |