|
|
@ -291,18 +291,21 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
|
|
|
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
|
|
|
throws BeansException {
|
|
|
|
throws BeansException {
|
|
|
|
ConfigurationProperties annotation = AnnotationUtils
|
|
|
|
ConfigurationProperties annotation = getAnnotation(bean, beanName);
|
|
|
|
.findAnnotation(bean.getClass(), ConfigurationProperties.class);
|
|
|
|
|
|
|
|
Object bound = bean;
|
|
|
|
|
|
|
|
if (annotation != null) {
|
|
|
|
if (annotation != null) {
|
|
|
|
bound = postProcessBeforeInitialization(bean, beanName, annotation);
|
|
|
|
postProcessBeforeInitialization(bean, beanName, annotation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
annotation = this.beans.findFactoryAnnotation(beanName,
|
|
|
|
return bean;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ConfigurationProperties getAnnotation(Object bean, String beanName) {
|
|
|
|
|
|
|
|
ConfigurationProperties annotation = this.beans.findFactoryAnnotation(beanName,
|
|
|
|
ConfigurationProperties.class);
|
|
|
|
ConfigurationProperties.class);
|
|
|
|
if (annotation != null) {
|
|
|
|
if (annotation == null) {
|
|
|
|
bound = postProcessBeforeInitialization(bean, beanName, annotation);
|
|
|
|
annotation = AnnotationUtils.findAnnotation(bean.getClass(),
|
|
|
|
|
|
|
|
ConfigurationProperties.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bound;
|
|
|
|
return annotation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -311,7 +314,7 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
|
|
|
|
return bean;
|
|
|
|
return bean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Object postProcessBeforeInitialization(Object bean, String beanName,
|
|
|
|
private void postProcessBeforeInitialization(Object bean, String beanName,
|
|
|
|
ConfigurationProperties annotation) {
|
|
|
|
ConfigurationProperties annotation) {
|
|
|
|
Binder binder = getBinder();
|
|
|
|
Binder binder = getBinder();
|
|
|
|
Validator validator = determineValidator(bean);
|
|
|
|
Validator validator = determineValidator(bean);
|
|
|
@ -319,7 +322,6 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
|
|
|
|
Bindable<?> bindable = Bindable.ofInstance(bean);
|
|
|
|
Bindable<?> bindable = Bindable.ofInstance(bean);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
binder.bind(annotation.prefix(), bindable, handler);
|
|
|
|
binder.bind(annotation.prefix(), bindable, handler);
|
|
|
|
return bean;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex) {
|
|
|
|
catch (Exception ex) {
|
|
|
|
String targetClass = ClassUtils.getShortName(bean.getClass());
|
|
|
|
String targetClass = ClassUtils.getShortName(bean.getClass());
|
|
|
|