org.springframework.batch.retry.support
Class DefaultRetryState

java.lang.Object
  extended by org.springframework.batch.retry.support.DefaultRetryState
All Implemented Interfaces:
RetryState

public class DefaultRetryState
extends Object
implements RetryState

Author:
Dave Syer

Constructor Summary
DefaultRetryState(Object key)
          Defaults the force refresh flag (to false) and the rollback classifier (to null).
DefaultRetryState(Object key, boolean forceRefresh)
          Defaults the rollback classifier to null.
DefaultRetryState(Object key, boolean forceRefresh, Classifier<? super Throwable,Boolean> rollbackClassifier)
          Create a DefaultRetryState representing the state for a new retry attempt.
DefaultRetryState(Object key, Classifier<? super Throwable,Boolean> rollbackClassifier)
          Defaults the force refresh flag to false.
 
Method Summary
 Object getKey()
          Key representing the state for a retry attempt.
 boolean isForceRefresh()
          Indicate whether a cache lookup can be avoided.
 boolean rollbackFor(Throwable exception)
          Check whether this exception requires a rollback.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultRetryState

public DefaultRetryState(Object key,
                         boolean forceRefresh,
                         Classifier<? super Throwable,Boolean> rollbackClassifier)
Create a DefaultRetryState representing the state for a new retry attempt.

Parameters:
key - the key for the state to allow this retry attempt to be recognised
forceRefresh - true if the attempt is known to be a brand new state (could not have previously failed)
rollbackClassifier - the rollback classifier to set. The rollback classifier answers true if the exception provided should cause a rollback.
See Also:
RetryOperations.execute(RetryCallback, RetryState), RetryOperations.execute(RetryCallback, RecoveryCallback, RetryState)

DefaultRetryState

public DefaultRetryState(Object key,
                         Classifier<? super Throwable,Boolean> rollbackClassifier)
Defaults the force refresh flag to false.

See Also:
DefaultRetryState(Object, boolean, Classifier)

DefaultRetryState

public DefaultRetryState(Object key,
                         boolean forceRefresh)
Defaults the rollback classifier to null.

See Also:
DefaultRetryState(Object, boolean, Classifier)

DefaultRetryState

public DefaultRetryState(Object key)
Defaults the force refresh flag (to false) and the rollback classifier (to null).

See Also:
DefaultRetryState(Object, boolean, Classifier)
Method Detail

getKey

public Object getKey()
Description copied from interface: RetryState
Key representing the state for a retry attempt. Stateful retry is characterised by having to recognise the items that are being processed, so this value is used as a cache key in between failed attempts.

Specified by:
getKey in interface RetryState
Returns:
the key that this state represents

isForceRefresh

public boolean isForceRefresh()
Description copied from interface: RetryState
Indicate whether a cache lookup can be avoided. If the key is known ahead of the retry attempt to be fresh (i.e. has never been seen before) then a cache lookup can be avoided if this flag is true.

Specified by:
isForceRefresh in interface RetryState
Returns:
true if the state does not require an explicit check for the key

rollbackFor

public boolean rollbackFor(Throwable exception)
Description copied from interface: RetryState
Check whether this exception requires a rollback. The default is always true, which is conservative, so this method provides an optimisation for switching to stateless retry if there is an exception for which rollback is unnecessary. Example usage would be for a stateful retry to specify a validation exception as not for rollback.

Specified by:
rollbackFor in interface RetryState
Parameters:
exception - the exception that caused a retry attempt to fail
Returns:
true if this exception should cause a rollback

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013 SpringSource. All Rights Reserved.