javax.validation.Configuration.messageInterpolator()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中javax.validation.Configuration.messageInterpolator()方法的一些代码示例,展示了Configuration.messageInterpolator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.messageInterpolator()方法的具体详情如下:
包路径:javax.validation.Configuration
类名称:Configuration
方法名:messageInterpolator

Configuration.messageInterpolator介绍

[英]Defines the message interpolator used. Has priority over the configuration based message interpolator.

If null is passed, the default message interpolator is used (defined in XML or the specification default).
[中]定义使用的消息插值器。优先于基于配置的消息插值器。
如果传递null,则使用默认消息插值器(在XML或默认规范中定义)。

代码示例

代码示例来源:origin: spring-projects/spring-framework

targetInterpolator = configuration.getDefaultMessageInterpolator();
configuration.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));

代码示例来源:origin: org.springframework/spring-context

targetInterpolator = configuration.getDefaultMessageInterpolator();
configuration.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));

代码示例来源:origin: com.atlassian.plugins.rest/atlassian-rest-common

public ValidationInterceptor(MessageInterpolator messageInterpolator) {
  // Yes, this cast is unnecessary in Java 6, but seems to be required in Java 5
  this.factory = ((Configuration) Validation.byDefaultProvider().configure().messageInterpolator(messageInterpolator)).buildValidatorFactory();
}

代码示例来源:origin: org.graniteds/granite-client-java-advanced

@SuppressWarnings("unchecked")
@Override
public T messageInterpolator(MessageInterpolator interpolator) {
  configuration = configuration.messageInterpolator(interpolator);
  return (T)this;
}

代码示例来源:origin: hibernate/hibernate-validator

@Override
public ValidatorFactory create(CreationalContext<ValidatorFactory> ctx) {
  Configuration<?> config = getConfiguration();
  config.constraintValidatorFactory( createConstraintValidatorFactory( config ) );
  config.messageInterpolator( createMessageInterpolator( config ) );
  config.traversableResolver( createTraversableResolver( config ) );
  config.parameterNameProvider( createParameterNameProvider( config ) );
  config.clockProvider( createClockProvider( config ) );
  addValueExtractorBeans( config );
  return config.buildValidatorFactory();
}

代码示例来源:origin: caelum/vraptor

@PostConstruct
public void buildFactory() {
  factory = Validation.byDefaultProvider()
    .configure()
    .messageInterpolator(interpolator)
    .buildValidatorFactory();
logger.debug("Initializing Bean Validation (1.0 supported)");
}

代码示例来源:origin: apache/tapestry-5

@Override
  public void configure(javax.validation.Configuration<?> configuration)
  {
    MessageInterpolator defaultInterpolator = configuration.getDefaultMessageInterpolator();
    configuration.messageInterpolator(new MessageInterpolatorImpl(defaultInterpolator, threadLocale));
  }
});

代码示例来源:origin: org.hibernate.jsr303.tck/jsr303-tck

@Test
@SpecAssertion(section = "4.3.2", id = "b")
public void testCustomMessageInterpolatorViaConfiguration() {
  Configuration config = Validation.byDefaultProvider().configure();
  config = config.messageInterpolator( new DummyMessageInterpolator() );
  Validator validator = config.buildValidatorFactory().getValidator();
  assertCustomMessageInterpolatorUsed( validator );
}

代码示例来源:origin: com.pojosontheweb/woko-hibernate

@Override
public void init(Configuration configuration) throws Exception {
  javax.validation.Configuration config = Validation.byDefaultProvider().configure();
  MessageInterpolator mi = new ClientLocaleMessageInterpolator(config.getDefaultMessageInterpolator());
  config = config.messageInterpolator( mi );
  VALIDATOR = config.buildValidatorFactory().getValidator();
}

代码示例来源:origin: com.typesafe.play/play-java-forms

@Inject
public ValidatorFactoryProvider(ConstraintValidatorFactory constraintValidatorFactory, final ApplicationLifecycle lifecycle) {
  this.validatorFactory = Validation.byDefaultProvider().configure()
      .constraintValidatorFactory(constraintValidatorFactory)
      .messageInterpolator(new ParameterMessageInterpolator())
      .buildValidatorFactory();
  lifecycle.addStopHook(() -> {
    this.validatorFactory.close();
    return CompletableFuture.completedFuture(null);
  });
}

代码示例来源:origin: com.nablarch.framework/nablarch-core-validation-ee

/**
 * デフォルトの{@link ValidatorFactoryBuilder}インスタンスを生成する。
 * @return インスタンス
 */
private static ValidatorFactory createDefaultValidatorFactory() {
  return Validation.byDefaultProvider()
           .configure()
           .messageInterpolator(new MultiLanguageMessageInterpolator())
           .buildValidatorFactory();
}

代码示例来源:origin: apache/cxf

private static void initFactoryConfig(Configuration<?> factoryCfg, ValidationConfiguration cfg) {
  if (cfg != null) {
    factoryCfg.parameterNameProvider(cfg.getParameterNameProvider());
    factoryCfg.messageInterpolator(cfg.getMessageInterpolator());
    factoryCfg.traversableResolver(cfg.getTraversableResolver());
    factoryCfg.constraintValidatorFactory(cfg.getConstraintValidatorFactory());
    for (Map.Entry<String, String> entry : cfg.getProperties().entrySet()) {
      factoryCfg.addProperty(entry.getKey(), entry.getValue());
    }
  }
}

代码示例来源:origin: com.typesafe.play/play-java-forms

@Inject
public ValidatorProvider(ConstraintValidatorFactory constraintValidatorFactory, final ApplicationLifecycle lifecycle) {
  this.validatorFactory = Validation.byDefaultProvider().configure()
      .constraintValidatorFactory(constraintValidatorFactory)
      .messageInterpolator(new ParameterMessageInterpolator())
      .buildValidatorFactory();
  lifecycle.addStopHook(() -> {
    this.validatorFactory.close();
    return CompletableFuture.completedFuture(null);
  });
}

代码示例来源:origin: com.typesafe.play/play-java-forms_2.12

@Inject
public ValidatorProvider(ConstraintValidatorFactory constraintValidatorFactory, final ApplicationLifecycle lifecycle) {
  this.validatorFactory = Validation.byDefaultProvider().configure()
      .constraintValidatorFactory(constraintValidatorFactory)
      .messageInterpolator(new ParameterMessageInterpolator())
      .buildValidatorFactory();
  lifecycle.addStopHook(() -> {
    this.validatorFactory.close();
    return CompletableFuture.completedFuture(null);
  });
}

代码示例来源:origin: com.typesafe.play/play-java-forms_2.12

@Inject
public ValidatorFactoryProvider(ConstraintValidatorFactory constraintValidatorFactory, final ApplicationLifecycle lifecycle) {
  this.validatorFactory = Validation.byDefaultProvider().configure()
      .constraintValidatorFactory(constraintValidatorFactory)
      .messageInterpolator(new ParameterMessageInterpolator())
      .buildValidatorFactory();
  lifecycle.addStopHook(() -> {
    this.validatorFactory.close();
    return CompletableFuture.completedFuture(null);
  });
}

代码示例来源:origin: org.apache.cxf/cxf-core

private static void initFactoryConfig(Configuration<?> factoryCfg, ValidationConfiguration cfg) {
  if (cfg != null) {
    factoryCfg.parameterNameProvider(cfg.getParameterNameProvider());
    factoryCfg.messageInterpolator(cfg.getMessageInterpolator());
    factoryCfg.traversableResolver(cfg.getTraversableResolver());
    factoryCfg.constraintValidatorFactory(cfg.getConstraintValidatorFactory());
    for (Map.Entry<String, String> entry : cfg.getProperties().entrySet()) {
      factoryCfg.addProperty(entry.getKey(), entry.getValue());
    }
  }
}

代码示例来源:origin: actframework/actframework

private void init(App app) {
  config = Validation.byDefaultProvider().configure();
  config.messageInterpolator(new ActValidationMessageInterpolator(config.getDefaultMessageInterpolator(), app.config()));
  ensureFactoryValidator();
}

代码示例来源:origin: org.seedstack.seed/seed-core

private GlobalValidatorFactory() {
  validatorFactory = Validation.byDefaultProvider()
      .configure()
      .parameterNameProvider(new ReflectionParameterNameProvider())
      .messageInterpolator(new SeedMessageInterpolator())
      .buildValidatorFactory();
}

代码示例来源:origin: org.seedstack.seed/seed-core

@Override
  public ValidatorFactory get() {
    return Validation.byDefaultProvider()
        .configure()
        .parameterNameProvider(new ReflectionParameterNameProvider())
        .messageInterpolator(new SeedMessageInterpolator())
        .constraintValidatorFactory(new SeedConstraintValidatorFactory(injector))
        .buildValidatorFactory();
  }
}

代码示例来源:origin: org.hibernate.validator/hibernate-validator-cdi

@Override
public ValidatorFactory create(CreationalContext<ValidatorFactory> ctx) {
  Configuration<?> config = getConfiguration();
  config.constraintValidatorFactory( createConstraintValidatorFactory( config ) );
  config.messageInterpolator( createMessageInterpolator( config ) );
  config.traversableResolver( createTraversableResolver( config ) );
  config.parameterNameProvider( createParameterNameProvider( config ) );
  config.clockProvider( createClockProvider( config ) );
  addValueExtractorBeans( config );
  return config.buildValidatorFactory();
}

相关文章