本文整理汇总了Java中javax.validation.Configuration.buildValidatorFactory方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.buildValidatorFactory方法的具体用法?Java Configuration.buildValidatorFactory怎么用?Java Configuration.buildValidatorFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.validation.Configuration
的用法示例。
在下文中一共展示了Configuration.buildValidatorFactory方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildValidator
import javax.validation.Configuration; //导入方法依赖的package包/类
private static Validator buildValidator ()
{
final GenericBootstrap bootstrap = Validation.byDefaultProvider ();
bootstrap.providerResolver ( tracker );
final Configuration<?> cfg = bootstrap.configure ();
final OsgiMessageInterpolator mi = getMessageInterpolator ();
mi.setFallback ( cfg.getDefaultMessageInterpolator () );
cfg.messageInterpolator ( mi );
final ValidatorFactory factory = cfg.buildValidatorFactory ();
return factory.getValidator ();
}
示例2: createValidatorFactory
import javax.validation.Configuration; //导入方法依赖的package包/类
/**
* Create a validator factory
* @return The factory
*/
static ValidatorFactory createValidatorFactory()
{
Configuration configuration = Validation.byDefaultProvider().configure();
Configuration<?> conf = configuration.traversableResolver(new IronJacamarTraversableResolver());
return conf.buildValidatorFactory();
}
示例3: getContext
import javax.validation.Configuration; //导入方法依赖的package包/类
/**
* Get a context of type {@code GeneralValidator} that is applicable to the supplied type.
*
* @param type the class of object for which a context is desired
* @return a context for the supplied type or {@code null} if a context for the supplied type is not available from
* this provider.
*/
@Override
public GeneralValidator getContext(Class<?> type) {
Configuration<?> config = Validation.byDefaultProvider().configure();
BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
config.messageInterpolator(new LocaleSpecificMessageInterpolator(Validation.byDefaultProvider().configure()
.getDefaultMessageInterpolator()));
config.parameterNameProvider(new CustomParameterNameProvider());
return new GeneralValidatorImpl(config.buildValidatorFactory(),
bootstrapConfiguration.isExecutableValidationEnabled(),
bootstrapConfiguration.getDefaultValidatedExecutableTypes());
}
开发者ID:samaxes,项目名称:jaxrs-beanvalidation-javaee7,代码行数:21,代码来源:ValidationConfigurationContextResolver.java
示例4: buildFactory
import javax.validation.Configuration; //导入方法依赖的package包/类
public static ValidatorFactory buildFactory(final ValidationInfo config, final ClassLoader classLoader) {
ValidatorFactory factory = null;
final Thread thread = Thread.currentThread();
final ClassLoader oldContextLoader = thread.getContextClassLoader();
try {
thread.setContextClassLoader(classLoader);
if (config == null) {
factory = Validation.buildDefaultValidatorFactory();
} else {
final Configuration<?> configuration = getConfig(config);
try {
factory = configuration.buildValidatorFactory();
} catch (final ValidationException ve) {
thread.setContextClassLoader(ValidatorBuilder.class.getClassLoader());
factory = Validation.buildDefaultValidatorFactory();
thread.setContextClassLoader(classLoader);
logger.warning("Unable create validator factory with config " + config
+ " (" + ve.getMessage() + ")."
+ " Default factory will be used.");
}
}
} finally {
thread.setContextClassLoader(oldContextLoader);
}
return factory;
}
示例5: DefaultValidationContext
import javax.validation.Configuration; //导入方法依赖的package包/类
private DefaultValidationContext() {
Configuration<?> validationConfig = Validation.byDefaultProvider().configure();
if (new DefaultSejdaContext().isIgnoreXmlConfiguration()) {
validationConfig.ignoreXmlConfiguration();
}
ValidatorFactory factory = validationConfig.buildValidatorFactory();
validator = factory.getValidator();
}
示例6: ValidationExtension
import javax.validation.Configuration; //导入方法依赖的package包/类
/**
* Creates a ValidationExtension
*
* @param m the Morphia instance to use
*/
public ValidationExtension(final Morphia m) {
final Configuration<?> configuration = Validation.byDefaultProvider().configure();
validationFactory = configuration.buildValidatorFactory();
m.getMapper().addInterceptor(this);
}
示例7: afterPropertiesSet
import javax.validation.Configuration; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() {
@SuppressWarnings({"rawtypes", "unchecked"})
Configuration<?> configuration = (this.providerClass != null ?
Validation.byProvider(this.providerClass).configure() :
Validation.byDefaultProvider().configure());
MessageInterpolator targetInterpolator = this.messageInterpolator;
if (targetInterpolator == null) {
targetInterpolator = configuration.getDefaultMessageInterpolator();
}
configuration.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));
if (this.traversableResolver != null) {
configuration.traversableResolver(this.traversableResolver);
}
ConstraintValidatorFactory targetConstraintValidatorFactory = this.constraintValidatorFactory;
if (targetConstraintValidatorFactory == null && this.applicationContext != null) {
targetConstraintValidatorFactory =
new SpringConstraintValidatorFactory(this.applicationContext.getAutowireCapableBeanFactory());
}
if (targetConstraintValidatorFactory != null) {
configuration.constraintValidatorFactory(targetConstraintValidatorFactory);
}
if (this.parameterNameDiscoverer != null) {
configureParameterNameProviderIfPossible(configuration);
}
if (this.mappingLocations != null) {
for (Resource location : this.mappingLocations) {
try {
configuration.addMapping(location.getInputStream());
}
catch (IOException ex) {
throw new IllegalStateException("Cannot read mapping resource: " + location);
}
}
}
for (Map.Entry<String, String> entry : this.validationPropertyMap.entrySet()) {
configuration.addProperty(entry.getKey(), entry.getValue());
}
// Allow for custom post-processing before we actually build the ValidatorFactory.
postProcessConfiguration(configuration);
this.validatorFactory = configuration.buildValidatorFactory();
setTargetValidator(this.validatorFactory.getValidator());
}
示例8: buildValidatorFactory
import javax.validation.Configuration; //导入方法依赖的package包/类
public static ValidatorFactory buildValidatorFactory(boolean osgi,
ValidationProviderResolver validationProviderResolver,
MessageInterpolator messageInterpolator,
TraversableResolver traversableResolver,
ConstraintValidatorFactory constraintValidatorFactory) {
ValidationProviderResolver resolvedValidationProviderResolver =
resolveValidationProviderResolver(osgi, validationProviderResolver);
GenericBootstrap bootstrap = Validation.byDefaultProvider();
if (resolvedValidationProviderResolver != null) {
bootstrap.providerResolver(resolvedValidationProviderResolver);
}
Configuration<?> configuration = bootstrap.configure();
if (messageInterpolator != null) {
configuration.messageInterpolator(messageInterpolator);
}
if (traversableResolver != null) {
configuration.traversableResolver(traversableResolver);
}
if (constraintValidatorFactory != null) {
configuration.constraintValidatorFactory(constraintValidatorFactory);
}
return configuration.buildValidatorFactory();
}
示例9: buildValidatorFactory
import javax.validation.Configuration; //导入方法依赖的package包/类
protected ValidatorFactory buildValidatorFactory(VaConfigSetupper hibernateConfigSetupper) {
final Configuration<?> configuration = createConfiguration();
setupFrameworkConfiguration(configuration);
setupYourConfiguration(configuration, hibernateConfigSetupper);
return configuration.buildValidatorFactory();
}
示例10: afterPropertiesSet
import javax.validation.Configuration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void afterPropertiesSet() {
@SuppressWarnings("rawtypes")
Configuration configuration = (this.providerClass != null ?
Validation.byProvider(this.providerClass).configure() :
Validation.byDefaultProvider().configure());
MessageInterpolator targetInterpolator = this.messageInterpolator;
if (targetInterpolator == null) {
targetInterpolator = configuration.getDefaultMessageInterpolator();
}
configuration.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));
if (this.traversableResolver != null) {
configuration.traversableResolver(this.traversableResolver);
}
ConstraintValidatorFactory targetConstraintValidatorFactory = this.constraintValidatorFactory;
if (targetConstraintValidatorFactory == null && this.applicationContext != null) {
targetConstraintValidatorFactory =
new SpringConstraintValidatorFactory(this.applicationContext.getAutowireCapableBeanFactory());
}
if (targetConstraintValidatorFactory != null) {
configuration.constraintValidatorFactory(targetConstraintValidatorFactory);
}
if (this.mappingLocations != null) {
for (Resource location : this.mappingLocations) {
try {
configuration.addMapping(location.getInputStream());
}
catch (IOException ex) {
throw new IllegalStateException("Cannot read mapping resource: " + location);
}
}
}
for (Map.Entry<String, String> entry : this.validationPropertyMap.entrySet()) {
configuration.addProperty(entry.getKey(), entry.getValue());
}
// Allow for custom post-processing before we actually build the ValidatorFactory.
postProcessConfiguration(configuration);
this.validatorFactory = configuration.buildValidatorFactory();
setTargetValidator(this.validatorFactory.getValidator());
}
示例11: ValidatorHolder
import javax.validation.Configuration; //导入方法依赖的package包/类
private ValidatorHolder() {
Configuration<?> validationConfig = Validation.byDefaultProvider().configure();
validationConfig.ignoreXmlConfiguration();
ValidatorFactory factory = validationConfig.buildValidatorFactory();
validator = factory.getValidator();
}