From 8a74afa4b6c33a93bfdfb7fef0f64165cebe366b Mon Sep 17 00:00:00 2001 From: chentianming Date: Sun, 4 Dec 2022 20:20:57 +0800 Subject: [PATCH] update dependency and doc --- README.md | 4 +- README_EN.md | 4 +- pom.xml | 54 ++++++++----------- .../boot/config/RetrofitProperties.java | 5 ++ .../boot/core/BodyCallAdapterFactory.java | 3 +- .../spring/boot/core/ErrorDecoder.java | 10 ++-- .../boot/core/InternalCallAdapterFactory.java | 1 + .../boot/core/ResponseCallAdapterFactory.java | 3 +- .../spring/boot/core/RetrofitClient.java | 38 ++++++++++--- .../core/RetrofitClientScannerRegistrar.java | 5 -- .../spring/boot/core/RetrofitFactoryBean.java | 4 +- .../core/SourceOkHttpClientRegistrar.java | 2 + .../boot/core/SourceOkHttpClientRegistry.java | 1 + .../boot/degrade/ResourceNameParser.java | 2 + .../spring/boot/degrade/RetrofitDegrade.java | 2 + .../CircuitBreakerConfigRegistrar.java | 1 + .../resilience4j/Resilience4jDegrade.java | 4 ++ .../degrade/sentinel/SentinelDegrade.java | 8 +++ .../interceptor/BasePathMatchInterceptor.java | 2 +- .../spring/boot/interceptor/Intercept.java | 5 ++ .../retrofit/spring/boot/log/Logging.java | 6 +++ .../retrofit/spring/boot/retry/Retry.java | 4 +- .../boot/util/AnnotationExtendUtils.java | 2 + .../spring/boot/util/AppContextUtils.java | 5 ++ .../spring/boot/util/BeanExtendUtils.java | 4 +- .../spring/boot/util/RetrofitUtils.java | 2 +- 26 files changed, 123 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 414dde5..d0dbc81 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ [English Document](https://github.com/LianjiaTech/retrofit-spring-boot-starter/blob/master/README_EN.md) **适用于retrofit的spring-boot启动器,支持快速集成和功能增强**。 +1. *Spring Boot 3.x 项目,请使用retrofit-spring-boot-starter 3.x*。 +2. *Spring Boot 1.x/2.x 项目,请使用retrofit-spring-boot-starter 2.x*。 > 🚀项目持续优化迭代,欢迎大家提ISSUE和PR!麻烦大家能给一颗star✨,您的star是我们持续更新的动力! @@ -49,7 +51,7 @@ gitee项目地址:[https://gitee.com/lianjiatech/retrofit-spring-boot-starter] com.github.lianjiatech retrofit-spring-boot-starter - 2.3.10 + 2.3.11 ``` diff --git a/README_EN.md b/README_EN.md index fd68261..df6a35a 100644 --- a/README_EN.md +++ b/README_EN.md @@ -12,6 +12,8 @@ [中文文档](https://github.com/LianjiaTech/retrofit-spring-boot-starter/blob/master/README.md) **A spring-boot starter for retrofit, supports rapid integration and feature enhancements.** +1. *Spring Boot 3.x project,please use retrofit-spring-boot-starter 3.x*。 +2. *Spring Boot 1.x/2.x project,please use retrofit-spring-boot-starter 2.x*。 > Open source is not easy, please give me a star⭐️ @@ -39,7 +41,7 @@ com.github.lianjiatech retrofit-spring-boot-starter - 2.3.10 + 2.3.11 ``` diff --git a/pom.xml b/pom.xml index aab6163..b8593ee 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.lianjiatech retrofit-spring-boot-starter - 2.3.10 + 2.3.11 retrofit-spring-boot-starter retrofit-spring-boot-starter @@ -38,13 +38,10 @@ 2.9.0 - 4.13.1 1.3.2 - 1.7.25 - 2.0.9.RELEASE + 2.7.6 3.14.9 1.6.3 - 2.13.4.2 1.18.24 @@ -74,6 +71,18 @@ spring-boot-starter-test ${spring-boot.version} test + + + slf4j-api + org.slf4j + + + + + org.springframework.boot + spring-boot-starter-logging + ${spring-boot.version} + provided com.squareup.retrofit2 @@ -84,36 +93,12 @@ com.squareup.retrofit2 converter-jackson ${retrofit.version} - - - com.fasterxml.jackson.core - jackson-databind - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - junit - junit - ${junit.version} - test javax.annotation javax.annotation-api ${javax.annotation-api.version} - - - org.slf4j - slf4j-api - ${slf4j-api.version} - - com.squareup.okhttp3 logging-interceptor @@ -153,6 +138,12 @@ resilience4j-circuitbreaker 1.7.1 provided + + + org.slf4j + slf4j-api + + io.projectreactor @@ -166,7 +157,6 @@ 3.1.5 provided - io.reactivex.rxjava2 rxjava @@ -221,7 +211,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.2.0 private true @@ -229,8 +219,6 @@ UTF-8 UTF-8 -Xdoclint:none - /Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home/bin/javadoc - diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/config/RetrofitProperties.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/config/RetrofitProperties.java index 2ecab59..8fe28d3 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/config/RetrofitProperties.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/config/RetrofitProperties.java @@ -23,6 +23,7 @@ public class RetrofitProperties { /** * 全局重试配置 + *

* retry config */ @NestedConfigurationProperty @@ -30,6 +31,7 @@ public class RetrofitProperties { /** * 熔断降级配置 + *

* degrade config */ @NestedConfigurationProperty @@ -37,6 +39,7 @@ public class RetrofitProperties { /** * 全局日志配置 + *

* log config */ @NestedConfigurationProperty @@ -50,6 +53,7 @@ public class RetrofitProperties { /** * 全局转换器工厂,转换器实例优先从Spring容器获取,如果没有获取到,则反射创建。 + *

* global converter factories, The converter instance is first obtained from the Spring container. If it is not obtained, it is created by reflection. */ @SuppressWarnings("unchecked") @@ -59,6 +63,7 @@ public class RetrofitProperties { /** * 全局调用适配器工厂,转换器实例优先从Spring容器获取,如果没有获取到,则反射创建。 + *

* global call adapter factories, The callAdapter instance is first obtained from the Spring container. If it is not obtained, it is created by reflection. */ @SuppressWarnings("unchecked") diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/BodyCallAdapterFactory.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/BodyCallAdapterFactory.java index 81d1e4a..b26514a 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/BodyCallAdapterFactory.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/BodyCallAdapterFactory.java @@ -31,7 +31,8 @@ import retrofit2.Retrofit; /** - * 同步调用,如果返回的http状态码是是成功,返回responseBody 反序列化之后的对象。否则,抛出异常!异常信息中包含请求和响应相关信息。
+ * 同步调用,如果返回的http状态码是是成功,返回responseBody 反序列化之后的对象。否则,抛出异常!异常信息中包含请求和响应相关信息。 + *

* Synchronous call, if the returned http status code is successful, return the responseBody object after deserialization. * Otherwise, throw an exception! The exception information includes request and response related information. * diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ErrorDecoder.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ErrorDecoder.java index 6fb97b8..ca96112 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ErrorDecoder.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ErrorDecoder.java @@ -9,8 +9,9 @@ /** * 错误解码器。ErrorDecoder. + *

* 当请求发生异常或者收到无效响应结果的时候,将HTTP相关信息解码到异常中,无效响应由业务自己判断 - * + *

* When an exception occurs in the request or an invalid response result is received, the HTTP related information is decoded into the exception, * and the invalid response is determined by the business itself. * @@ -20,6 +21,7 @@ public interface ErrorDecoder { /** * 当无效响应的时候,将HTTP信息解码到异常中,无效响应由业务自行判断。 + *

* When the response is invalid, decode the HTTP information into the exception, invalid response is determined by business. * * @param request request @@ -35,11 +37,12 @@ default RuntimeException invalidRespDecode(Request request, Response response) { /** * 当请求发生IO异常时,将HTTP信息解码到异常中。 + *

* When an IO exception occurs in the request, the HTTP information is decoded into the exception. * * @param request request * @param cause IOException - * @return RuntimeException + * @return 解码后的异常 */ default RuntimeException ioExceptionDecode(Request request, IOException cause) { return RetrofitException.errorExecuting(request, cause); @@ -47,11 +50,12 @@ default RuntimeException ioExceptionDecode(Request request, IOException cause) { /** * 当请求发生除IO异常之外的其它异常时,将HTTP信息解码到异常中。 + *

* When the request has an exception other than the IO exception, the HTTP information is decoded into the exception. * * @param request request * @param cause Exception - * @return RuntimeException + * @return 解码后的异常 */ default RuntimeException exceptionDecode(Request request, Exception cause) { return RetrofitException.errorUnknown(request, cause); diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/InternalCallAdapterFactory.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/InternalCallAdapterFactory.java index c4249ea..2e6f795 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/InternalCallAdapterFactory.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/InternalCallAdapterFactory.java @@ -2,6 +2,7 @@ /** * 组件内置CallAdapterFactory,标记接口。 + * * @author 陈添明 * @since 2022/9/12 8:08 下午 */ diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ResponseCallAdapterFactory.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ResponseCallAdapterFactory.java index 78b27d6..6c7bbc2 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ResponseCallAdapterFactory.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ResponseCallAdapterFactory.java @@ -31,7 +31,8 @@ import retrofit2.Retrofit; /** - * 同步调用执行,直接返回 #{@link Response} 对象。
+ * 同步调用执行,直接返回 #{@link Response} 对象。 + *

* Synchronous call execution, directly return #{@link Response} object * * @author 陈添明 diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClient.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClient.java index 93bc8e1..3809ca5 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClient.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClient.java @@ -21,45 +21,58 @@ public @interface RetrofitClient { /** - * 绝对URL(协议是必需的)。 + * 基础URL(协议是必需的)。 * 可以指定为属性键,例如:$ {propertyKey}。 * 如果baseUrl没有配置,则必须配置serviceId以及,path可选配置。 - * + *

* An absolute URL (the protocol is necessary). * Can be specified as property key, eg: ${propertyKey}. * If baseUrl is not configured, you must configure serviceId and path optional configuration. + *

* + * @return 基础Url */ String baseUrl() default Constants.STR_EMPTY; /** - * The name of the service. - * Can be specified as property key, eg: ${propertyKey}. + * The name of the service. Can be specified as property key, eg: ${propertyKey}. + * + * @return 服务id */ String serviceId() default Constants.STR_EMPTY; /** * Path prefix to be used by all method-level mappings. + * + * @return 服务路径前缀 */ String path() default Constants.STR_EMPTY; /** * 适用于当前接口的转换器工厂,优先级比全局转换器工厂更高。转换器实例优先从Spring容器获取,如果没有获取到,则反射创建。 + *

* Converter factory for the current interface, higher priority than global converter factory. * The converter instance is first obtained from the Spring container. If it is not obtained, it is created by reflection. + * + * @return 转换器工厂 */ Class[] converterFactories() default {}; /** * 适用于当前接口的调用适配器工厂,优先级比全局调用适配器工厂更高。转换器实例优先从Spring容器获取,如果没有获取到,则反射创建。 + *

* callAdapter factory for the current interface, higher priority than global callAdapter factory. * The converter instance is first obtained from the Spring container. If it is not obtained, it is created by reflection. + * + * @return 调用适配器工厂 */ Class[] callAdapterFactories() default {}; /** * Fallback class for the specified retrofit client interface. The fallback class must * implement the interface annotated by this annotation and be a valid spring bean. + * + * @return fallback class */ Class fallback() default void.class; @@ -68,16 +81,20 @@ * factory must produce instances of fallback classes that implement the interface * annotated by {@link RetrofitClient}.The fallback factory must be a valid spring bean. * bean. + * + * @return fallback factory */ Class fallbackFactory() default void.class; /** * 当前接口采用的错误解码器,当请求发生异常或者收到无效响应结果的时候,将HTTP相关信息解码到异常中,无效响应由业务自己判断。 - * 一般情况下,每个服务对应的无效响应各不相同,可以自定义对应的{@link ErrorDecoder},然后配置在这里。
+ * 一般情况下,每个服务对应的无效响应各不相同,可以自定义对应的{@link ErrorDecoder},然后配置在这里。 + *

* The error decoder used in the current interface will decode HTTP related information into the exception when an exception occurs in the request or an invalid response result is received. * The invalid response is determined by the business itself. * In general, the invalid response corresponding to each service is different, you can customize the corresponding {@link ErrorDecoder}, and then configure it here. * + * @return 错误解码器 */ Class errorDecoder() default ErrorDecoder.DefaultErrorDecoder.class; @@ -90,7 +107,9 @@ boolean validateEagerly() default false; /** - * 原始OkHttpClient,根据该名称到#{@link SourceOkHttpClientRegistry}查找对应的OkHttpClient来构建当前接口的OkhttpClient。 + * 源OkHttpClient,根据该名称到#{@link SourceOkHttpClientRegistry}查找对应的OkHttpClient来构建当前接口的OkhttpClient。 + * + * @return 源OkHttpClient */ String sourceOkHttpClient() default Constants.NO_SOURCE_OK_HTTP_CLIENT; @@ -102,6 +121,8 @@ * otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds. * If it is configured as -1, the global default configuration is used. * + * @return connectTimeoutMs + * */ int connectTimeoutMs() default Constants.INVALID_TIMEOUT_VALUE; @@ -110,6 +131,8 @@ * otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds. * If it is configured as -1, the global default configuration is used. * + * @return readTimeoutMs + * */ int readTimeoutMs() default Constants.INVALID_TIMEOUT_VALUE; @@ -118,6 +141,7 @@ * otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds. * If it is configured as -1, the global default configuration is used. * + * @return writeTimeoutMs */ int writeTimeoutMs() default Constants.INVALID_TIMEOUT_VALUE; @@ -127,6 +151,8 @@ * otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds. * If it is configured as -1, the global default configuration is used. * + * @return callTimeoutMs + * */ int callTimeoutMs() default Constants.INVALID_TIMEOUT_VALUE; diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClientScannerRegistrar.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClientScannerRegistrar.java index c5fd785..bf87962 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClientScannerRegistrar.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClientScannerRegistrar.java @@ -50,11 +50,6 @@ public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionR scanner.doScan(basePackages); } - /** - * 获取扫描的基础包路径 - * - * @return 基础包路径 - */ private String[] getPackagesToScan(AnnotationAttributes attributes) { String[] value = attributes.getStringArray("value"); String[] basePackages = attributes.getStringArray("basePackages"); diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitFactoryBean.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitFactoryBean.java index 711ca2f..a3a2f96 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitFactoryBean.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitFactoryBean.java @@ -3,15 +3,12 @@ import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; -import com.github.lianjiatech.retrofit.spring.boot.config.GlobalTimeoutProperty; -import com.github.lianjiatech.retrofit.spring.boot.config.RetrofitProperties; import org.springframework.beans.BeansException; import org.springframework.beans.factory.FactoryBean; import org.springframework.context.ApplicationContext; @@ -23,6 +20,7 @@ import org.springframework.util.Assert; import org.springframework.util.StringUtils; +import com.github.lianjiatech.retrofit.spring.boot.config.GlobalTimeoutProperty; import com.github.lianjiatech.retrofit.spring.boot.config.RetrofitConfigBean; import com.github.lianjiatech.retrofit.spring.boot.core.reactive.MonoCallAdapterFactory; import com.github.lianjiatech.retrofit.spring.boot.core.reactive.Rxjava2CompletableCallAdapterFactory; diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/SourceOkHttpClientRegistrar.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/SourceOkHttpClientRegistrar.java index 2c3746f..5147f7e 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/SourceOkHttpClientRegistrar.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/SourceOkHttpClientRegistrar.java @@ -2,6 +2,7 @@ /** * SourceOkHttpClientRegistry注册器 + * * @author 陈添明 * @since 2022/5/24 8:13 下午 */ @@ -9,6 +10,7 @@ public interface SourceOkHttpClientRegistrar { /** * 向#{@link SourceOkHttpClientRegistry}注册数据 + * * @param registry SourceOkHttpClientRegistry */ void register(SourceOkHttpClientRegistry registry); diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/SourceOkHttpClientRegistry.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/SourceOkHttpClientRegistry.java index 89e1e40..6a69de2 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/SourceOkHttpClientRegistry.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/SourceOkHttpClientRegistry.java @@ -12,6 +12,7 @@ /** * SourceOkHttpClient注册中心 + * * @author 陈添明 * @since 2022/5/24 7:54 下午 */ diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/ResourceNameParser.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/ResourceNameParser.java index 172e4ff..4fc2201 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/ResourceNameParser.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/ResourceNameParser.java @@ -19,12 +19,14 @@ public interface ResourceNameParser { /** * 解析资源名称 * @param method 方法 + * * @return 资源名称 */ String parseResourceName(Method method); /** * 解析方法路径 + * * @param method 方法 * @return 方法路径 */ diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/RetrofitDegrade.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/RetrofitDegrade.java index a9ad037..19268bc 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/RetrofitDegrade.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/RetrofitDegrade.java @@ -14,6 +14,7 @@ public interface RetrofitDegrade extends Interceptor { /** * 对于指定Retrofit接口,是否允许降级 + * * @param retrofitInterface Retrofit接口 * @return 是否允许降级 */ @@ -21,6 +22,7 @@ public interface RetrofitDegrade extends Interceptor { /** * 加载指定Retrofit接口下的降级规则 + * * @param retrofitInterface Retrofit接口 */ void loadDegradeRules(Class retrofitInterface); diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/resilience4j/CircuitBreakerConfigRegistrar.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/resilience4j/CircuitBreakerConfigRegistrar.java index 063a114..215e19c 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/resilience4j/CircuitBreakerConfigRegistrar.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/resilience4j/CircuitBreakerConfigRegistrar.java @@ -8,6 +8,7 @@ public interface CircuitBreakerConfigRegistrar { /** * 向#{@link CircuitBreakerConfigRegistry}注册数据 + * * @param registry CircuitBreakerConfigRegistry */ void register(CircuitBreakerConfigRegistry registry); diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/resilience4j/Resilience4jDegrade.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/resilience4j/Resilience4jDegrade.java index 7ca0b8f..e09d8f4 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/resilience4j/Resilience4jDegrade.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/resilience4j/Resilience4jDegrade.java @@ -20,11 +20,15 @@ /** * 是否开启 + * + * @return enable */ boolean enable() default true; /** * 根据该名称从#{@link CircuitBreakerConfigRegistry}中获取CircuitBreakerConfig,作为当前接口或者方法的熔断配置 + * + * @return circuitBreakerConfigName */ String circuitBreakerConfigName() default Constants.CIRCUIT_BREAKER_CLASS_NAME; } \ No newline at end of file diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/sentinel/SentinelDegrade.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/sentinel/SentinelDegrade.java index 8aa8742..a505dbe 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/sentinel/SentinelDegrade.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/degrade/sentinel/SentinelDegrade.java @@ -18,21 +18,29 @@ /** * 是否开启 + * + * @return 是否开启 */ boolean enable() default true; /** * 各降级策略对应的阈值。平均响应时间(ms),异常比例(0-1),异常数量(1-N) + * + * @return 阈值 */ double count() default 1000; /** * 熔断时长,单位为 s + * + * @return 熔断时长 */ int timeWindow() default 5; /** * 降级策略(0:平均响应时间;1:异常比例;2:异常数量) + * + * @return 降级策略 */ int grade() default 0; } diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/interceptor/BasePathMatchInterceptor.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/interceptor/BasePathMatchInterceptor.java index bd368e8..3264fd1 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/interceptor/BasePathMatchInterceptor.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/interceptor/BasePathMatchInterceptor.java @@ -50,7 +50,7 @@ public Response intercept(Chain chain) throws IOException { protected abstract Response doIntercept(Chain chain) throws IOException; /** - * 当前http的url路径是否与指定的patterns匹配。
+ * 当前http的url路径是否与指定的patterns匹配。 * Whether the current http URL path matches the specified patterns * * @param patterns the specified patterns diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/interceptor/Intercept.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/interceptor/Intercept.java index 0b8c0d9..7285bc7 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/interceptor/Intercept.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/interceptor/Intercept.java @@ -8,6 +8,7 @@ /** * 自动将注解上的参数值赋值到handleInterceptor实例上 + *

* Automatically assign the parameter value on the annotation to the handleInterceptor instance * * @author 陈添明 @@ -19,6 +20,7 @@ public @interface Intercept { /** * 拦截器匹配路径pattern + *

* Interceptor matching path pattern * * @return 拦截器匹配路径pattern Interceptor matching path pattern @@ -27,6 +29,7 @@ /** * 拦截器排除匹配,排除指定路径拦截 + *

* Interceptor excludes matching, excludes specified path interception * * @return 排除指定路径拦截pattern Exclude specified path interception pattern @@ -35,7 +38,9 @@ /** * Interceptor handler + *

* 优先从spring容器获取对应的Bean,如果获取不到,则使用反射创建一个! + *

* First obtain the corresponding Bean from the spring container, if not, use reflection to create one! * * @return 拦截器处理器 Interceptor handler diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/log/Logging.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/log/Logging.java index b619773..12a12bf 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/log/Logging.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/log/Logging.java @@ -19,22 +19,28 @@ /** * 是否启用日志打印,针对当前接口或者方法 + * + * @return 是否启用 */ boolean enable() default true; /** * 日志打印级别,支持的日志级别参见{@link LogLevel} * 如果为NULL,则取全局日志打印级别 + *

* Log printing level, see {@link LogLevel} for supported log levels * + * @return 日志打印级别 */ LogLevel logLevel() default LogLevel.INFO; /** * 日志打印策略,支持的日志打印策略参见{@link LogStrategy} * 如果为NULL,则取全局日志打印策略 + *

* Log printing strategy, see {@link LogStrategy} for supported log printing strategies * + * @return 日志打印策略 */ LogStrategy logStrategy() default LogStrategy.BASIC; } diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/retry/Retry.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/retry/Retry.java index 43bb46d..234b0e8 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/retry/Retry.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/retry/Retry.java @@ -25,6 +25,7 @@ /** * 最大重试次数,最大可设置为100 + *

* The maximum number of retries, the maximum can be set to 100 * * @return 最大重试次数;The maximum number of retries @@ -33,6 +34,7 @@ /** * 重试时间间隔 + *

* Retry interval * * @return 重试时间间隔;Retry interval @@ -41,7 +43,7 @@ /** * 重试规则,默认 响应状态码不是2xx 或者 发生IO异常 时触发重试 - * Retry rule + * * @return Retry rule */ RetryRule[] retryRules() default {RetryRule.RESPONSE_STATUS_NOT_2XX, RetryRule.OCCUR_IO_EXCEPTION}; diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/AnnotationExtendUtils.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/AnnotationExtendUtils.java index 2426c18..51ecccf 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/AnnotationExtendUtils.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/AnnotationExtendUtils.java @@ -16,6 +16,7 @@ public class AnnotationExtendUtils { /** * 查找方法及其类上的指定注解,优先返回方法上的。 + * * @param 注解泛型参数 * @param method 方法 * @param clazz 类型 @@ -33,6 +34,7 @@ public static A findMergedAnnotation(Method method, Class /** * 判断某个类及其公有方法上是否存在指定注解。 + * * @param 注解泛型参数 * @param clazz 类 * @param annotationType 注解类型 diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/AppContextUtils.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/AppContextUtils.java index c950485..a3693d6 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/AppContextUtils.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/AppContextUtils.java @@ -16,6 +16,11 @@ public final class AppContextUtils { /** * 优先从Spring容器获取实例,如果获取失败,调用无参方法创建,如果再失败,尝试调用无参create静态方法创建 + * + * @param context spring context + * @param clz 对象类型 + * @param 泛型参数 + * @return spring context实例,或者反射创建的实例。 */ @SuppressWarnings("unchecked") public static T getBeanOrNew(ApplicationContext context, Class clz) { diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/BeanExtendUtils.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/BeanExtendUtils.java index 9ddb0ea..6ba43eb 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/BeanExtendUtils.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/BeanExtendUtils.java @@ -15,7 +15,8 @@ public final class BeanExtendUtils { /** - * 使用map填充bean实例的属性值 + * 使用map填充bean实例的属性值。 + *

* Use map to fill in the attribute values of the bean instance * * @param bean 需要填充的实例bean。The instance bean that needs to be filled @@ -41,6 +42,7 @@ public static void populate(final Object bean, final Map properties) /** * 为指定实例对象的指定属性赋值,待赋值的属性字段必须提供setter方法。 + *

* Assign a value to the specified attribute of the specified instance object, the attribute field to be assigned must provide a setter method. * * @param bean 需要设置属性的示例对象。the object that needs to set properties diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/RetrofitUtils.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/RetrofitUtils.java index 17fad2f..6ea89df 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/RetrofitUtils.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/util/RetrofitUtils.java @@ -38,7 +38,7 @@ public final class RetrofitUtils { * * @param response response * @return ResponseBody String - * @throws IOException + * @throws ReadResponseBodyException ReadResponseBodyException */ public static String readResponseBody(Response response) throws ReadResponseBodyException { try {