public class RetrofitFactoryBean<T> extends Object implements org.springframework.beans.factory.FactoryBean<T>, org.springframework.context.EnvironmentAware, org.springframework.context.ApplicationContextAware
| 限定符和类型 | 字段和说明 |
|---|---|
private org.springframework.context.ApplicationContext |
applicationContext |
private static Map<Class<? extends retrofit2.CallAdapter.Factory>,retrofit2.CallAdapter.Factory> |
CALL_ADAPTER_FACTORIES_CACHE |
private static Map<Class<? extends retrofit2.Converter.Factory>,retrofit2.Converter.Factory> |
CONVERTER_FACTORIES_CACHE |
private org.springframework.core.env.Environment |
environment |
private static org.slf4j.Logger |
logger |
private RetrofitClient |
retrofitClient |
private RetrofitConfigBean |
retrofitConfigBean |
private Class<T> |
retrofitInterface |
private RetrofitProperties |
retrofitProperties |
| 构造器和说明 |
|---|
RetrofitFactoryBean(Class<T> retrofitInterface) |
| 限定符和类型 | 方法和说明 |
|---|---|
private void |
checkRetrofitInterface(Class<T> retrofitInterface)
RetrofitInterface检查
|
private List<okhttp3.Interceptor> |
findInterceptorByAnnotation(Class<?> retrofitClientInterfaceClass)
获取retrofitClient接口类上定义的拦截器集合
Get the interceptor set defined on the retrofitClient interface class
|
private Method |
findOkHttpClientBuilderMethod(Class<?> retrofitClientInterfaceClass) |
private List<retrofit2.CallAdapter.Factory> |
getCallAdapterFactories(Class<? extends retrofit2.CallAdapter.Factory>[] callAdapterFactoryClasses,
Class<? extends retrofit2.CallAdapter.Factory>[] globalCallAdapterFactoryClasses) |
private okhttp3.ConnectionPool |
getConnectionPool(Class<?> retrofitClientInterfaceClass)
Get okhttp3 connection pool
|
private List<retrofit2.Converter.Factory> |
getConverterFactories(Class<? extends retrofit2.Converter.Factory>[] converterFactoryClasses,
Class<? extends retrofit2.Converter.Factory>[] globalConverterFactoryClasses) |
private BasePathMatchInterceptor |
getInterceptorInstance(Class<? extends BasePathMatchInterceptor> interceptorClass)
获取路径拦截器实例,优先从spring容器中取。
|
T |
getObject() |
Class<T> |
getObjectType() |
private okhttp3.OkHttpClient |
getOkHttpClient(Class<?> retrofitClientInterfaceClass)
Get OkHttpClient instance, one interface corresponds to one OkHttpClient
|
private retrofit2.Retrofit |
getRetrofit(Class<?> retrofitClientInterfaceClass)
获取Retrofit实例,一个retrofitClient接口对应一个Retrofit实例
Obtain a Retrofit instance, a retrofitClient interface corresponds to a Retrofit instance
|
boolean |
isSingleton() |
private void |
loadDegradeRules() |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setEnvironment(org.springframework.core.env.Environment environment) |
private static final org.slf4j.Logger logger
private static final Map<Class<? extends retrofit2.CallAdapter.Factory>,retrofit2.CallAdapter.Factory> CALL_ADAPTER_FACTORIES_CACHE
private org.springframework.core.env.Environment environment
private RetrofitProperties retrofitProperties
private RetrofitConfigBean retrofitConfigBean
private org.springframework.context.ApplicationContext applicationContext
private RetrofitClient retrofitClient
private void loadDegradeRules()
private void checkRetrofitInterface(Class<T> retrofitInterface)
retrofitInterface - .public Class<T> getObjectType()
getObjectType 在接口中 org.springframework.beans.factory.FactoryBean<T>public boolean isSingleton()
isSingleton 在接口中 org.springframework.beans.factory.FactoryBean<T>private okhttp3.ConnectionPool getConnectionPool(Class<?> retrofitClientInterfaceClass)
retrofitClientInterfaceClass - retrofitClientInterfaceClassprivate okhttp3.OkHttpClient getOkHttpClient(Class<?> retrofitClientInterfaceClass) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException
retrofitClientInterfaceClass - retrofitClientInterfaceClassIllegalAccessExceptionInstantiationExceptionNoSuchMethodExceptionInvocationTargetExceptionprivate Method findOkHttpClientBuilderMethod(Class<?> retrofitClientInterfaceClass)
private List<okhttp3.Interceptor> findInterceptorByAnnotation(Class<?> retrofitClientInterfaceClass) throws InstantiationException, IllegalAccessException
retrofitClientInterfaceClass - retrofitClientInterfaceClassInstantiationExceptionIllegalAccessExceptionprivate BasePathMatchInterceptor getInterceptorInstance(Class<? extends BasePathMatchInterceptor> interceptorClass) throws IllegalAccessException, InstantiationException
interceptorClass - A subclass of @BasePathMatchInterceptorBasePathMatchInterceptor instanceIllegalAccessExceptionInstantiationExceptionprivate retrofit2.Retrofit getRetrofit(Class<?> retrofitClientInterfaceClass) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException
retrofitClientInterfaceClass - retrofitClientInterfaceClassInstantiationExceptionIllegalAccessExceptionNoSuchMethodExceptionInvocationTargetExceptionprivate List<retrofit2.CallAdapter.Factory> getCallAdapterFactories(Class<? extends retrofit2.CallAdapter.Factory>[] callAdapterFactoryClasses, Class<? extends retrofit2.CallAdapter.Factory>[] globalCallAdapterFactoryClasses) throws IllegalAccessException, InstantiationException
private List<retrofit2.Converter.Factory> getConverterFactories(Class<? extends retrofit2.Converter.Factory>[] converterFactoryClasses, Class<? extends retrofit2.Converter.Factory>[] globalConverterFactoryClasses) throws IllegalAccessException, InstantiationException
public void setEnvironment(org.springframework.core.env.Environment environment)
setEnvironment 在接口中 org.springframework.context.EnvironmentAwarepublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext 在接口中 org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionCopyright © 2022. All rights reserved.