|
|
|
@ -55,7 +55,9 @@ class ConfigurationPropertiesBinder { |
|
|
|
|
|
|
|
|
|
|
|
private final Validator configurationPropertiesValidator; |
|
|
|
private final Validator configurationPropertiesValidator; |
|
|
|
|
|
|
|
|
|
|
|
private final Validator jsr303Validator; |
|
|
|
private final boolean jsr303Present; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private volatile Validator jsr303Validator; |
|
|
|
|
|
|
|
|
|
|
|
private volatile Binder binder; |
|
|
|
private volatile Binder binder; |
|
|
|
|
|
|
|
|
|
|
|
@ -66,8 +68,8 @@ class ConfigurationPropertiesBinder { |
|
|
|
.getPropertySources(); |
|
|
|
.getPropertySources(); |
|
|
|
this.configurationPropertiesValidator = getConfigurationPropertiesValidator( |
|
|
|
this.configurationPropertiesValidator = getConfigurationPropertiesValidator( |
|
|
|
applicationContext, validatorBeanName); |
|
|
|
applicationContext, validatorBeanName); |
|
|
|
this.jsr303Validator = ConfigurationPropertiesJsr303Validator |
|
|
|
this.jsr303Present = ConfigurationPropertiesJsr303Validator |
|
|
|
.getIfJsr303Present(applicationContext); |
|
|
|
.isJsr303Present(applicationContext); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void bind(Bindable<?> target) { |
|
|
|
public void bind(Bindable<?> target) { |
|
|
|
@ -93,9 +95,8 @@ class ConfigurationPropertiesBinder { |
|
|
|
if (this.configurationPropertiesValidator != null) { |
|
|
|
if (this.configurationPropertiesValidator != null) { |
|
|
|
validators.add(this.configurationPropertiesValidator); |
|
|
|
validators.add(this.configurationPropertiesValidator); |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.jsr303Validator != null |
|
|
|
if (this.jsr303Present && target.getAnnotation(Validated.class) != null) { |
|
|
|
&& target.getAnnotation(Validated.class) != null) { |
|
|
|
validators.add(getJsr303Validator()); |
|
|
|
validators.add(this.jsr303Validator); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (target.getValue() != null && target.getValue().get() instanceof Validator) { |
|
|
|
if (target.getValue() != null && target.getValue().get() instanceof Validator) { |
|
|
|
validators.add((Validator) target.getValue().get()); |
|
|
|
validators.add((Validator) target.getValue().get()); |
|
|
|
@ -103,6 +104,14 @@ class ConfigurationPropertiesBinder { |
|
|
|
return validators; |
|
|
|
return validators; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Validator getJsr303Validator() { |
|
|
|
|
|
|
|
if (this.jsr303Validator == null) { |
|
|
|
|
|
|
|
this.jsr303Validator = new ConfigurationPropertiesJsr303Validator( |
|
|
|
|
|
|
|
this.applicationContext); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return this.jsr303Validator; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private BindHandler getBindHandler(ConfigurationProperties annotation, |
|
|
|
private BindHandler getBindHandler(ConfigurationProperties annotation, |
|
|
|
List<Validator> validators) { |
|
|
|
List<Validator> validators) { |
|
|
|
BindHandler handler = new IgnoreTopLevelConverterNotFoundBindHandler(); |
|
|
|
BindHandler handler = new IgnoreTopLevelConverterNotFoundBindHandler(); |
|
|
|
|