Search in sources :

Example 1 with HttpClient

use of com.ctrip.framework.apollo.util.http.HttpClient in project apollo by ctripcorp.

the class ApolloClientLongPollingExtensionInitializer method initialize.

@Override
public void initialize(ApolloClientProperties apolloClientProperties, Binder binder, BindHandler bindHandler) {
    WebClient.Builder webClientBuilder = WebClient.builder();
    List<ApolloClientWebClientCustomizerFactory> factories = ServiceBootstrap.loadAllOrdered(ApolloClientWebClientCustomizerFactory.class);
    if (!CollectionUtils.isEmpty(factories)) {
        for (ApolloClientWebClientCustomizerFactory factory : factories) {
            WebClientCustomizer webClientCustomizer = factory.createWebClientCustomizer(apolloClientProperties, binder, bindHandler, this.log, this.bootstrapContext);
            if (webClientCustomizer != null) {
                webClientCustomizer.customize(webClientBuilder);
            }
        }
    }
    HttpClient httpClient = new ApolloWebClientHttpClient(webClientBuilder.build());
    ApolloConfigDataInjectorCustomizer.registerIfAbsent(HttpClient.class, () -> httpClient);
}
Also used : WebClientCustomizer(org.springframework.boot.web.reactive.function.client.WebClientCustomizer) ApolloClientWebClientCustomizerFactory(com.ctrip.framework.apollo.config.data.extension.webclient.customizer.spi.ApolloClientWebClientCustomizerFactory) HttpClient(com.ctrip.framework.apollo.util.http.HttpClient) WebClient(org.springframework.web.reactive.function.client.WebClient)

Aggregations

ApolloClientWebClientCustomizerFactory (com.ctrip.framework.apollo.config.data.extension.webclient.customizer.spi.ApolloClientWebClientCustomizerFactory)1 HttpClient (com.ctrip.framework.apollo.util.http.HttpClient)1 WebClientCustomizer (org.springframework.boot.web.reactive.function.client.WebClientCustomizer)1 WebClient (org.springframework.web.reactive.function.client.WebClient)1