org.zodiac.autoconfigure.feign.OkHttpFeignConsumerConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.feign;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.feign.condition.ConditionalOnFeignConsumerEnabled;
import org.zodiac.autoconfigure.feign.condition.ConditionalOnFeignOkHttpEnabled;
@SpringBootConfiguration
@ConditionalOnFeignConsumerEnabled
@ConditionalOnFeignOkHttpEnabled
@ConditionalOnClass(value = {feign.Client.class, org.zodiac.feign.core.FeignConsumerClientProvider.class, okhttp3.OkHttpClient.class})
@ConditionalOnExpression(value = "'" + org.zodiac.feign.core.constants.FeignConstants.CLIENT_PROVIDER_OK_HTTP + "'.equalsIgnoreCase('${" + org.zodiac.feign.core.constants.FeignSystemPropertiesConstants.FEIGN_CLIENT_CONSUMER_PROVIDER + ":" + org.zodiac.feign.core.constants.FeignConstants.CLIENT_PROVIDER_OK_HTTP + "}')")
class OkHttpFeignConsumerConfiguration {
private FeignConsumerProperties feignConsumerProperties;
protected OkHttpFeignConsumerConfiguration(FeignConsumerProperties feignConsumerProperties) {
this.feignConsumerProperties = feignConsumerProperties;
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.feign.core.config.OkHttpFeignConsumerConfigurer okHttpFeignConsumerConfigurer() {
return new org.zodiac.feign.core.config.OkHttpFeignConsumerConfigurer(this.feignConsumerProperties);
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.okhttp.logger.HttpLoggingInterceptor loggingInterceptor(org.zodiac.feign.core.config.OkHttpFeignConsumerConfigurer okHttpFeignConsumerConfigurer) {
return okHttpFeignConsumerConfigurer.loggingInterceptor();
}
@Bean
@ConditionalOnMissingBean
protected okhttp3.ConnectionPool okHttp3ConnectionPool(org.zodiac.feign.core.config.OkHttpFeignConsumerConfigurer okHttpFeignConsumerConfigurer) {
return okHttpFeignConsumerConfigurer.okHttp3ConnectionPool();
}
@ConditionalOnMissingBean
@Bean(name = org.zodiac.feign.core.constants.FeignConsumerConstants.BEAN_FEIGN_CLIENT)
protected feign.Client okHttpFeignClient(org.zodiac.feign.core.config.OkHttpFeignConsumerConfigurer okHttpFeignConsumerConfigurer,
okhttp3.ConnectionPool connectionPool, ObjectProvider interceptorsProvider) {
return okHttpFeignConsumerConfigurer.okHttpFeignClient(connectionPool, interceptorsProvider);
}
}