org.springframework.batch.retry.policy
Class NeverRetryPolicy

java.lang.Object
  extended by org.springframework.batch.retry.policy.AbstractStatelessRetryPolicy
      extended by org.springframework.batch.retry.policy.NeverRetryPolicy
All Implemented Interfaces:
RetryPolicy
Direct Known Subclasses:
AlwaysRetryPolicy

public class NeverRetryPolicy
extends AbstractStatelessRetryPolicy

A RetryPolicy that allows the first attempt but never permits a retry. Also be used as a base class for other policies, e.g. for test purposes as a stub.

Author:
Dave Syer

Constructor Summary
NeverRetryPolicy()
           
 
Method Summary
 boolean canRetry(RetryContext context)
          Returns false after the first exception.
 void close(RetryContext context)
          Do nothing.
 RetryContext open(RetryCallback callback, RetryContext parent)
          Return a context that can respond to early termination requests, but does nothing else.
 void registerThrowable(RetryContext context, Throwable throwable)
          Do nothing.
 
Methods inherited from class org.springframework.batch.retry.policy.AbstractStatelessRetryPolicy
handleRetryExhausted, shouldRethrow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NeverRetryPolicy

public NeverRetryPolicy()
Method Detail

canRetry

public boolean canRetry(RetryContext context)
Returns false after the first exception. So there is always one try, and then the retry is prevented.

Parameters:
context - the current retry status
Returns:
true if the operation can proceed
See Also:
RetryPolicy.canRetry(org.springframework.batch.retry.RetryContext)

close

public void close(RetryContext context)
Do nothing.

Parameters:
context - a retry status created by the RetryPolicy.open(RetryCallback, RetryContext) method of this manager.
See Also:
RetryPolicy.close(org.springframework.batch.retry.RetryContext)

open

public RetryContext open(RetryCallback callback,
                         RetryContext parent)
Return a context that can respond to early termination requests, but does nothing else.

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.
See Also:
RetryPolicy.open(org.springframework.batch.retry.RetryCallback, RetryContext)

registerThrowable

public void registerThrowable(RetryContext context,
                              Throwable throwable)
                       throws TerminatedRetryException
Do nothing.

Parameters:
context - the current status object.
Throws:
TerminatedRetryException - if the status is set to terminate only.
See Also:
RetryPolicy.registerThrowable(org.springframework.batch.retry.RetryContext, java.lang.Throwable)


Copyright © 2009 SpringSource. All Rights Reserved.