org.springframework.retry.policy
Class ExceptionClassifierRetryPolicy

java.lang.Object
  extended by org.springframework.retry.policy.ExceptionClassifierRetryPolicy
All Implemented Interfaces:
RetryPolicy

public class ExceptionClassifierRetryPolicy
extends java.lang.Object
implements RetryPolicy

A RetryPolicy that dynamically adapts to one of a set of injected policies according to the value of the latest exception.

Author:
Dave Syer

Constructor Summary
ExceptionClassifierRetryPolicy()
           
 
Method Summary
 boolean canRetry(RetryContext context)
          Delegate to the policy currently activated in the context.
 void close(RetryContext context)
          Delegate to the policy currently activated in the context.
 RetryContext open(RetryContext parent)
          Create an active context that proxies a retry policy by chosing a target from the policy map.
 void registerThrowable(RetryContext context, java.lang.Throwable throwable)
          Delegate to the policy currently activated in the context.
 void setExceptionClassifier(Classifier<java.lang.Throwable,RetryPolicy> exceptionClassifier)
          Setter for an exception classifier.
 void setPolicyMap(java.util.Map<java.lang.Class<? extends java.lang.Throwable>,RetryPolicy> policyMap)
          Setter for policy map used to create a classifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionClassifierRetryPolicy

public ExceptionClassifierRetryPolicy()
Method Detail

setPolicyMap

public void setPolicyMap(java.util.Map<java.lang.Class<? extends java.lang.Throwable>,RetryPolicy> policyMap)
Setter for policy map used to create a classifier. Either this property or the exception classifier directly should be set, but not both.

Parameters:
policyMap - a map of Throwable class to RetryPolicy that will be used to create a Classifier to locate a policy.

setExceptionClassifier

public void setExceptionClassifier(Classifier<java.lang.Throwable,RetryPolicy> exceptionClassifier)
Setter for an exception classifier. The classifier is responsible for translating exceptions to concrete retry policies. Either this property or the policy map should be used, but not both.

Parameters:
exceptionClassifier - ExceptionClassifier to use

canRetry

public boolean canRetry(RetryContext context)
Delegate to the policy currently activated in the context.

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

close

public void close(RetryContext context)
Delegate to the policy currently activated in the context.

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

open

public RetryContext open(RetryContext parent)
Create an active context that proxies a retry policy by chosing a target from the policy map.

Specified by:
open in interface RetryPolicy
Parameters:
parent - the parent context if we are in a nested retry.
Returns:
a RetryContext object specific to this manager.
See Also:
RetryPolicy.open(RetryContext)

registerThrowable

public void registerThrowable(RetryContext context,
                              java.lang.Throwable throwable)
Delegate to the policy currently activated in the context.

Specified by:
registerThrowable in interface RetryPolicy
Parameters:
context - the current status object.
See Also:
RetryPolicy.registerThrowable(org.springframework.retry.RetryContext, Throwable)


Copyright © 2011 SpringSource. All Rights Reserved.