org.zodiac.autoconfigure.bootstrap.httpclient.HttpClientJava11AutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.bootstrap.httpclient;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.zodiac.core.constnts.CoreSystemPropertiesConstants;
import org.zodiac.core.httpclient.http2client.DefaultHttp2ClientFactory;
import org.zodiac.core.httpclient.http2client.Http2ClientFactory;
@SpringBootConfiguration
public class HttpClientJava11AutoConfiguration {
public HttpClientJava11AutoConfiguration() {
}
@SpringBootConfiguration
@ConditionalOnProperty(name = CoreSystemPropertiesConstants.Zodiac.SPRING_HTTP_CLIENT_HTTP2CLIENT_ENABLED, havingValue = "true")
@ConditionalOnClass(value = {java.net.http.HttpClient.class})
static class Http2ClientConfiguration {
@Bean
@ConditionalOnMissingBean
protected java.net.http.HttpClient.Builder http2ClientBuilder() {
return java.net.http.HttpClient.newBuilder();
}
@Bean
@ConditionalOnMissingBean
protected Http2ClientFactory okHttpClientFactory(java.net.http.HttpClient.Builder builder) {
return new DefaultHttp2ClientFactory(builder);
}
}
}