org.springframework.batch.retry.callback
Class RecoveryRetryCallback

java.lang.Object
  extended by org.springframework.batch.retry.callback.RecoveryRetryCallback
All Implemented Interfaces:
RetryCallback

public class RecoveryRetryCallback
extends Object
implements RetryCallback

A RetryCallback that knows about and caches an item, and attempts to process it using a delegate RetryCallback. Used by the RecoveryCallbackRetryPolicy to enable stateful retry of the processing.

Author:
Dave Syer
See Also:
RecoveryCallbackRetryPolicy, RetryPolicy.handleRetryExhausted(RetryContext)

Constructor Summary
RecoveryRetryCallback(Object item, RetryCallback callback)
          Constructor with mandatory properties.
RecoveryRetryCallback(Object item, RetryCallback callback, Object key)
          Constructor with mandatory properties.
 
Method Summary
 Object doWithRetry(RetryContext context)
          Execute an operation with retry semantics.
 Object getItem()
           
 Object getKey()
          Public getter for the key.
 RecoveryCallback getRecoveryCallback()
          Accessor for the RecoveryCallback.
 boolean isForceRefresh()
           
 void setForceRefresh(boolean forceRefresh)
          Public setter for a flag signalling to clients of this callback that the processing is not a retry.
 void setRecoveryCallback(RecoveryCallback recoverer)
          Setter for injecting optional recovery handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecoveryRetryCallback

public RecoveryRetryCallback(Object item,
                             RetryCallback callback)
Constructor with mandatory properties. The key will be set to the item.

Parameters:
item - the item to process
callback - the delegate to use to process it

RecoveryRetryCallback

public RecoveryRetryCallback(Object item,
                             RetryCallback callback,
                             Object key)
Constructor with mandatory properties.

Parameters:
item - the item to process
callback - the delegate to use to process it
Method Detail

getKey

public Object getKey()
Public getter for the key. This will be used to identify the item being processed, to see if it has previously failed.

Returns:
the key

setRecoveryCallback

public void setRecoveryCallback(RecoveryCallback recoverer)
Setter for injecting optional recovery handler.

Parameters:
recoverer -

setForceRefresh

public void setForceRefresh(boolean forceRefresh)
Public setter for a flag signalling to clients of this callback that the processing is not a retry. It is always safe to leave this set to the default value (false), but in some cases it is possible to determine by examining the input data whether a failure has never been encountered (e.g. a message header saying that the message has never been consumed). Clients who have this information can avoid a cache query in such cases by setting the flag to true.

Parameters:
forceRefresh - the flag value to set

doWithRetry

public Object doWithRetry(RetryContext context)
                   throws Throwable
Description copied from interface: RetryCallback
Execute an operation with retry semantics. Operations should generally be idempotent, but implementations may choose to implement compensation semantics when an operation is retried.

Specified by:
doWithRetry in interface RetryCallback
Parameters:
context - the current retry context.
Returns:
the result of the successful operation.
Throws:
Throwable

getItem

public Object getItem()

isForceRefresh

public boolean isForceRefresh()

getRecoveryCallback

public RecoveryCallback getRecoveryCallback()
Accessor for the RecoveryCallback.

Returns:
the RecoveryCallback.


Copyright © 2009 SpringSource. All Rights Reserved.