use of javax.validation.ValidatorFactory in project Payara by payara.
the class ValidationNamingProxy method handle.
@Override
public Object handle(String name) throws NamingException {
// delegate to the java:comp/BeanManager handler to obtain the appropriate BeanManager
BeanManager beanManager = obtainBeanManager();
if (beanManager == null) {
// There is no bean manager available, return and let BeanValidatorNamingProxy handle lookup..
return null;
}
if (VALIDATOR_FACTORY_CONTEXT.equals(name)) {
try {
ValidatorFactory validatorFactory = (ValidatorFactory) getAndCreateBean(beanManager, ValidatorFactory.class);
if (validatorFactory != null) {
return validatorFactory;
} else {
throw new NamingException("Error retrieving " + name);
}
} catch (Throwable t) {
NamingException ne = new NamingException("Error retrieving " + name);
ne.initCause(t);
throw ne;
}
} else if (VALIDATOR_CONTEXT.equals(name)) {
try {
Validator validator = (Validator) getAndCreateBean(beanManager, Validator.class);
if (validator != null) {
return validator;
} else {
throw new NamingException("Error retrieving " + name);
}
} catch (Throwable t) {
NamingException ne = new NamingException("Error retrieving " + name);
ne.initCause(t);
throw ne;
}
} else {
throw new NamingException("wrong handler for " + name);
}
}
use of javax.validation.ValidatorFactory in project Payara by payara.
the class BeanValidatorNamingProxy method getValidator.
private Validator getValidator() throws NamingException {
if (null == validator) {
try {
ValidatorFactory factory = getValidatorFactory();
ValidatorContext validatorContext = factory.usingContext();
validator = validatorContext.getValidator();
} catch (Throwable t) {
NamingException ne = new NamingException("Error retrieving Validator for " + nameForValidator + " lookup");
ne.initCause(t);
throw ne;
}
}
return validator;
}
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);
}
use of javax.validation.ValidatorFactory in project tomee by apache.
the class AppComposerAsJUnitRuleTest method injectionValidatorFactory.
@Test
public void injectionValidatorFactory() {
final ValidatorFactory validatorFactory = persistManager.getValidatorFactory();
assertNotNull(validatorFactory);
}
use of javax.validation.ValidatorFactory in project tomee by apache.
the class AppComposerAsJUnitRuleWithReusableModulesTest method injectionValidatorFactory.
@Test
public void injectionValidatorFactory() {
final ValidatorFactory validatorFactory = persistManager.getValidatorFactory();
assertNotNull(validatorFactory);
}
Aggregations