Package javax.validation

Examples of javax.validation.ValidatorFactory.usingContext()


    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;
View Full Code Here


            }
        });
        try {
            Thread.currentThread().setContextClassLoader(Validation.class.getClassLoader());
            ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
            ValidatorContext validatorContext = validatorFactory.usingContext();
            validatorContext.messageInterpolator(new MessageInterpolatorImpl());
            beanValidator = validatorContext.getValidator();
        } finally {
            Thread.currentThread().setContextClassLoader(cl);
        }
View Full Code Here

  }

  public void usingContext() {
    ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();

    Validator validator = validatorFactory.usingContext()
        .messageInterpolator( new MyMessageInterpolator() )
        .traversableResolver(
            new MyTraversableResolver()
        )
        .getValidator();
View Full Code Here

            }
        });
        try {
            Thread.currentThread().setContextClassLoader(Validation.class.getClassLoader());
            ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
            ValidatorContext validatorContext = validatorFactory.usingContext();
            validatorContext.messageInterpolator(new MessageInterpolatorImpl());
            beanValidator = validatorContext.getValidator();
        } finally {
            Thread.currentThread().setContextClassLoader(cl);
        }
View Full Code Here

  @Override
  public void validate(Object target, Errors errors) {
    if (validator == null) {
      ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
      validator = validatorFactory.usingContext().getValidator();
    }

    Set<ConstraintViolation<Object>> constraintViolations = validator.validate(target);
    for (ConstraintViolation<Object> constraintViolation : constraintViolations) {
      String propertyPath = constraintViolation.getPropertyPath().toString();
View Full Code Here

  }

  @Override
  public void afterPropertiesSet() {
    ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
    validator = validatorFactory.usingContext().getValidator();
  }

}
View Full Code Here

            }
        });
        try {
            Thread.currentThread().setContextClassLoader(null);
            ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
            ValidatorContext validatorContext = validatorFactory.usingContext();
            validatorContext.messageInterpolator(new MessageInterpolatorImpl());
            beanValidator = validatorContext.getValidator();
        } finally {
            Thread.currentThread().setContextClassLoader(cl);
        }
View Full Code Here

                    try {
                        containerSystemContext.bind(VALIDATOR_FACTORY_NAMING_CONTEXT + id, factory);

                        Validator validator = null;
                        try {
                            validator = factory.usingContext().getValidator();
                        } catch (Exception e) {
                            validator = (Validator) Proxy.newProxyInstance(appContext.getClassLoader(), new Class<?>[]{ Validator.class }, new LazyValidator(factory));
                        }

                        containerSystemContext.bind(VALIDATOR_NAMING_CONTEXT + id, validator);
View Full Code Here

                throw new FacesException("Could not build a default Bean Validator factory", e);
            }
            context.getExternalContext().getApplicationMap().put(VALIDATOR_FACTORY_KEY, validatorFactory);
        }

        ValidatorContext validatorContext = validatorFactory.usingContext();
        MessageInterpolator jsfMessageInterpolator =
                new JsfAwareMessageInterpolator(context,
                           validatorFactory.getMessageInterpolator());
        validatorContext.messageInterpolator(jsfMessageInterpolator);
        javax.validation.Validator beanValidator = validatorContext.getValidator();
View Full Code Here

            }
        });
        try {
            Thread.currentThread().setContextClassLoader(Validation.class.getClassLoader());
            ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
            ValidatorContext validatorContext = validatorFactory.usingContext();
            validatorContext.messageInterpolator(new MessageInterpolatorImpl());
            beanValidator = validatorContext.getValidator();
        } finally {
            Thread.currentThread().setContextClassLoader(cl);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.