本文整理了Java中javax.validation.Validation.byProvider()
方法的一些代码示例,展示了Validation.byProvider()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validation.byProvider()
方法的具体详情如下:
包路径:javax.validation.Validation
类名称:Validation
方法名:byProvider
[英]Builds a Configuration for a particular provider implementation.
Optionally overrides the provider resolution strategy used to determine the provider.
Used by applications targeting a specific provider programmatically.
ACMEConfiguration configuration =
Validation.byProvider(ACMEProvider.class)
.providerResolver( new MyResolverStrategy() )
.configure();
, where ACMEConfiguration is the Configuration sub interface uniquely identifying the ACME Bean Validation provider. and ACMEProvider is the ValidationProvider implementation of the ACME provider.
[中]为特定的提供程序实现构建配置。
可选地覆盖用于确定提供程序的提供程序解析策略。
由以编程方式针对特定提供程序的应用程序使用。
ACMEConfiguration configuration =
Validation.byProvider(ACMEProvider.class)
.providerResolver( new MyResolverStrategy() )
.configure();
,其中ACMEConfiguration是唯一标识ACME Bean验证提供者的配置子接口。ACMEProvider是ACME provider的ValidationProvider实现。
代码示例来源:origin: Netflix/conductor
@Provides
@Singleton
public HibernateValidatorConfiguration getConfiguration() {
return Validation.byProvider(HibernateValidator.class).configure();
}
代码示例来源:origin: apache/incubator-dubbo
@SuppressWarnings({"unchecked", "rawtypes"})
public JValidator(URL url) {
this.clazz = ReflectUtils.forName(url.getServiceInterface());
String jvalidation = url.getParameter("jvalidation");
ValidatorFactory factory;
if (jvalidation != null && jvalidation.length() > 0) {
factory = Validation.byProvider((Class) ReflectUtils.forName(jvalidation)).configure().buildValidatorFactory();
} else {
factory = Validation.buildDefaultValidatorFactory();
}
this.validator = factory.getValidator();
this.methodClassMap = new ConcurrentHashMap<String, Class>();
}
代码示例来源:origin: apache/incubator-dubbo
@SuppressWarnings({"unchecked", "rawtypes"})
public JValidator(URL url) {
this.clazz = ReflectUtils.forName(url.getServiceInterface());
String jvalidation = url.getParameter("jvalidation");
ValidatorFactory factory;
if (jvalidation != null && jvalidation.length() > 0) {
factory = Validation.byProvider((Class) ReflectUtils.forName(jvalidation)).configure().buildValidatorFactory();
} else {
factory = Validation.buildDefaultValidatorFactory();
}
this.validator = factory.getValidator();
this.methodClassMap = new ConcurrentHashMap<String, Class>();
}
代码示例来源:origin: linlinjava/litemall
@Bean
public Validator validator() {
ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class)
.configure()
.addProperty("hibernate.validator.fail_fast", "true")
.buildValidatorFactory();
Validator validator = validatorFactory.getValidator();
return validator;
}
}
代码示例来源:origin: jooby-project/jooby
@Override
public void configure(final Env env, final Config config, final Binder binder) {
HibernateValidatorConfiguration configuration = byProvider(HibernateValidator.class)
.configure();
if (config.hasPath("hibernate.validator")) {
config.getConfig("hibernate.validator").root().forEach((k, v) -> configuration.addProperty("hibernate.validator." + k, v.unwrapped().toString()));
}
if (configurer != null) {
configurer.accept(configuration, config);
}
binder.bind(HibernateValidatorConfiguration.class).toInstance(configuration);
binder.bind(Validator.class).toProvider(HbvFactory.class).asEagerSingleton();
env.lifeCycle(HbvFactory.class);
Multibinder.newSetBinder(binder, Parser.class).addBinding()
.toInstance(new HbvParser(predicate));
}
代码示例来源:origin: spotify/helios
protected static Environment createEnvironment(final String name) {
final Validator validator = Validation
.byProvider(HibernateValidator.class)
.configure()
.addValidatedValueHandler(new OptionalValidatedValueUnwrapper())
.buildValidatorFactory()
.getValidator();
return new Environment(name,
Jackson.newObjectMapper(),
validator,
new MetricRegistry(),
Thread.currentThread().getContextClassLoader());
}
代码示例来源:origin: embulk/embulk
@Inject
public ModelManager(Injector injector, ObjectMapper objectMapper) {
this.injector = injector;
this.objectMapper = objectMapper;
this.configObjectMapper = objectMapper.copy();
this.taskValidator = new TaskValidator(
Validation.byProvider(ApacheValidationProvider.class).configure().buildValidatorFactory().getValidator());
objectMapper.registerModule(new TaskSerDe.TaskSerializerModule(objectMapper));
objectMapper.registerModule(new TaskSerDe.TaskDeserializerModule(objectMapper, this));
objectMapper.registerModule(new DataSourceSerDe.SerDeModule(this));
configObjectMapper.registerModule(new TaskSerDe.TaskSerializerModule(configObjectMapper));
configObjectMapper.registerModule(new TaskSerDe.ConfigTaskDeserializerModule(configObjectMapper, this));
configObjectMapper.registerModule(new DataSourceSerDe.SerDeModule(this));
}
代码示例来源:origin: spring-projects/spring-framework
Configuration<?> configuration;
if (this.providerClass != null) {
ProviderSpecificBootstrap bootstrap = Validation.byProvider(this.providerClass);
if (this.validationProviderResolver != null) {
bootstrap = bootstrap.providerResolver(this.validationProviderResolver);
代码示例来源:origin: Netflix/conductor
@Before
public void init() {
ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
validator = vf.getValidator();
mockMetadataDao = Mockito.mock(MetadataDAO.class);
ValidationContext.initialize(mockMetadataDao);
config = Validation.byProvider(HibernateValidator.class).configure();
}
代码示例来源:origin: Netflix/conductor
@Before
public void init() {
ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
validator = vf.getValidator();
mockMetadataDao = Mockito.mock(MetadataDAO.class);
ValidationContext.initialize(mockMetadataDao);
config = Validation.byProvider(HibernateValidator.class).configure();
}
代码示例来源:origin: org.springframework/spring-context
Configuration<?> configuration;
if (this.providerClass != null) {
ProviderSpecificBootstrap bootstrap = Validation.byProvider(this.providerClass);
if (this.validationProviderResolver != null) {
bootstrap = bootstrap.providerResolver(this.validationProviderResolver);
代码示例来源:origin: dropwizard/dropwizard
/**
* Creates a new {@link HibernateValidatorConfiguration} with the base custom {@link
* org.hibernate.validator.spi.valuehandling.ValidatedValueUnwrapper} registered.
*/
public static HibernateValidatorConfiguration newConfiguration() {
return Validation
.byProvider(HibernateValidator.class)
.configure()
.addValidatedValueHandler(new GuavaOptionalValidatedValueUnwrapper())
.addValidatedValueHandler(new OptionalDoubleValidatedValueUnwrapper())
.addValidatedValueHandler(new OptionalIntValidatedValueUnwrapper())
.addValidatedValueHandler(new OptionalLongValidatedValueUnwrapper());
}
}
代码示例来源:origin: hibernate/hibernate-validator
private Configuration<?> getConfiguration() {
return validationProviderHelper.isDefaultProvider() ?
Validation.byDefaultProvider().configure() :
Validation.byProvider( org.hibernate.validator.HibernateValidator.class ).configure();
}
代码示例来源:origin: resteasy/Resteasy
ValidatorFactory getValidatorFactory()
{
ValidatorFactory tmpValidatorFactory = validatorFactory;
if (tmpValidatorFactory == null)
{
synchronized (RD_LOCK)
{
tmpValidatorFactory = validatorFactory;
if (tmpValidatorFactory == null)
{
try
{
// Also look up java:comp/env
Context context = new InitialContext();
validatorFactory = tmpValidatorFactory = ValidatorFactory.class.cast(context.lookup("java:comp/ValidatorFactory"));
LogMessages.LOGGER.debug(Messages.MESSAGES.usingValidatorFactorySupportsCDI(validatorFactory));
}
catch (NamingException e)
{
LogMessages.LOGGER.info(Messages.MESSAGES.usingValidatorFactoryDoesNotSupportCDI());
HibernateValidatorConfiguration config = Validation.byProvider(HibernateValidator.class).configure();
validatorFactory = tmpValidatorFactory = config.buildValidatorFactory();
}
}
}
}
return validatorFactory;
}
代码示例来源:origin: com.netflix.conductor/conductor-core
@Provides
@Singleton
public HibernateValidatorConfiguration getConfiguration() {
return Validation.byProvider(HibernateValidator.class).configure();
}
代码示例来源:origin: yujunhao8831/spring-boot-start-current
/**
* 线程安全的
*
* @return {@link Validator}
*/
public static Validator getValidator ( Class< ? extends ValidationProvider > providerType ) {
return Validation.byProvider( providerType )
.configure()
.buildValidatorFactory()
.getValidator();
}
代码示例来源:origin: restx/restx
@Provides @Named(VALIDATOR_NAME)
public Validator validator(@Named(IGNORE_XML_CONFIGURATION_NAME) Boolean ignoreXmlConfiguration) {
HibernateValidatorConfiguration config = Validation.byProvider(HibernateValidator.class).configure();
if(ignoreXmlConfiguration) {
config.ignoreXmlConfiguration();
}
return config.buildValidatorFactory().getValidator();
}
代码示例来源:origin: io.restx/restx-validation
@Provides @Named(VALIDATOR_NAME)
public Validator validator(@Named(IGNORE_XML_CONFIGURATION_NAME) Boolean ignoreXmlConfiguration) {
HibernateValidatorConfiguration config = Validation.byProvider(HibernateValidator.class).configure();
if(ignoreXmlConfiguration) {
config.ignoreXmlConfiguration();
}
return config.buildValidatorFactory().getValidator();
}
代码示例来源:origin: com.alibaba/dubbo
@SuppressWarnings({"unchecked", "rawtypes"})
public JValidator(URL url) {
this.clazz = ReflectUtils.forName(url.getServiceInterface());
String jvalidation = url.getParameter("jvalidation");
ValidatorFactory factory;
if (jvalidation != null && jvalidation.length() > 0) {
factory = Validation.byProvider((Class) ReflectUtils.forName(jvalidation)).configure().buildValidatorFactory();
} else {
factory = Validation.buildDefaultValidatorFactory();
}
this.validator = factory.getValidator();
}
代码示例来源:origin: dremio/dremio-oss
public InputValidation() {
HibernateValidatorConfiguration config = Validation.byProvider(HibernateValidator.class).configure();
this.validator = config
.addMapping(configureTransforms(config.createConstraintMapping()))
.buildValidatorFactory()
.getValidator();
}
内容来源于网络,如有侵权,请联系作者删除!