本文整理汇总了Java中javax.validation.Configuration.getDefaultMessageInterpolator方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.getDefaultMessageInterpolator方法的具体用法?Java Configuration.getDefaultMessageInterpolator怎么用?Java Configuration.getDefaultMessageInterpolator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.validation.Configuration
的用法示例。
在下文中一共展示了Configuration.getDefaultMessageInterpolator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BeanMessageInterpolator
import javax.validation.Configuration; //导入方法依赖的package包/类
/**
* Creates a new BeanMessageInterpolator object. The nested delegator is
* pulled from the bootstrap of the validation provider
*
*/
public BeanMessageInterpolator() {
@SuppressWarnings("rawtypes")
Configuration configuration = Validation.byDefaultProvider().configure();
delegate = configuration.getDefaultMessageInterpolator();
}
示例2: afterPropertiesSet
import javax.validation.Configuration; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() {
@SuppressWarnings({"rawtypes", "unchecked"})
Configuration<?> configuration = (this.providerClass != null ?
Validation.byProvider(this.providerClass).configure() :
Validation.byDefaultProvider().configure());
MessageInterpolator targetInterpolator = this.messageInterpolator;
if (targetInterpolator == null) {
targetInterpolator = configuration.getDefaultMessageInterpolator();
}
configuration.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));
if (this.traversableResolver != null) {
configuration.traversableResolver(this.traversableResolver);
}
ConstraintValidatorFactory targetConstraintValidatorFactory = this.constraintValidatorFactory;
if (targetConstraintValidatorFactory == null && this.applicationContext != null) {
targetConstraintValidatorFactory =
new SpringConstraintValidatorFactory(this.applicationContext.getAutowireCapableBeanFactory());
}
if (targetConstraintValidatorFactory != null) {
configuration.constraintValidatorFactory(targetConstraintValidatorFactory);
}
if (this.parameterNameDiscoverer != null) {
configureParameterNameProviderIfPossible(configuration);
}
if (this.mappingLocations != null) {
for (Resource location : this.mappingLocations) {
try {
configuration.addMapping(location.getInputStream());
}
catch (IOException ex) {
throw new IllegalStateException("Cannot read mapping resource: " + location);
}
}
}
for (Map.Entry<String, String> entry : this.validationPropertyMap.entrySet()) {
configuration.addProperty(entry.getKey(), entry.getValue());
}
// Allow for custom post-processing before we actually build the ValidatorFactory.
postProcessConfiguration(configuration);
this.validatorFactory = configuration.buildValidatorFactory();
setTargetValidator(this.validatorFactory.getValidator());
}
示例3: afterPropertiesSet
import javax.validation.Configuration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void afterPropertiesSet() {
@SuppressWarnings("rawtypes")
Configuration configuration = (this.providerClass != null ?
Validation.byProvider(this.providerClass).configure() :
Validation.byDefaultProvider().configure());
MessageInterpolator targetInterpolator = this.messageInterpolator;
if (targetInterpolator == null) {
targetInterpolator = configuration.getDefaultMessageInterpolator();
}
configuration.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));
if (this.traversableResolver != null) {
configuration.traversableResolver(this.traversableResolver);
}
ConstraintValidatorFactory targetConstraintValidatorFactory = this.constraintValidatorFactory;
if (targetConstraintValidatorFactory == null && this.applicationContext != null) {
targetConstraintValidatorFactory =
new SpringConstraintValidatorFactory(this.applicationContext.getAutowireCapableBeanFactory());
}
if (targetConstraintValidatorFactory != null) {
configuration.constraintValidatorFactory(targetConstraintValidatorFactory);
}
if (this.mappingLocations != null) {
for (Resource location : this.mappingLocations) {
try {
configuration.addMapping(location.getInputStream());
}
catch (IOException ex) {
throw new IllegalStateException("Cannot read mapping resource: " + location);
}
}
}
for (Map.Entry<String, String> entry : this.validationPropertyMap.entrySet()) {
configuration.addProperty(entry.getKey(), entry.getValue());
}
// Allow for custom post-processing before we actually build the ValidatorFactory.
postProcessConfiguration(configuration);
this.validatorFactory = configuration.buildValidatorFactory();
setTargetValidator(this.validatorFactory.getValidator());
}