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 org.springframework.core.env.Environment |
environment |
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接口类上定义的拦截器集合
|
private okhttp3.ConnectionPool |
getConnectionPool(Class<?> retrofitClientInterfaceClass)
获取okhttp3连接池
|
private BasePathMatchInterceptor |
getInterceptorInstance(Class<? extends BasePathMatchInterceptor> interceptorClass)
获取路径拦截器实例,优先从spring容器中取。
|
T |
getObject() |
Class<T> |
getObjectType() |
private okhttp3.OkHttpClient |
getOkHttpClient(Class<?> retrofitClientInterfaceClass)
获取OkHttpClient实例,一个接口接口对应一个OkHttpClient
|
private retrofit2.Retrofit |
getRetrofit(Class<?> retrofitClientInterfaceClass)
获取Retrofit实例,一个retrofitClient接口对应一个Retrofit实例
|
boolean |
isSingleton() |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setEnvironment(org.springframework.core.env.Environment environment) |
private org.springframework.core.env.Environment environment
private RetrofitProperties retrofitProperties
private RetrofitConfigBean retrofitConfigBean
private org.springframework.context.ApplicationContext applicationContext
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 - retrofitClient接口类private okhttp3.OkHttpClient getOkHttpClient(Class<?> retrofitClientInterfaceClass) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException
retrofitClientInterfaceClass - retrofitClient接口类IllegalAccessExceptionInstantiationExceptionNoSuchMethodExceptionInvocationTargetExceptionprivate List<okhttp3.Interceptor> findInterceptorByAnnotation(Class<?> retrofitClientInterfaceClass) throws InstantiationException, IllegalAccessException
retrofitClientInterfaceClass - retrofitClient接口类InstantiationExceptionIllegalAccessExceptionprivate BasePathMatchInterceptor getInterceptorInstance(Class<? extends BasePathMatchInterceptor> interceptorClass) throws IllegalAccessException, InstantiationException
interceptorClass - 路径拦截器类的子类,参见@BasePathMatchInterceptorIllegalAccessExceptionInstantiationExceptionprivate retrofit2.Retrofit getRetrofit(Class<?> retrofitClientInterfaceClass) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException
retrofitClientInterfaceClass - retrofitClient接口类InstantiationExceptionIllegalAccessExceptionNoSuchMethodExceptionInvocationTargetExceptionpublic 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 © 2020. All rights reserved.