From 004d277c81869263bfbf356a4d73a2a0bb33e83d Mon Sep 17 00:00:00 2001 From: Josh Long Date: Fri, 12 Feb 2016 17:12:40 +0100 Subject: [PATCH] javadoc --- .../classify/BackToBackPatternClassifier.java | 2 +- .../classify/BinaryExceptionClassifier.java | 11 ++- .../classify/ClassifierAdapter.java | 4 +- .../classify/ClassifierSupport.java | 2 +- .../classify/PatternMatchingClassifier.java | 2 +- .../classify/SubclassClassifier.java | 9 ++- .../util/AnnotationMethodResolver.java | 1 + .../classify/util/MethodInvokerUtils.java | 4 +- .../retry/RecoveryCallback.java | 5 +- .../springframework/retry/RetryCallback.java | 8 +- .../springframework/retry/RetryListener.java | 8 +- .../retry/RetryOperations.java | 38 ++++++---- .../springframework/retry/RetryPolicy.java | 2 +- .../retry/annotation/Backoff.java | 2 +- .../retry/annotation/EnableRetry.java | 2 + .../retry/backoff/BackOffPolicy.java | 19 +++-- .../backoff/ExponentialBackOffPolicy.java | 9 ++- .../retry/backoff/FixedBackOffPolicy.java | 3 +- .../retry/backoff/Sleeper.java | 3 +- .../backoff/UniformRandomBackOffPolicy.java | 5 +- .../retry/context/RetryContextSupport.java | 4 +- .../MethodInvocationRecoverer.java | 2 +- .../RetryOperationsInterceptor.java | 2 +- .../StatefulRetryOperationsInterceptor.java | 6 +- .../retry/policy/CompositeRetryPolicy.java | 6 +- .../retry/policy/MapRetryContextCache.java | 3 +- .../RetryCacheCapacityExceededException.java | 4 +- .../retry/policy/SimpleRetryPolicy.java | 10 +-- .../SoftReferenceMapRetryContextCache.java | 3 +- .../retry/policy/TimeoutRetryPolicy.java | 2 +- .../retry/support/DefaultRetryState.java | 7 +- .../retry/support/RetrySimulation.java | 3 +- .../retry/support/RetryTemplate.java | 73 +++++++++++-------- 33 files changed, 163 insertions(+), 101 deletions(-) diff --git a/src/main/java/org/springframework/classify/BackToBackPatternClassifier.java b/src/main/java/org/springframework/classify/BackToBackPatternClassifier.java index 0559409..cfc3ca2 100644 --- a/src/main/java/org/springframework/classify/BackToBackPatternClassifier.java +++ b/src/main/java/org/springframework/classify/BackToBackPatternClassifier.java @@ -64,7 +64,7 @@ public class BackToBackPatternClassifier implements Classifier { * Java Object. The object provided must have precisely one public method * that either has the @Classifier annotation or accepts a single argument * and outputs a String. This will be used to create an input classifier for - * the router component.
+ * the router component. * * @param delegate the delegate object used to create a router classifier */ diff --git a/src/main/java/org/springframework/classify/BinaryExceptionClassifier.java b/src/main/java/org/springframework/classify/BinaryExceptionClassifier.java index 2f374e4..e2cb4cc 100644 --- a/src/main/java/org/springframework/classify/BinaryExceptionClassifier.java +++ b/src/main/java/org/springframework/classify/BinaryExceptionClassifier.java @@ -50,7 +50,8 @@ public class BinaryExceptionClassifier extends SubclassClassifier> exceptionClasses, boolean value) { this(!value); @@ -66,6 +67,8 @@ public class BinaryExceptionClassifier extends SubclassClassifier> exceptionClasses) { this(exceptionClasses, true); @@ -74,8 +77,7 @@ public class BinaryExceptionClassifier extends SubclassClassifier, Boolean> typeMap) { this(typeMap, false); @@ -85,7 +87,8 @@ public class BinaryExceptionClassifier extends SubclassClassifier, Boolean> typeMap, boolean defaultValue) { super(typeMap, defaultValue); diff --git a/src/main/java/org/springframework/classify/ClassifierAdapter.java b/src/main/java/org/springframework/classify/ClassifierAdapter.java index 9dab62b..c5767a9 100644 --- a/src/main/java/org/springframework/classify/ClassifierAdapter.java +++ b/src/main/java/org/springframework/classify/ClassifierAdapter.java @@ -42,7 +42,7 @@ public class ClassifierAdapter implements Classifier { * Create a new {@link Classifier} from the delegate provided. Use the * constructor as an alternative to the {@link #setDelegate(Object)} method. * - * @param delegate + * @param delegate the delegate */ public ClassifierAdapter(Object delegate) { setDelegate(delegate); @@ -53,7 +53,7 @@ public class ClassifierAdapter implements Classifier { * constructor as an alternative to the {@link #setDelegate(Classifier)} * method. * - * @param delegate + * @param delegate the classifier to delegate to */ public ClassifierAdapter(Classifier delegate) { classifier = delegate; diff --git a/src/main/java/org/springframework/classify/ClassifierSupport.java b/src/main/java/org/springframework/classify/ClassifierSupport.java index d24aec2..8490229 100644 --- a/src/main/java/org/springframework/classify/ClassifierSupport.java +++ b/src/main/java/org/springframework/classify/ClassifierSupport.java @@ -28,7 +28,7 @@ public class ClassifierSupport implements Classifier { final private T defaultValue; /** - * @param defaultValue + * @param defaultValue the default value */ public ClassifierSupport(T defaultValue) { super(); diff --git a/src/main/java/org/springframework/classify/PatternMatchingClassifier.java b/src/main/java/org/springframework/classify/PatternMatchingClassifier.java index be9b67f..e9ba899 100644 --- a/src/main/java/org/springframework/classify/PatternMatchingClassifier.java +++ b/src/main/java/org/springframework/classify/PatternMatchingClassifier.java @@ -43,7 +43,7 @@ public class PatternMatchingClassifier implements Classifier { * Create a classifier from the provided map. The keys are patterns, using * '?' as a single character and '*' as multi-character wildcard. * - * @param values + * @param values the values to use in the {@link PatternMatcher} */ public PatternMatchingClassifier(Map values) { super(); diff --git a/src/main/java/org/springframework/classify/SubclassClassifier.java b/src/main/java/org/springframework/classify/SubclassClassifier.java index 4045fad..d384470 100644 --- a/src/main/java/org/springframework/classify/SubclassClassifier.java +++ b/src/main/java/org/springframework/classify/SubclassClassifier.java @@ -53,7 +53,7 @@ public class SubclassClassifier implements Classifier { /** * Create a {@link SubclassClassifier} with supplied default value. * - * @param defaultValue + * @param defaultValue the default value */ public SubclassClassifier(C defaultValue) { this(new HashMap, C>(), defaultValue); @@ -62,7 +62,8 @@ public class SubclassClassifier implements Classifier { /** * Create a {@link SubclassClassifier} with supplied default value. * - * @param defaultValue + * @param defaultValue the default value + * @param typeMap the map of types */ public SubclassClassifier(Map, C> typeMap, C defaultValue) { super(); @@ -95,6 +96,8 @@ public class SubclassClassifier implements Classifier { * Return the value from the type map whose key is the class of the given * Throwable, or its nearest ancestor if a subclass. * + * @return C the classified value + * @param classifiable the classifiable thing */ public C classify(T classifiable) { @@ -124,6 +127,8 @@ public class SubclassClassifier implements Classifier { /** * Return the default value supplied in the constructor (default false). + * + * @return C the default value */ final public C getDefault() { return defaultValue; diff --git a/src/main/java/org/springframework/classify/util/AnnotationMethodResolver.java b/src/main/java/org/springframework/classify/util/AnnotationMethodResolver.java index 9aec6b5..0b59c66 100644 --- a/src/main/java/org/springframework/classify/util/AnnotationMethodResolver.java +++ b/src/main/java/org/springframework/classify/util/AnnotationMethodResolver.java @@ -41,6 +41,7 @@ public class AnnotationMethodResolver implements MethodResolver { /** * Create a MethodResolver for the specified Method-level annotation type + * @param annotationType the type of the annotation */ public AnnotationMethodResolver(Class annotationType) { Assert.notNull(annotationType, "annotationType must not be null"); diff --git a/src/main/java/org/springframework/classify/util/MethodInvokerUtils.java b/src/main/java/org/springframework/classify/util/MethodInvokerUtils.java index 1c8fbce..dc7a4e4 100644 --- a/src/main/java/org/springframework/classify/util/MethodInvokerUtils.java +++ b/src/main/java/org/springframework/classify/util/MethodInvokerUtils.java @@ -30,7 +30,7 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; /** - * Utility methods for create MethodInvoker instances. + * Utility methods to create {@link MethodInvoker} instances. * * @author Lucas Ward * @author Artem Bilan @@ -190,6 +190,8 @@ public class MethodInvokerUtils { * * @param target an object to search for an appropriate method * @return a MethodInvoker that calls a method on the delegate + * @param the t + * @param the C */ public static MethodInvoker getMethodInvokerForSingleArgument(Object target) { final AtomicReference methodHolder = new AtomicReference(); diff --git a/src/main/java/org/springframework/retry/RecoveryCallback.java b/src/main/java/org/springframework/retry/RecoveryCallback.java index ee5906a..354484d 100644 --- a/src/main/java/org/springframework/retry/RecoveryCallback.java +++ b/src/main/java/org/springframework/retry/RecoveryCallback.java @@ -26,9 +26,8 @@ public interface RecoveryCallback { /** * @param context the current retry context - * @return an Object that can be used to replace the callback result that - * failed - * @throws Exception + * @return an Object that can be used to replace the callback result that failed + * @throws Exception when something goes wrong */ T recover(RetryContext context) throws Exception; diff --git a/src/main/java/org/springframework/retry/RetryCallback.java b/src/main/java/org/springframework/retry/RetryCallback.java index 4e75a43..c2989cd 100644 --- a/src/main/java/org/springframework/retry/RetryCallback.java +++ b/src/main/java/org/springframework/retry/RetryCallback.java @@ -20,8 +20,8 @@ package org.springframework.retry; * Callback interface for an operation that can be retried using a * {@link RetryOperations}. * - * @param T the type of object returned by the callback - * @param E the type of exception it declares may be thrown + * @param the type of object returned by the callback + * @param the type of exception it declares may be thrown * * @author Rob Harrop * @author Dave Syer @@ -34,7 +34,7 @@ public interface RetryCallback { * semantics when an operation is retried. * @param context the current retry context. * @return the result of the successful operation. - * @throws Throwable of type E if processing fails + * @throws E of type E if processing fails */ - T doWithRetry(RetryContext context) throws E; + T doWithRetry(RetryContext context) throws E; } diff --git a/src/main/java/org/springframework/retry/RetryListener.java b/src/main/java/org/springframework/retry/RetryListener.java index c649bb8..2a20d76 100644 --- a/src/main/java/org/springframework/retry/RetryListener.java +++ b/src/main/java/org/springframework/retry/RetryListener.java @@ -33,7 +33,9 @@ public interface RetryListener { * {@link RetryOperations}. The whole retry can be vetoed by returning * false from this method, in which case a {@link TerminatedRetryException} * will be thrown. - * + * + * @param the type of object returned by the callback + * @param the type of exception it declares may be thrown * @param context the current {@link RetryContext}. * @param callback the current {@link RetryCallback}. * @return true if the retry should proceed. @@ -48,6 +50,8 @@ public interface RetryListener { * @param context the current {@link RetryContext}. * @param callback the current {@link RetryCallback}. * @param throwable the last exception that was thrown by the callback. + * @param the exception type + * @param the return value */ void close(RetryContext context, RetryCallback callback, Throwable throwable); @@ -57,6 +61,8 @@ public interface RetryListener { * @param context the current {@link RetryContext}. * @param callback the current {@link RetryCallback}. * @param throwable the last exception that was thrown by the callback. + * @param the return value + * @param the exception to throw */ void onError(RetryContext context, RetryCallback callback, Throwable throwable); } diff --git a/src/main/java/org/springframework/retry/RetryOperations.java b/src/main/java/org/springframework/retry/RetryOperations.java index 745b371..ebb565a 100644 --- a/src/main/java/org/springframework/retry/RetryOperations.java +++ b/src/main/java/org/springframework/retry/RetryOperations.java @@ -33,9 +33,12 @@ public interface RetryOperations { * * @return the value returned by the {@link RetryCallback} upon successful * invocation. - * @throws Exception any {@link Exception} raised by the + * @throws E any {@link Exception} raised by the * {@link RetryCallback} upon unsuccessful retry. - * @throws Throwable + * @throws E the exception thrown + * @param the return value + * @param retryCallback the {@link RetryCallback} + * @param the exception to throw */ T execute(RetryCallback retryCallback) throws E; @@ -46,7 +49,11 @@ public interface RetryOperations { * * @return the value returned by the {@link RetryCallback} upon successful * invocation, and that returned by the {@link RecoveryCallback} otherwise. - * @throws Exception any {@link Exception} raised by the + * @throws E any {@link Exception} raised by the + * @param the type to return + * @param the type of the exception + * @param recoveryCallback the {@link RecoveryCallback} + * @param retryCallback the {@link RetryCallback} * {@link RecoveryCallback} upon unsuccessful retry. */ T execute(RetryCallback retryCallback, RecoveryCallback recoveryCallback) throws E; @@ -58,16 +65,19 @@ public interface RetryOperations { * the state is required to be able to identify the previous attempt, if * there is one - hence the state is required. Normal patterns would see * this method being used inside a transaction, where the callback might - * invalidate the transaction if it fails.

+ * invalidate the transaction if it fails. * * See implementations for configuration details. - * + * + * @param retryCallback the {@link RetryCallback} + * @param retryState the {@link RetryState} * @return the value returned by the {@link RetryCallback} upon successful * invocation, and that returned by the {@link RecoveryCallback} otherwise. - * @throws Exception any {@link Exception} raised by the - * {@link RecoveryCallback}. + * @throws E any {@link Exception} raised by the {@link RecoveryCallback}. * @throws ExhaustedRetryException if the last attempt for this state has * already been reached + * @param the type of the return value + * @param the type of the exception to return */ T execute(RetryCallback retryCallback, RetryState retryState) throws E, ExhaustedRetryException; @@ -76,13 +86,15 @@ public interface RetryOperations { * {@link RetryCallback} with a fallback on exhausted retry to the * {@link RecoveryCallback} and a target object for the retry attempt * identified by the {@link DefaultRetryState}. - * + * @param recoveryCallback the {@link RecoveryCallback} + * @param retryState the {@link RetryState} + * @param retryCallback the {@link RetryCallback} * @see #execute(RetryCallback, RetryState) - * - * @return the value returned by the {@link RetryCallback} upon successful - * invocation, and that returned by the {@link RecoveryCallback} otherwise. - * @throws Exception any {@link Exception} raised by the - * {@link RecoveryCallback} upon unsuccessful retry. + * @param the return value type + * @param the exception type + * @return the value returned by the {@link RetryCallback} upon successful + * invocation, and that returned by the {@link RecoveryCallback} otherwise. + * @throws E any {@link Exception} raised by the {@link RecoveryCallback} upon unsuccessful retry. */ T execute(RetryCallback retryCallback, RecoveryCallback recoveryCallback, RetryState retryState) throws E; diff --git a/src/main/java/org/springframework/retry/RetryPolicy.java b/src/main/java/org/springframework/retry/RetryPolicy.java index a4722a4..a2cf102 100644 --- a/src/main/java/org/springframework/retry/RetryPolicy.java +++ b/src/main/java/org/springframework/retry/RetryPolicy.java @@ -56,7 +56,7 @@ public interface RetryPolicy { * Called once per retry attempt, after the callback fails. * * @param context the current status object. - * + * @param throwable the exception to throw */ void registerThrowable(RetryContext context, Throwable throwable); diff --git a/src/main/java/org/springframework/retry/annotation/Backoff.java b/src/main/java/org/springframework/retry/annotation/Backoff.java index 38ea11c..1e2f69a 100644 --- a/src/main/java/org/springframework/retry/annotation/Backoff.java +++ b/src/main/java/org/springframework/retry/annotation/Backoff.java @@ -80,7 +80,7 @@ public @interface Backoff { double multiplier() default 0; /** - * In the exponential case ({@link #multiplier()}>0) set this to true to have the + * In the exponential case ({@link #multiplier()} > 0) set this to true to have the * backoff delays randomized, so that the maximum delay is multiplier times the * previous delay and the distribution is uniform between the two values. * diff --git a/src/main/java/org/springframework/retry/annotation/EnableRetry.java b/src/main/java/org/springframework/retry/annotation/EnableRetry.java index 8081eb7..ea3944c 100644 --- a/src/main/java/org/springframework/retry/annotation/EnableRetry.java +++ b/src/main/java/org/springframework/retry/annotation/EnableRetry.java @@ -45,6 +45,8 @@ public @interface EnableRetry { /** * Indicate whether subclass-based (CGLIB) proxies are to be created as opposed * to standard Java interface-based proxies. The default is {@code false}. + * + * @return whether to proxy or not to proxy the class */ boolean proxyTargetClass() default false; diff --git a/src/main/java/org/springframework/retry/backoff/BackOffPolicy.java b/src/main/java/org/springframework/retry/backoff/BackOffPolicy.java index 3b7ce79..455a2bb 100644 --- a/src/main/java/org/springframework/retry/backoff/BackOffPolicy.java +++ b/src/main/java/org/springframework/retry/backoff/BackOffPolicy.java @@ -21,17 +21,19 @@ import org.springframework.retry.RetryContext; /** * Strategy interface to control back off between attempts in a single * {@link org.springframework.retry.support.RetryTemplate retry operation}. - *

Implementations are expected to be thread-safe and should be designed + * + * Implementations are expected to be thread-safe and should be designed * for concurrent access. Configuration for each implementation is also expected * to be thread-safe but need not be suitable for high load concurrent access. - *

For each block of retry operations the {@link #start} method is called + * + * For each block of retry operations the {@link #start} method is called * and implementations can return an implementation-specific + * * {@link BackOffContext} that can be used to track state through subsequent - * back off invocations.

Each back off process is handled via a call to - * {@link #backOff}. The - * {@link org.springframework.retry.support.RetryTemplate} will pass in - * the corresponding {@link BackOffContext} object created by the call to - * {@link #start}. + * back off invocations. Each back off process is handled via a call to {@link #backOff}. + * + * The {@link org.springframework.retry.support.RetryTemplate} will pass in + * the corresponding {@link BackOffContext} object created by the call to {@link #start}. * * @author Rob Harrop * @author Dave Syer @@ -42,7 +44,7 @@ public interface BackOffPolicy { * Start a new block of back off operations. Implementations can choose to * pause when this method is called, but normally it returns immediately. * - * @param context the current retry context, which might contain information + * @param context the {@link RetryContext} context, which might contain information * that we can use to decide how to proceed. * @return the implementation-specific {@link BackOffContext} or 'null'. */ @@ -55,6 +57,7 @@ public interface BackOffPolicy { * * @throws BackOffInterruptedException if the attempt at back off is * interrupted. + * @param backOffContext the {@link BackOffContext} */ void backOff(BackOffContext backOffContext) throws BackOffInterruptedException; diff --git a/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java b/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java index 977b9d7..902732e 100644 --- a/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java +++ b/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java @@ -25,11 +25,11 @@ import org.springframework.util.ClassUtils; * Implementation of {@link BackOffPolicy} that increases the back off period * for each retry attempt in a given set using the {@link Math#exp(double) * exponential} function. - *

+ * * This implementation is thread-safe and suitable for concurrent access. * Modifications to the configuration do not affect any retry sets that are * already in progress. - *

+ * * The {@link #setInitialInterval(long)} property controls the initial value * passed to {@link Math#exp(double)} and the {@link #setMultiplier(double)} * property controls by how much this value is increased for each subsequent @@ -104,8 +104,10 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy100 + * Set the initial sleep interval value. Default is {@code 100} * millisecond. Cannot be set to a value less than one. + * + * @param initialInterval the initial interval */ public void setInitialInterval(long initialInterval) { this.initialInterval = (initialInterval > 1 ? initialInterval : 1); @@ -115,6 +117,7 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy2.0'. Hint: do not use * values much in excess of 1.0 (or the backoff will get very long very * fast). + * @param multiplier the multiplier */ public void setMultiplier(double multiplier) { this.multiplier = (multiplier > 1.0 ? multiplier : 1.0); diff --git a/src/main/java/org/springframework/retry/backoff/FixedBackOffPolicy.java b/src/main/java/org/springframework/retry/backoff/FixedBackOffPolicy.java index 74104e1..5b884f1 100644 --- a/src/main/java/org/springframework/retry/backoff/FixedBackOffPolicy.java +++ b/src/main/java/org/springframework/retry/backoff/FixedBackOffPolicy.java @@ -19,7 +19,7 @@ package org.springframework.retry.backoff; /** * Implementation of {@link BackOffPolicy} that pauses for a fixed period of time before * continuing. A pause is implemented using {@link Sleeper#sleep(long)}. - *

+ * * {@link #setBackOffPeriod(long)} is thread-safe and it is safe to call * {@link #setBackOffPeriod} during execution from multiple threads, however this may * cause a single retry operation to have pauses of different intervals. @@ -60,6 +60,7 @@ public class FixedBackOffPolicy extends StatelessBackOffPolicy implements /** * Set the back off period in milliseconds. Cannot be < 1. Default value is 1000ms. + * @param backOffPeriod the back off period */ public void setBackOffPeriod(long backOffPeriod) { this.backOffPeriod = (backOffPeriod > 0 ? backOffPeriod : 1); diff --git a/src/main/java/org/springframework/retry/backoff/Sleeper.java b/src/main/java/org/springframework/retry/backoff/Sleeper.java index 4a313c9..2e7d3dd 100644 --- a/src/main/java/org/springframework/retry/backoff/Sleeper.java +++ b/src/main/java/org/springframework/retry/backoff/Sleeper.java @@ -26,7 +26,8 @@ public interface Sleeper { /** * Pause for the specified period using whatever means available. * - * @param backOffPeriod + * @param backOffPeriod the backoff period + * @throws InterruptedException the exception when interrupted */ void sleep(long backOffPeriod) throws InterruptedException; diff --git a/src/main/java/org/springframework/retry/backoff/UniformRandomBackOffPolicy.java b/src/main/java/org/springframework/retry/backoff/UniformRandomBackOffPolicy.java index 6386689..5ba464a 100644 --- a/src/main/java/org/springframework/retry/backoff/UniformRandomBackOffPolicy.java +++ b/src/main/java/org/springframework/retry/backoff/UniformRandomBackOffPolicy.java @@ -22,7 +22,7 @@ import java.util.Random; /** * Implementation of {@link BackOffPolicy} that pauses for a random period of * time before continuing. A pause is implemented using {@link Sleeper#sleep(long)}. - *

+ * * {@link #setMinBackOffPeriod(long)} is thread-safe and it is safe to call * {@link #setMaxBackOffPeriod(long)} during execution from multiple threads, however * this may cause a single retry operation to have pauses of different @@ -69,6 +69,8 @@ public class UniformRandomBackOffPolicy extends StatelessBackOffPolicy implement /** * Set the minimum back off period in milliseconds. Cannot be < 1. Default value * is 500ms. + * + * @param backOffPeriod the backoff period */ public void setMinBackOffPeriod(long backOffPeriod) { this.minBackOffPeriod = (backOffPeriod > 0 ? backOffPeriod : 1); @@ -85,6 +87,7 @@ public class UniformRandomBackOffPolicy extends StatelessBackOffPolicy implement /** * Set the maximum back off period in milliseconds. Cannot be < 1. Default value * is 1500ms. + * @param backOffPeriod the back off period */ public void setMaxBackOffPeriod(long backOffPeriod) { this.maxBackOffPeriod = (backOffPeriod > 0 ? backOffPeriod : 1); diff --git a/src/main/java/org/springframework/retry/context/RetryContextSupport.java b/src/main/java/org/springframework/retry/context/RetryContextSupport.java index ebf9206..d692239 100644 --- a/src/main/java/org/springframework/retry/context/RetryContextSupport.java +++ b/src/main/java/org/springframework/retry/context/RetryContextSupport.java @@ -61,11 +61,11 @@ public class RetryContextSupport extends AttributeAccessorSupport implements Ret /** * Set the exception for the public interface {@link RetryContext}, and - * also increment the retry count if the throwable is non-null.
+ * also increment the retry count if the throwable is non-null. * * All {@link RetryPolicy} implementations should use this method when they * register the throwable. It should only be called once per retry attempt - * because it increments a counter.
+ * because it increments a counter. * * Use of this method is not enforced by the framework - it is a service * provider contract for authors of policies. diff --git a/src/main/java/org/springframework/retry/interceptor/MethodInvocationRecoverer.java b/src/main/java/org/springframework/retry/interceptor/MethodInvocationRecoverer.java index e254cdc..ebe46b2 100644 --- a/src/main/java/org/springframework/retry/interceptor/MethodInvocationRecoverer.java +++ b/src/main/java/org/springframework/retry/interceptor/MethodInvocationRecoverer.java @@ -18,7 +18,7 @@ package org.springframework.retry.interceptor; /** - * Strategy interface for recovery action when processing of an item fails.
+ * Strategy interface for recovery action when processing of an item fails. * * @author Dave Syer */ diff --git a/src/main/java/org/springframework/retry/interceptor/RetryOperationsInterceptor.java b/src/main/java/org/springframework/retry/interceptor/RetryOperationsInterceptor.java index 57faacd..5289e42 100644 --- a/src/main/java/org/springframework/retry/interceptor/RetryOperationsInterceptor.java +++ b/src/main/java/org/springframework/retry/interceptor/RetryOperationsInterceptor.java @@ -30,7 +30,7 @@ import org.springframework.util.Assert; * A {@link MethodInterceptor} that can be used to automatically retry calls to a method * on a service if it fails. The injected {@link RetryOperations} is used to control the * number of retries. By default it will retry a fixed number of times, according to the - * defaults in {@link RetryTemplate}.
+ * defaults in {@link RetryTemplate}. * * Hint about transaction boundaries. If you want to retry a failed transaction you need * to make sure that the transaction boundary is inside the retry, otherwise the diff --git a/src/main/java/org/springframework/retry/interceptor/StatefulRetryOperationsInterceptor.java b/src/main/java/org/springframework/retry/interceptor/StatefulRetryOperationsInterceptor.java index 1b271de..842bdb8 100644 --- a/src/main/java/org/springframework/retry/interceptor/StatefulRetryOperationsInterceptor.java +++ b/src/main/java/org/springframework/retry/interceptor/StatefulRetryOperationsInterceptor.java @@ -40,15 +40,15 @@ import org.springframework.util.ObjectUtils; * be remembered in case the call fails. So the retry operation is stateful, and the item * that failed is tracked by its unique key (via {@link MethodArgumentsKeyGenerator}) * until the retry is exhausted, at which point the {@link MethodInvocationRecoverer} is - * called.
+ * called. * * The main use case for this is where the service is transactional, via a transaction * interceptor on the interceptor chain. In this case the retry (and recovery on - * exhausted) always happens in a new transaction.
+ * exhausted) always happens in a new transaction. * * The injected {@link RetryOperations} is used to control the number of retries. By * default it will retry a fixed number of times, according to the defaults in - * {@link RetryTemplate}.
+ * {@link RetryTemplate}. * * @author Dave Syer */ diff --git a/src/main/java/org/springframework/retry/policy/CompositeRetryPolicy.java b/src/main/java/org/springframework/retry/policy/CompositeRetryPolicy.java index 445b825..94864af 100644 --- a/src/main/java/org/springframework/retry/policy/CompositeRetryPolicy.java +++ b/src/main/java/org/springframework/retry/policy/CompositeRetryPolicy.java @@ -40,7 +40,7 @@ public class CompositeRetryPolicy implements RetryPolicy { /** * Setter for optimistic. * - * @param optimistic + * @param optimistic should this retry policy be optimistic */ public void setOptimistic(boolean optimistic) { this.optimistic = optimistic; @@ -49,7 +49,7 @@ public class CompositeRetryPolicy implements RetryPolicy { /** * Setter for policies. * - * @param policies + * @param policies the {@link RetryPolicy} policies */ public void setPolicies(RetryPolicy[] policies) { this.policies = Arrays.asList(policies).toArray(new RetryPolicy[policies.length]); @@ -60,6 +60,7 @@ public class CompositeRetryPolicy implements RetryPolicy { * created. If any of them cannot retry then return false, otherwise return * true. * + * @param context the {@link RetryContext} * @see org.springframework.retry.RetryPolicy#canRetry(org.springframework.retry.RetryContext) */ @Override @@ -94,6 +95,7 @@ public class CompositeRetryPolicy implements RetryPolicy { * those later in the chain are closed before re-throwing). * * @see org.springframework.retry.RetryPolicy#close(org.springframework.retry.RetryContext) + * @param context the {@link RetryContext} */ @Override public void close(RetryContext context) { diff --git a/src/main/java/org/springframework/retry/policy/MapRetryContextCache.java b/src/main/java/org/springframework/retry/policy/MapRetryContextCache.java index a3f330c..b2a67fd 100644 --- a/src/main/java/org/springframework/retry/policy/MapRetryContextCache.java +++ b/src/main/java/org/springframework/retry/policy/MapRetryContextCache.java @@ -26,7 +26,6 @@ import org.springframework.retry.RetryContext; * cache of contexts is synchronized. * * @author Dave Syer - * */ public class MapRetryContextCache implements RetryContextCache { @@ -49,7 +48,7 @@ public class MapRetryContextCache implements RetryContextCache { } /** - * @param defaultCapacity + * @param defaultCapacity the default capacity */ public MapRetryContextCache(int defaultCapacity) { super(); diff --git a/src/main/java/org/springframework/retry/policy/RetryCacheCapacityExceededException.java b/src/main/java/org/springframework/retry/policy/RetryCacheCapacityExceededException.java index 5771cfa..3c28957 100644 --- a/src/main/java/org/springframework/retry/policy/RetryCacheCapacityExceededException.java +++ b/src/main/java/org/springframework/retry/policy/RetryCacheCapacityExceededException.java @@ -34,7 +34,7 @@ public class RetryCacheCapacityExceededException extends RetryException { /** * Constructs a new instance with a message. * - * @param message + * @param message the message sent when creating the exception */ public RetryCacheCapacityExceededException(String message) { super(message); @@ -44,7 +44,7 @@ public class RetryCacheCapacityExceededException extends RetryException { * Constructs a new instance with a message and nested exception. * * @param msg the exception message. - * + * @param nested the nested exception */ public RetryCacheCapacityExceededException(String msg, Throwable nested) { super(msg, nested); diff --git a/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java b/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java index b6d2f73..f0ca03d 100644 --- a/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java +++ b/src/main/java/org/springframework/retry/policy/SimpleRetryPolicy.java @@ -67,8 +67,8 @@ public class SimpleRetryPolicy implements RetryPolicy { * Create a {@link SimpleRetryPolicy} with the specified number of retry * attempts. * - * @param maxAttempts - * @param retryableExceptions + * @param maxAttempts the maximum number of attempts + * @param retryableExceptions the map of exceptions that are retryable */ public SimpleRetryPolicy(int maxAttempts, Map, Boolean> retryableExceptions) { this(maxAttempts, retryableExceptions, false); @@ -79,9 +79,9 @@ public class SimpleRetryPolicy implements RetryPolicy { * attempts. If traverseCauses is true, the exception causes will be traversed until * a match is found. * - * @param maxAttempts - * @param retryableExceptions - * @param traverseCauses + * @param maxAttempts the maximum number of attempts + * @param retryableExceptions the map of exceptions that are retryable + * @param traverseCauses is this clause traversable */ public SimpleRetryPolicy(int maxAttempts, Map, Boolean> retryableExceptions, boolean traverseCauses) { diff --git a/src/main/java/org/springframework/retry/policy/SoftReferenceMapRetryContextCache.java b/src/main/java/org/springframework/retry/policy/SoftReferenceMapRetryContextCache.java index 12140ac..cfb54f6 100644 --- a/src/main/java/org/springframework/retry/policy/SoftReferenceMapRetryContextCache.java +++ b/src/main/java/org/springframework/retry/policy/SoftReferenceMapRetryContextCache.java @@ -30,7 +30,6 @@ import org.springframework.retry.RetryContext; * @see MapRetryContextCache for non-soft referenced version * * @author Dave Syer - * */ public class SoftReferenceMapRetryContextCache implements RetryContextCache { @@ -54,7 +53,7 @@ public class SoftReferenceMapRetryContextCache implements RetryContextCache { } /** - * @param defaultCapacity + * @param defaultCapacity the default capacity */ public SoftReferenceMapRetryContextCache(int defaultCapacity) { super(); diff --git a/src/main/java/org/springframework/retry/policy/TimeoutRetryPolicy.java b/src/main/java/org/springframework/retry/policy/TimeoutRetryPolicy.java index 4599597..2470d1e 100644 --- a/src/main/java/org/springframework/retry/policy/TimeoutRetryPolicy.java +++ b/src/main/java/org/springframework/retry/policy/TimeoutRetryPolicy.java @@ -38,7 +38,7 @@ public class TimeoutRetryPolicy implements RetryPolicy { /** * Setter for timeout in milliseconds. Default is {@link #DEFAULT_TIMEOUT}. - * @param timeout + * @param timeout how long to wait until a timeout */ public void setTimeout(long timeout) { this.timeout = timeout; diff --git a/src/main/java/org/springframework/retry/support/DefaultRetryState.java b/src/main/java/org/springframework/retry/support/DefaultRetryState.java index b6f8ae8..14e2daa 100644 --- a/src/main/java/org/springframework/retry/support/DefaultRetryState.java +++ b/src/main/java/org/springframework/retry/support/DefaultRetryState.java @@ -58,6 +58,8 @@ public class DefaultRetryState implements RetryState { /** * Defaults the force refresh flag to false. * @see DefaultRetryState#DefaultRetryState(Object, boolean, Classifier) + * @param key the key + * @param rollbackClassifier the rollback {@link Classifier} */ public DefaultRetryState(Object key, Classifier rollbackClassifier) { this(key, false, rollbackClassifier); @@ -66,6 +68,8 @@ public class DefaultRetryState implements RetryState { /** * Defaults the rollback classifier to null. * @see DefaultRetryState#DefaultRetryState(Object, boolean, Classifier) + * @param key the key + * @param forceRefresh whether to force a refresh */ public DefaultRetryState(Object key, boolean forceRefresh) { this(key, forceRefresh, null); @@ -74,7 +78,8 @@ public class DefaultRetryState implements RetryState { /** * Defaults the force refresh flag (to false) and the rollback classifier * (to null). - * + * + * @param key the key to use * @see DefaultRetryState#DefaultRetryState(Object, boolean, Classifier) */ public DefaultRetryState(Object key) { diff --git a/src/main/java/org/springframework/retry/support/RetrySimulation.java b/src/main/java/org/springframework/retry/support/RetrySimulation.java index 3d328e7..0651b19 100644 --- a/src/main/java/org/springframework/retry/support/RetrySimulation.java +++ b/src/main/java/org/springframework/retry/support/RetrySimulation.java @@ -34,6 +34,7 @@ public class RetrySimulation { /** * Add a sequence of sleeps to the simulation. + * @param sleeps the times to be created as a {@link SleepSequence} */ public void addSequence(List sleeps) { sleepHistogram.addAll(sleeps); @@ -97,7 +98,7 @@ public class RetrySimulation { } /** - * Returns the longest individual sleep within this sequence. + * @return the longest individual sleep within this sequence */ public long getLongestSleep() { return longestSleep; diff --git a/src/main/java/org/springframework/retry/support/RetryTemplate.java b/src/main/java/org/springframework/retry/support/RetryTemplate.java index af66f0c..6d6adc6 100644 --- a/src/main/java/org/springframework/retry/support/RetryTemplate.java +++ b/src/main/java/org/springframework/retry/support/RetryTemplate.java @@ -43,20 +43,21 @@ import org.springframework.retry.policy.RetryContextCache; import org.springframework.retry.policy.SimpleRetryPolicy; /** - * Template class that simplifies the execution of operations with retry semantics.
+ * Template class that simplifies the execution of operations with retry semantics. + *

* Retryable operations are encapsulated in implementations of the {@link RetryCallback} - * interface and are executed using one of the supplied execute methods.
- * + * interface and are executed using one of the supplied execute methods. + *

* By default, an operation is retried if is throws any {@link Exception} or subclass of * {@link Exception}. This behaviour can be changed by using the - * {@link #setRetryPolicy(RetryPolicy)} method.
- * + * {@link #setRetryPolicy(RetryPolicy)} method. + *

* Also by default, each operation is retried for a maximum of three attempts with no back * off in between. This behaviour can be configured using the * {@link #setRetryPolicy(RetryPolicy)} and {@link #setBackOffPolicy(BackOffPolicy)} * properties. The {@link org.springframework.retry.backoff.BackOffPolicy} controls how - * long the pause is between each individual retry attempt.
- * + * long the pause is between each individual retry attempt. + *

* This class is thread-safe and suitable for concurrent access when executing operations * and when performing configuration changes. As such, it is possible to change the number * of retries on the fly, as well as the {@link BackOffPolicy} used and no in progress @@ -66,6 +67,7 @@ import org.springframework.retry.policy.SimpleRetryPolicy; * @author Dave Syer * @author Gary Russell * @author Artem Bilan + * @author Josh Long */ public class RetryTemplate implements RetryOperations { @@ -102,7 +104,7 @@ public class RetryTemplate implements RetryOperations { * Setter for listeners. The listeners are executed before and after a retry block * (i.e. before and after all the attempts), and on an error (every attempt). * - * @param listeners + * @param listeners the {@link RetryListener}s * @see RetryListener */ public void setListeners(RetryListener[] listeners) { @@ -113,7 +115,7 @@ public class RetryTemplate implements RetryOperations { /** * Register an additional listener. * - * @param listener + * @param listener the {@link RetryListener} * @see #setListeners(RetryListener[]) */ public void registerListener(RetryListener listener) { @@ -125,7 +127,7 @@ public class RetryTemplate implements RetryOperations { /** * Setter for {@link BackOffPolicy}. * - * @param backOffPolicy + * @param backOffPolicy the {@link BackOffPolicy} */ public void setBackOffPolicy(BackOffPolicy backOffPolicy) { this.backOffPolicy = backOffPolicy; @@ -134,7 +136,7 @@ public class RetryTemplate implements RetryOperations { /** * Setter for {@link RetryPolicy}. * - * @param retryPolicy + * @param retryPolicy the {@link RetryPolicy} */ public void setRetryPolicy(RetryPolicy retryPolicy) { this.retryPolicy = retryPolicy; @@ -146,6 +148,7 @@ public class RetryTemplate implements RetryOperations { * rethrown. * * @see RetryOperations#execute(RetryCallback) + * @param retryCallback the {@link RetryCallback} * * @throws TerminatedRetryException if the retry has been manually terminated by a * listener. @@ -159,7 +162,8 @@ public class RetryTemplate implements RetryOperations { * stop, in which case the recovery callback will be executed. * * @see RetryOperations#execute(RetryCallback, RecoveryCallback) - * + * @param retryCallback the {@link RetryCallback} + * @param recoveryCallback the {@link RecoveryCallback} * @throws TerminatedRetryException if the retry has been manually terminated by a * listener. */ @@ -173,7 +177,8 @@ public class RetryTemplate implements RetryOperations { * exception encountered so that clients can re-present the same task later. * * @see RetryOperations#execute(RetryCallback, RetryState) - * + * @param retryCallback the {@link RetryCallback} + * @param retryState the {@link RetryState} * @throws ExhaustedRetryException if the retry has been exhausted. */ public final T execute(RetryCallback retryCallback, RetryState retryState) @@ -186,6 +191,9 @@ public class RetryTemplate implements RetryOperations { * exception encountered so that clients can re-present the same task later. * * @see RetryOperations#execute(RetryCallback, RetryState) + * @param retryCallback the {@link RetryCallback} + * @param recoveryCallback the {@link RecoveryCallback} + * @param retryState the {@link RetryState} */ public final T execute(RetryCallback retryCallback, RecoveryCallback recoveryCallback, RetryState retryState) @@ -196,10 +204,15 @@ public class RetryTemplate implements RetryOperations { /** * Execute the callback once if the policy dictates that we can, otherwise execute the * recovery callback. - * + * @param recoveryCallback the {@link RecoveryCallback} + * @param retryCallback the {@link RetryCallback} + * @param state the {@link RetryState} + * @param the type of the return value + * @param the exception type to throw * @see RetryOperations#execute(RetryCallback, RecoveryCallback, RetryState) - * @throws ExhaustedRetryException if the retry has been exhausted. finally { - + * @throws ExhaustedRetryException if the retry has been exhausted. + * @throws E an exception if the retry operation fails + * @return T the retried value */ protected T doExecute(RetryCallback retryCallback, RecoveryCallback recoveryCallback, RetryState state) throws E, @@ -348,9 +361,10 @@ public class RetryTemplate implements RetryOperations { * Clean up the cache if necessary and close the context provided (if the flag * indicates that processing was successful). * - * @param context - * @param state - * @param succeeded + * @param retryPolicy the {@link RetryPolicy} + * @param context the {@link RetryContext} + * @param state the {@link RetryState} + * @param succeeded whether the close succeeded */ protected void close(RetryPolicy retryPolicy, RetryContext context, RetryState state, boolean succeeded) { @@ -366,10 +380,10 @@ public class RetryTemplate implements RetryOperations { } /** - * @param retryPolicy - * @param state - * @param context - * @param e + * @param retryPolicy the retry policy + * @param state the retry state + * @param context the retry context + * @param e the exception thrown */ protected void registerThrowable(RetryPolicy retryPolicy, RetryState state, RetryContext context, Throwable e) { @@ -390,7 +404,9 @@ public class RetryTemplate implements RetryOperations { * Delegate to the {@link RetryPolicy} having checked in the cache for an existing * value if the state is not null. * + * @param state a {@link RetryState} * @param retryPolicy a {@link RetryPolicy} to delegate the context creation + * * @return a retry context, either a new one or the one used last time the same state * was encountered */ @@ -429,10 +445,6 @@ public class RetryTemplate implements RetryOperations { } - /** - * @param retryPolicy - * @return - */ private RetryContext doOpenInternal(RetryPolicy retryPolicy) { return retryPolicy.open(RetrySynchronizationManager.getContext()); } @@ -444,10 +456,13 @@ public class RetryTemplate implements RetryOperations { * * @param recoveryCallback the callback for recovery (might be null) * @param context the current retry context + * @param state the {@link RetryState} + * @param the type to classify * @throws Exception if the callback does, and if there is no callback and the state * is null then the last exception from the context * @throws ExhaustedRetryException if the state is not null and there is no recovery * callback + * @return T the payload to return */ protected T handleRetryExhausted(RecoveryCallback recoveryCallback, RetryContext context, RetryState state) throws Throwable { @@ -480,9 +495,9 @@ public class RetryTemplate implements RetryOperations { * in a {@link RetryCallback}. Normal stateless behaviour is not to rethrow, and if * there is state we rethrow. * - * @param retryPolicy + * @param retryPolicy the retry policy * @param context the current context - * + * @param state the current retryState * @return true if the state is not null but subclasses might choose otherwise */ protected boolean shouldRethrow(RetryPolicy retryPolicy, RetryContext context, RetryState state) {