org.springframework.batch.retry
Interface RetryPolicy

All Known Implementing Classes:
AbstractStatefulRetryPolicy, AbstractStatelessRetryPolicy, AlwaysRetryPolicy, CompositeRetryPolicy, ExceptionClassifierRetryPolicy, NeverRetryPolicy, RecoveryCallbackRetryPolicy, SimpleRetryPolicy, TimeoutRetryPolicy

public interface RetryPolicy

A RetryPolicy is responsible for allocating and managing resources needed by RetryOperations. The RetryPolicy allows retry operations to be aware of their context. Context can be internal to the retry framework, e.g. to support nested retries. Context can also be external, and the RetryPolicy provides a uniform API for a range of different platforms for the external context.

Author:
Dave Syer

Method Summary
 boolean canRetry(RetryContext context)
           
 void close(RetryContext context)
           
 Object handleRetryExhausted(RetryContext context)
          Handle an exhausted retry.
 RetryContext open(RetryCallback callback, RetryContext parent)
          Acquire resources needed for the retry operation.
 void registerThrowable(RetryContext context, Throwable throwable)
          Called once per retry attempt, after the callback fails.
 boolean shouldRethrow(RetryContext context)
           
 

Method Detail

canRetry

boolean canRetry(RetryContext context)
Parameters:
context - the current retry status
Returns:
true if the operation can proceed

shouldRethrow

boolean shouldRethrow(RetryContext context)
Parameters:
context - the current context.
Returns:
true if the policy determines that the last exception should be re-thrown.

open

RetryContext open(RetryCallback callback,
                  RetryContext parent)
Acquire resources needed for the retry operation. The callback is passed in so that marker interfaces can be used and a manager can collaborate with the callback to set up some state in the status token.

Parameters:
callback - the RetryCallback that will execute the unit of work for this retry.
parent - the parent context if we are in a nested retry.
Returns:
a RetryContext object specific to this manager.

close

void close(RetryContext context)
Parameters:
context - a retry status created by the open(RetryCallback, RetryContext) method of this manager.

registerThrowable

void registerThrowable(RetryContext context,
                       Throwable throwable)
                       throws TerminatedRetryException
Called once per retry attempt, after the callback fails.

Parameters:
context - the current status object.
Throws:
TerminatedRetryException - if the status is set to terminate only.

handleRetryExhausted

Object handleRetryExhausted(RetryContext context)
                            throws ExhaustedRetryException
Handle an exhausted retry. Default will be to throw an exception, but implementations may provide recovery path.

Parameters:
context - the current retry context.
Returns:
an appropriate value possibly from the callback.
Throws:
ExhaustedRetryException - if there is no recovery path.


Copyright © 2009 SpringSource. All Rights Reserved.