use of javax.validation.Configuration in project Payara by payara.
the class BVIntegrationTestServlet method configureValidation.
private Validator configureValidation(HttpServletRequest req, HttpServletResponse resp) throws IOException {
PrintWriter out = resp.getWriter();
GenericBootstrap bootstrap = Validation.byDefaultProvider();
Configuration config = bootstrap.configure();
InputStream mappingsXml = new ByteArrayInputStream(validationXml.getBytes());
config.addMapping(mappingsXml);
ValidatorFactory factory = config.buildValidatorFactory();
ValidatorContext validatorContext = factory.usingContext();
Validator validator = validatorContext.getValidator();
if (validator == null) {
factory = Validation.byDefaultProvider().configure().buildValidatorFactory();
validator = factory.getValidator();
}
out.print("<p>");
out.print("Obtained ValidatorFactory: " + factory + ".");
out.print("</p>");
return validator;
}
Aggregations