add java doc

pull/304/head
weihu 3 years ago
parent 0d72a80483
commit f1699db2d7

@ -19,10 +19,13 @@ package com.tencent.cloud.polaris.circuitbreaker;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.SmartInitializingSingleton; import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.util.Map;
/** /**
* @author : wh * @author : wh
* @date : 2022/6/21 21:20 * @date : 2022/6/21 21:20
@ -40,7 +43,13 @@ public class PolarisRestTemplateRegisterAutoConfiguration implements Application
@Override @Override
public void afterSingletonsInstantiated() { public void afterSingletonsInstantiated() {
RestTemplate restTemplate = this.applicationContext.getBean(RestTemplate.class); Map<String, Object> beans = this.applicationContext.getBeansWithAnnotation(LoadBalanced.class);
beans.forEach(this::initRestTemplate);
this.applicationContext.getBean(RestTemplate.class);
}
private void initRestTemplate(String beanName, Object bean) {
RestTemplate restTemplate = (RestTemplate) bean;
restTemplate.setErrorHandler(polarisRestTemplateResponseErrorHandler); restTemplate.setErrorHandler(polarisRestTemplateResponseErrorHandler);
} }

Loading…
Cancel
Save