org.springframework.batch.retry.policy
Class CompositeRetryPolicy

java.lang.Object
  extended by org.springframework.batch.retry.policy.AbstractStatelessRetryPolicy
      extended by org.springframework.batch.retry.policy.CompositeRetryPolicy
All Implemented Interfaces:
RetryPolicy

public class CompositeRetryPolicy
extends AbstractStatelessRetryPolicy

A RetryPolicy that composes a list of other policies and delegates calls to them in order.

Author:
Dave Syer

Constructor Summary
CompositeRetryPolicy()
           
 
Method Summary
 boolean canRetry(RetryContext context)
          Delegate to the policies that were in operation when the context was created.
 void close(RetryContext context)
          Delegate to the policies that were in operation when the context was created.
 RetryContext open(RetryCallback callback, RetryContext parent)
          Creates a new context that copies the existing policies and keeps a list of the contexts from each one.
 void registerThrowable(RetryContext context, Throwable throwable)
          Delegate to the policies that were in operation when the context was created.
 void setPolicies(RetryPolicy[] policies)
          Setter for policies.
 
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

CompositeRetryPolicy

public CompositeRetryPolicy()
Method Detail

setPolicies

public void setPolicies(RetryPolicy[] policies)
Setter for policies.

Parameters:
policies -

canRetry

public boolean canRetry(RetryContext context)
Delegate to the policies that were in operation when the context was created. If any of them cannot retry then return false, oetherwise return true.

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)
Delegate to the policies that were in operation when the context was created.

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)
Creates a new context that copies the existing policies and keeps a list of the contexts from each one.

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
Delegate to the policies that were in operation when the context was created.

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


Copyright © 2008 SpringSource. All Rights Reserved.