org.zodiac.autoconfigure.internal.InternalAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.internal;
import org.springframework.beans.factory.ObjectProvider;
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.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.bootstrap.condition.ConditionalOnAppDiscoveryEnabled;
import org.zodiac.core.application.AppContext;
import org.zodiac.core.bootstrap.discovery.AppDiscoveryClient;
import org.zodiac.core.internal.http.AppInternalHttpClient;
@SpringBootConfiguration
@ConditionalOnAppDiscoveryEnabled
@ConditionalOnWebApplication(type = Type.SERVLET)
@ConditionalOnClass(value = {org.springframework.web.client.RestTemplate.class})
public class InternalAutoConfiguration {
public InternalAutoConfiguration() {
super();
}
@Bean
@ConditionalOnMissingBean
protected AppInternalHttpClient internalHttpClient(AppDiscoveryClient discoveryClient, AppContext appContext,
ObjectProvider restTemplateProvider) {
return new AppInternalHttpClient(discoveryClient, appContext, restTemplateProvider.getIfAvailable());
}
}