Java源码示例:javax.validation.spi.ValidationProvider
示例1
/**
* 线程安全的
*
* @return {@link Validator}
*/
public static Validator getValidator ( Class< ? extends ValidationProvider > providerType ) {
return Validation.byProvider( providerType )
.configure()
.buildValidatorFactory()
.getValidator();
}
示例2
public <T extends Configuration<T>, U extends ValidationProvider<T>> BeanValidationProvider(
ValidationProviderResolver resolver,
Class<U> providerType,
ValidationConfiguration cfg) {
try {
Configuration<?> factoryCfg = providerType != null
? Validation.byProvider(providerType).providerResolver(resolver).configure()
: Validation.byDefaultProvider().providerResolver(resolver).configure();
initFactoryConfig(factoryCfg, cfg);
factory = factoryCfg.buildValidatorFactory();
} catch (final ValidationException ex) {
LOG.severe("Bean Validation provider can not be found, no validation will be performed");
throw ex;
}
}
示例3
public SingleValidationProviderResolver(ValidationProvider<?> provider) {
this.provider = provider;
}
示例4
@Override
public List<ValidationProvider<?>> getValidationProviders() {
return singletonList(provider);
}
示例5
public OsgiValidationProviderTracker ()
{
final BundleContext context = FrameworkUtil.getBundle ( OsgiValidationProviderTracker.class ).getBundleContext ();
this.tracker = new ServiceTracker<> ( context, ValidationProvider.class, null );
}
示例6
@Override
public List<ValidationProvider<?>> getValidationProviders ()
{
return new ArrayList<> ( this.tracker.getTracked ().values () );
}
示例7
public <T extends Configuration<T>, U extends ValidationProvider<T>> BeanValidationProvider(
ValidationProviderResolver resolver,
Class<U> providerType) {
this(resolver, providerType, null);
}
示例8
public NullConfig(final BootstrapState aState, final ValidationProvider<ApacheValidatorConfiguration> aProvider) {
super(aState, aProvider);
}
示例9
@Override
public List<ValidationProvider<?>> getValidationProviders() {
return ImmutableList.<ValidationProvider<?>>of(new HibernateValidator());
}