use of javax.validation.ValidatorFactory in project kie-wb-common by kiegroup.
the class SequenceFlowPriorityTest method init.
@Before
public void init() {
ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
this.validator = vf.getValidator();
}
use of javax.validation.ValidatorFactory in project kie-wb-common by kiegroup.
the class StartNoneEventTest method init.
@Before
public void init() {
ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
this.validator = vf.getValidator();
}
use of javax.validation.ValidatorFactory 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;
}
use of javax.validation.ValidatorFactory in project Payara by payara.
the class WebContainerListener method containerEvent.
public void containerEvent(ContainerEvent event) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.CONTAINER_EVENT, event.getType() + "," + event.getContainer() + "," + event.getData());
}
String type = event.getType();
try {
WebModule wm = (WebModule) event.getContainer();
if (beforeEvents.contains(type)) {
preInvoke(wm);
if (type.equals(ContainerEvent.BEFORE_CONTEXT_DESTROYED)) {
try {
// must close the validator factory
if (validationNamingProxy != null) {
Object validatorFactory = validationNamingProxy.handle("java:comp/ValidatorFactory");
if (validatorFactory != null) {
((ValidatorFactory) validatorFactory).close();
}
}
} catch (NamingException exc) {
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.FINEST, LogFacade.EXCEPTION_GETTING_VALIDATOR_FACTORY, exc);
}
}
}
} else if (afterEvents.contains(type)) {
if (type.equals(ContainerEvent.AFTER_FILTER_DESTROYED) || type.equals(ContainerEvent.AFTER_CONTEXT_DESTROYED)) {
preDestroy(event);
}
postInvoke(wm);
} else if (ContainerEvent.PRE_DESTROY.equals(type)) {
preInvoke(wm);
preDestroy(event);
postInvoke(wm);
}
} catch (Throwable t) {
String msg = rb.getString(LogFacade.EXCEPTION_DURING_HANDLE_EVENT);
msg = MessageFormat.format(msg, new Object[] { type, event.getContainer() });
_logger.log(Level.SEVERE, msg, t);
}
}
use of javax.validation.ValidatorFactory in project tomee by apache.
the class AppComposerAsJUnitRuleTest method lookupValidatorFactory.
@Test
public void lookupValidatorFactory() throws Exception {
final ValidatorFactory validatorFactory = (ValidatorFactory) new InitialContext().lookup("java:comp/ValidatorFactory");
assertNotNull(validatorFactory);
}
Aggregations