Package javax.validation

Examples of javax.validation.ValidatorFactory.usingContext()


      @SpecAssertion(section = "4.3.2", id = "b")
  })
  public void testCustomMessageInterpolatorViaValidatorContext() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    DummyMessageInterpolator dummyMessageInterpolator = new DummyMessageInterpolator();
    Validator validator = factory.usingContext().messageInterpolator( dummyMessageInterpolator ).getValidator();
    assertCustomMessageInterpolatorUsed( validator );
    assertFalse(
        factory.getMessageInterpolator().equals( dummyMessageInterpolator ),
        "getMessageInterpolator() should return the default message interpolator."
    );
View Full Code Here


     */
    public Validator getValidator()
    {
        ValidatorFactory validatorFactory = this.validatorFactoryResolver.getValidatorFactory();

        return validatorFactory.usingContext()
                .constraintValidatorFactory(getConstraintValidatorFactory())
                .messageInterpolator(validatorFactory.getMessageInterpolator())
                .traversableResolver(validatorFactory.getTraversableResolver())
                .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

                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 {
                        containerSystemContext.bind(VALIDATOR_FACTORY_NAMING_CONTEXT + id, factory);

                        Validator validator;
                        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

      @SpecAssertion(section = "4.3.2", id = "b")
  })
  public void testCustomMessageInterpolatorViaValidatorContext() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    DummyMessageInterpolator dummyMessageInterpolator = new DummyMessageInterpolator();
    Validator validator = factory.usingContext().messageInterpolator( dummyMessageInterpolator ).getValidator();
    assertCustomMessageInterpolatorUsed( validator );
    assertFalse(
        factory.getMessageInterpolator().equals( dummyMessageInterpolator ),
        "getMessageInterpolator() should return the default message interpolator."
    );
View Full Code Here

      @SpecAssertion(section = "4.3.2", id = "b")
  })
  public void testCustomMessageInterpolatorViaValidatorContext() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    DummyMessageInterpolator dummyMessageInterpolator = new DummyMessageInterpolator();
    Validator validator = factory.usingContext().messageInterpolator( dummyMessageInterpolator ).getValidator();
    assertCustomMessageInterpolatorUsed( validator );
    assertFalse(
        factory.getMessageInterpolator().equals( dummyMessageInterpolator ),
        "getMessageInterpolator() should return the default message interpolator."
    );
View Full Code Here

  @Test
  @SpecAssertion(section = "4.3.2", id = "b")
  public void testCustomMessageInterpolatorViaConfiguration() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.usingContext()
        .messageInterpolator( new DummyMessageInterpolator() )
        .getValidator();

    assertCustomMessageInterpolatorUsed( validator );
  }
View Full Code Here

      @SpecAssertion(section = "4.3.2", id = "b")
  })
  public void testCustomMessageInterpolatorViaValidatorContext() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    DummyMessageInterpolator dummyMessageInterpolator = new DummyMessageInterpolator();
    Validator validator = factory.usingContext().messageInterpolator( dummyMessageInterpolator ).getValidator();
    assertCustomMessageInterpolatorUsed( validator );
    assertFalse(
        factory.getMessageInterpolator().equals( dummyMessageInterpolator ),
        "getMessageInterpolator() should return the default message interpolator."
    );
View Full Code Here

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

                        Validator validator;
                        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

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.