Java 类javax.validation.bootstrap.ProviderSpecificBootstrap 实例源码

项目:wisdom    文件:HibernateValidatorService.java   
/**
 * Initializes the validator, and registers it as an OSGi service (if the bundle context is set).
 *
 * @return the validator.
 */
@Validate
public Validator initialize() {
    // configure and build an instance of ValidatorFactory
    ProviderSpecificBootstrap<HibernateValidatorConfiguration> validationBootStrap = javax.validation.Validation
            .byProvider(HibernateValidator.class);

    // bootstrap to properly resolve in an OSGi environment
    validationBootStrap.providerResolver(new HibernateValidationProviderResolver());

    HibernateValidatorConfiguration configure = validationBootStrap.configure().messageInterpolator(interpolator);
    interpolator.setDefaultInterpolator(configure.getDefaultMessageInterpolator());

    // now that we've done configuring the ValidatorFactory, let's build it
    ValidatorFactory validatorFactory = configure.buildValidatorFactory();

    // retrieve a unique validator.
    Validator validator = validatorFactory.getValidator();

    // Register the validator.
    if (context != null) {
        registration = context.registerService(Validator.class, new WrappedValidator(validator), null);
        factoryRegistration = context.registerService(ValidatorFactory.class, validatorFactory, null);
    }

    return validator;
}
项目:gwt-bean-validators    文件:Validation.java   
/**
 * Unsupported. Always throws an {@link UnsupportedOperationException}.
 *
 * @param providerType
 *
 * @throws UnsupportedOperationException not supported
 */
public static <T extends Configuration<T>, U extends ValidationProvider<T>> //
    ProviderSpecificBootstrap<T> //
    byProvider(final Class<U> providerType) {
  throw new UnsupportedOperationException(
      "GWT Validation does not support custom validator " + "providers");
}