本文整理了Java中javax.validation.Configuration.constraintValidatorFactory()
方法的一些代码示例,展示了Configuration.constraintValidatorFactory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.constraintValidatorFactory()
方法的具体详情如下:
包路径:javax.validation.Configuration
类名称:Configuration
方法名:constraintValidatorFactory
[英]Defines the constraint validator factory. Has priority over the configuration based constraint factory.
If null is passed, the default constraint validator factory is used (defined in XML or the specification default).
[中]定义约束验证器工厂。优先于基于配置的约束工厂。
如果传递null,则使用默认约束验证器工厂(在XML或默认规范中定义)。
代码示例来源:origin: spring-projects/spring-framework
configuration.constraintValidatorFactory(targetConstraintValidatorFactory);
代码示例来源:origin: org.springframework/spring-context
configuration.constraintValidatorFactory(targetConstraintValidatorFactory);
代码示例来源:origin: org.graniteds/granite-client-java-advanced
@SuppressWarnings("unchecked")
@Override
public T constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory) {
configuration = configuration.constraintValidatorFactory(constraintValidatorFactory);
return (T)this;
}
代码示例来源:origin: org.apache.tomee/openejb-core
@Override
public T constraintValidatorFactory(final ConstraintValidatorFactory constraintValidatorFactory) {
return delegate.constraintValidatorFactory(constraintValidatorFactory);
}
代码示例来源: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() {
instance = Validation.byDefaultProvider().configure()
.constraintValidatorFactory(constraintValidatorFactory).buildValidatorFactory();
logger.debug("Initializing Bean Validation (1.1 supported)");
}
代码示例来源:origin: org.hibernate.jsr303.tck/jsr303-tck
@SpecAssertion(section = "2.5", id = "c")
@Test(expectedExceptions = ValidationException.class)
public void testValidationExceptionIsThrownInCaseFactoryReturnsNull() {
Configuration<?> config = TestUtil.getConfigurationUnderTest().constraintValidatorFactory(
new ConstraintValidatorFactory() {
public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T> key) {
return null;
}
}
);
Validator validator = config.buildValidatorFactory().getValidator();
validator.validate( new SecondDummy() );
}
代码示例来源:origin: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
@Test(expectedExceptions = ValidationException.class)
@SpecAssertion(section = Sections.CONSTRAINTSDEFINITIONIMPLEMENTATION_CONSTRAINTFACTORY, id = "d")
public void testValidationExceptionIsThrownInCaseFactoryReturnsNull() {
Configuration<?> config = TestUtil.getConfigurationUnderTest().constraintValidatorFactory(
new CustomConstraintValidatorFactory()
);
Validator validator = config.buildValidatorFactory().getValidator();
validator.validate( new SecondDummy() );
}
代码示例来源: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: 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
@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.typesafe.play/play-java-forms_2.11
@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.typesafe.play/play-java-forms_2.11
@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: 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: org.hibernate.beanvalidation.tck/beanvalidation-tck-tests
@Test
@SpecAssertion(section = Sections.VALIDATIONAPI_BOOTSTRAPPING_VALIDATORFACTORY, id = "d")
public void testGetConstraintValidatorFactoryFromValidatorFactory() {
CustomConstraintValidatorFactory constraintValidatorFactory = new CustomConstraintValidatorFactory();
ValidatorFactory validatorFactory = TestUtil.getConfigurationUnderTest()
.constraintValidatorFactory( constraintValidatorFactory )
.buildValidatorFactory();
assertSame(
validatorFactory.getConstraintValidatorFactory(),
constraintValidatorFactory,
"getConstraintValidatorFactory() should return the parameter name provider set via configuration"
);
}
代码示例来源: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: apache/deltaspike
@Before
public void initValidator()
{
this.validator = Validation.byDefaultProvider().configure()
.constraintValidatorFactory(new CDIAwareConstraintValidatorFactory())
.buildValidatorFactory().getValidator();
}
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!