spring-retry MethodInvocationRetryCallback 源码
spring-retry MethodInvocationRetryCallback 代码
文件路径:/src/main/java/org/springframework/retry/interceptor/MethodInvocationRetryCallback.java
/*
* Copyright 2006-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.retry.interceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.retry.RetryCallback;
import org.springframework.retry.RetryOperations;
import org.springframework.util.StringUtils;
/**
* Callback class for a Spring AOP reflective `MethodInvocation` that can be retried using
* a {@link RetryOperations}.
*
* In a concrete {@link org.springframework.retry.RetryListener} implementation, the
* `MethodInvocation` can be analysed for providing insights on the method called as well
* as its parameter values which could then be used for monitoring purposes.
*
* @param <T> the type of object returned by the callback
* @param <E> the type of exception it declares may be thrown
* @see StatefulRetryOperationsInterceptor
* @see RetryOperationsInterceptor
* @see org.springframework.retry.listener.MethodInvocationRetryListenerSupport
* @author Marius Grama
* @since 1.3
*/
public abstract class MethodInvocationRetryCallback<T, E extends Throwable> implements RetryCallback<T, E> {
protected final MethodInvocation invocation;
protected final String label;
/**
* Constructor for the class.
* @param invocation the method invocation
* @param label a unique label for statistics reporting.
*/
public MethodInvocationRetryCallback(MethodInvocation invocation, String label) {
this.invocation = invocation;
if (StringUtils.hasText(label)) {
this.label = label;
}
else {
this.label = invocation.getMethod().toGenericString();
}
}
public MethodInvocation getInvocation() {
return invocation;
}
public String getLabel() {
return label;
}
}
相关信息
相关文章
spring-retry FixedKeyGenerator 源码
spring-retry MethodArgumentsKeyGenerator 源码
spring-retry MethodInvocationRecoverer 源码
spring-retry NewMethodArgumentsIdentifier 源码
spring-retry RetryInterceptorBuilder 源码
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦