|
|
|
@ -68,8 +68,10 @@ public class MetadataTransferAutoConfiguration {
|
|
|
|
|
DecodeTransferMetadataServletFilter decodeTransferMetadataServletFilter) {
|
|
|
|
|
FilterRegistrationBean<DecodeTransferMetadataServletFilter> filterRegistrationBean = new FilterRegistrationBean<>(
|
|
|
|
|
decodeTransferMetadataServletFilter);
|
|
|
|
|
filterRegistrationBean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE, REQUEST);
|
|
|
|
|
filterRegistrationBean.setOrder(MetadataConstant.OrderConstant.WEB_FILTER_ORDER);
|
|
|
|
|
filterRegistrationBean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE,
|
|
|
|
|
REQUEST);
|
|
|
|
|
filterRegistrationBean
|
|
|
|
|
.setOrder(MetadataConstant.OrderConstant.WEB_FILTER_ORDER);
|
|
|
|
|
return filterRegistrationBean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -140,29 +142,34 @@ public class MetadataTransferAutoConfiguration {
|
|
|
|
|
BeanPostProcessor encodeTransferMetadataRestTemplatePostProcessor(
|
|
|
|
|
EncodeTransferMedataRestTemplateInterceptor encodeTransferMedataRestTemplateInterceptor) {
|
|
|
|
|
// Coping with multiple bean injection scenarios
|
|
|
|
|
Map<String, RestTemplate> beans = this.context.getBeansOfType(RestTemplate.class);
|
|
|
|
|
Map<String, RestTemplate> beans = this.context
|
|
|
|
|
.getBeansOfType(RestTemplate.class);
|
|
|
|
|
// If the restTemplate has been created when the
|
|
|
|
|
// MetadataRestTemplatePostProcessor Bean
|
|
|
|
|
// is initialized, then manually set the interceptor.
|
|
|
|
|
if (!CollectionUtils.isEmpty(beans)) {
|
|
|
|
|
for (RestTemplate restTemplate : beans.values()) {
|
|
|
|
|
List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
|
|
|
|
|
List<ClientHttpRequestInterceptor> interceptors = restTemplate
|
|
|
|
|
.getInterceptors();
|
|
|
|
|
// Avoid setting interceptor repeatedly.
|
|
|
|
|
if (null != interceptors && !interceptors.contains(encodeTransferMedataRestTemplateInterceptor)) {
|
|
|
|
|
if (!interceptors.contains(encodeTransferMedataRestTemplateInterceptor)) {
|
|
|
|
|
interceptors.add(encodeTransferMedataRestTemplateInterceptor);
|
|
|
|
|
restTemplate.setInterceptors(interceptors);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return new EncodeTransferMetadataRestTemplatePostProcessor(encodeTransferMedataRestTemplateInterceptor);
|
|
|
|
|
return new EncodeTransferMetadataRestTemplatePostProcessor(
|
|
|
|
|
encodeTransferMedataRestTemplateInterceptor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
|
|
|
public void setApplicationContext(ApplicationContext applicationContext)
|
|
|
|
|
throws BeansException {
|
|
|
|
|
this.context = applicationContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class EncodeTransferMetadataRestTemplatePostProcessor implements BeanPostProcessor {
|
|
|
|
|
public static class EncodeTransferMetadataRestTemplatePostProcessor
|
|
|
|
|
implements BeanPostProcessor {
|
|
|
|
|
|
|
|
|
|
private EncodeTransferMedataRestTemplateInterceptor encodeTransferMedataRestTemplateInterceptor;
|
|
|
|
|
|
|
|
|
@ -180,9 +187,10 @@ public class MetadataTransferAutoConfiguration {
|
|
|
|
|
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
|
|
|
|
if (bean instanceof RestTemplate) {
|
|
|
|
|
RestTemplate restTemplate = (RestTemplate) bean;
|
|
|
|
|
List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
|
|
|
|
|
List<ClientHttpRequestInterceptor> interceptors = restTemplate
|
|
|
|
|
.getInterceptors();
|
|
|
|
|
// Avoid setting interceptor repeatedly.
|
|
|
|
|
if (null != interceptors && !interceptors.contains(encodeTransferMedataRestTemplateInterceptor)) {
|
|
|
|
|
if (!interceptors.contains(encodeTransferMedataRestTemplateInterceptor)) {
|
|
|
|
|
interceptors.add(this.encodeTransferMedataRestTemplateInterceptor);
|
|
|
|
|
restTemplate.setInterceptors(interceptors);
|
|
|
|
|
}
|
|
|
|
|