Search in sources :

Example 1 with MessageInterpolatorImpl

use of org.glassfish.hk2.utilities.general.internal.MessageInterpolatorImpl in project glassfish-hk2 by eclipse-ee4j.

the class ValidatorUtilities method initializeValidator.

private static Validator initializeValidator() {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(HibernateValidator.class.getClassLoader());
        ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
        ValidatorContext validatorContext = validatorFactory.usingContext();
        validatorContext.messageInterpolator(new MessageInterpolatorImpl());
        return validatorContext.traversableResolver(TRAVERSABLE_RESOLVER).getValidator();
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
}
Also used : HibernateValidator(org.hibernate.validator.HibernateValidator) ValidatorFactory(jakarta.validation.ValidatorFactory) ValidatorContext(jakarta.validation.ValidatorContext) MessageInterpolatorImpl(org.glassfish.hk2.utilities.general.internal.MessageInterpolatorImpl)

Aggregations

ValidatorContext (jakarta.validation.ValidatorContext)1 ValidatorFactory (jakarta.validation.ValidatorFactory)1 MessageInterpolatorImpl (org.glassfish.hk2.utilities.general.internal.MessageInterpolatorImpl)1 HibernateValidator (org.hibernate.validator.HibernateValidator)1