|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.batch.retry.policy.AbstractStatefulRetryPolicy
org.springframework.batch.retry.policy.ItemWriterRetryPolicy
public class ItemWriterRetryPolicy
A RetryPolicy
that detects an ItemWriterRetryCallback
when it
opens a new context, and uses it to make sure the item is in place for later
decisions about how to retry or backoff. The callback should be an instance
of ItemWriterRetryCallback
otherwise an exception will be thrown when
the context is created.
Field Summary | |
---|---|
static String |
EXHAUSTED
|
protected org.apache.commons.logging.Log |
logger
|
Fields inherited from class org.springframework.batch.retry.policy.AbstractStatefulRetryPolicy |
---|
retryContextCache |
Constructor Summary | |
---|---|
ItemWriterRetryPolicy()
Default constructor. |
|
ItemWriterRetryPolicy(RetryPolicy delegate)
Convenience constructor to set delegate on init. |
Method Summary | |
---|---|
boolean |
canRetry(RetryContext context)
Check the history of this item, and if it has reached the retry limit, then return false. |
void |
close(RetryContext context)
Delegates to the delegate context. |
Object |
handleRetryExhausted(RetryContext context)
Call recovery path (if any) and clean up context history. |
protected boolean |
hasFailed(FailedItemIdentifier failedItemIdentifier,
Object key)
Extension point for cases where it is possible to avoid a cache hit by inspecting the item to determine if could ever have been seen before. |
RetryContext |
open(RetryCallback callback,
RetryContext parent)
Create a new context for the execution of the callback, which must be an instance of ItemWriterRetryCallback . |
void |
registerThrowable(RetryContext context,
Throwable throwable)
If canRetry(RetryContext) is false then take remedial action (if
implemented by subclasses), and remove the current item from the history. |
void |
setDelegate(RetryPolicy delegate)
Setter for delegate. |
Methods inherited from class org.springframework.batch.retry.policy.AbstractStatefulRetryPolicy |
---|
recoverForException, setRecoverableExceptionClasses, setRetryContextCache, shouldRethrow |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.apache.commons.logging.Log logger
public static final String EXHAUSTED
Constructor Detail |
---|
public ItemWriterRetryPolicy(RetryPolicy delegate)
delegate
- public ItemWriterRetryPolicy()
SimpleRetryPolicy
for the
delegate.
Method Detail |
---|
public void setDelegate(RetryPolicy delegate)
delegate
- public boolean canRetry(RetryContext context)
context
- the current retry status
RetryPolicy.canRetry(org.springframework.batch.retry.RetryContext)
public void close(RetryContext context)
context
- a retry status created by the RetryPolicy.open(RetryCallback, RetryContext)
method of this manager.RetryPolicy.close(org.springframework.batch.retry.RetryContext)
public RetryContext open(RetryCallback callback, RetryContext parent)
ItemWriterRetryCallback
.
callback
- the RetryCallback
that will execute the unit of
work for this retry.parent
- the parent context if we are in a nested retry.
RetryContext
object specific to this manager.
IllegalStateException
- if the callback is not of the required
type.RetryPolicy.open(org.springframework.batch.retry.RetryCallback,
RetryContext)
public void registerThrowable(RetryContext context, Throwable throwable) throws TerminatedRetryException
canRetry(RetryContext)
is false then take remedial action (if
implemented by subclasses), and remove the current item from the history.
context
- the current status object.
TerminatedRetryException
- if the status is set to terminate only.RetryPolicy.registerThrowable(org.springframework.batch.retry.RetryContext,
java.lang.Throwable)
public Object handleRetryExhausted(RetryContext context) throws Exception
handleRetryExhausted
in interface RetryPolicy
handleRetryExhausted
in class AbstractStatefulRetryPolicy
context
- the current retry context.
Exception
- if there is no recovery path.AbstractStatefulRetryPolicy.handleRetryExhausted(org.springframework.batch.retry.RetryContext)
protected boolean hasFailed(FailedItemIdentifier failedItemIdentifier, Object key)
FailedItemIdentifier
. Otherwise we just check the cache for the
item key.
failedItemIdentifier
- key
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |