Search in sources :

Example 1 with PlatformResourceBundleLocator

use of org.hibernate.validator.resourceloading.PlatformResourceBundleLocator in project JessMA by ldcsaa.

the class HibernateBeanValidator method tryCreateValidator.

private Validator tryCreateValidator(final String bundle, final Locale locale, ValidatorKey key) {
    HibernateValidatorConfiguration configure = Validation.byProvider(HibernateValidator.class).configure();
    configure.messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator(bundle)) {

        @Override
        public String interpolate(String message, Context context) {
            return super.interpolate(message, context, locale);
        }
    });
    ValidatorFactory vf = configure.buildValidatorFactory();
    Validator validator = vf.getValidator();
    GeneralHelper.syncTryPut(validatorMap, key, validator);
    return validatorMap.get(key);
}
Also used : HibernateValidator(org.hibernate.validator.HibernateValidator) ResourceBundleMessageInterpolator(org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator) ValidatorFactory(javax.validation.ValidatorFactory) PlatformResourceBundleLocator(org.hibernate.validator.resourceloading.PlatformResourceBundleLocator) HibernateValidatorConfiguration(org.hibernate.validator.HibernateValidatorConfiguration) Validator(javax.validation.Validator) HibernateValidator(org.hibernate.validator.HibernateValidator) BeanValidator(org.jessma.mvc.BeanValidator)

Aggregations

Validator (javax.validation.Validator)1 ValidatorFactory (javax.validation.ValidatorFactory)1 HibernateValidator (org.hibernate.validator.HibernateValidator)1 HibernateValidatorConfiguration (org.hibernate.validator.HibernateValidatorConfiguration)1 ResourceBundleMessageInterpolator (org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator)1 PlatformResourceBundleLocator (org.hibernate.validator.resourceloading.PlatformResourceBundleLocator)1 BeanValidator (org.jessma.mvc.BeanValidator)1