/** * create hibernate validation configuration * * @return */ protected HibernateValidatorConfiguration createConfiguration() { HibernateValidatorConfiguration configuration = null; if (this.isIgnoreClassHierarchy()) { ValidationProviderResolver resolver = new ValidationProviderResolver() { /** * (non-Javadoc) * * @see javax.validation.ValidationProviderResolver#getValidationProviders() */ @Override public List<ValidationProvider<?>> getValidationProviders() { List<ValidationProvider<?>> providers = new ArrayList<ValidationProvider<?>>(1); providers.add(new HibernateValidator513()); return providers; } }; configuration = Validation.byProvider(HibernateValidator513.class).providerResolver(resolver).configure(); } else { configuration = Validation.byProvider(HibernateValidator.class).configure(); } configuration.messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator( MESSAGES))); return configuration; }
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(); }
@Override public ValidationProviderResolver getDefaultValidationProviderResolver() { if (this.defaultResolver == null) { this.defaultResolver = GWT.create(ValidationProviderResolver.class); } return this.defaultResolver; }
public ValidationProviderResolver getValidationProviderResolver() { return validationProviderResolver; }
/** * To use a a custom {@link ValidationProviderResolver} */ public void setValidationProviderResolver(ValidationProviderResolver validationProviderResolver) { this.validationProviderResolver = validationProviderResolver; }
@Override public ValidationProviderResolver getValidationProviderResolver() { return this.getDefaultValidationProviderResolver(); }
/** * Unsupported. Always throws an {@link UnsupportedOperationException}. * * @throws UnsupportedOperationException not supported */ @Override public GenericBootstrap providerResolver(final ValidationProviderResolver resolver) { throw new UnsupportedOperationException( "GWT Validation does not support custom validator " + "provider resolvers"); }
/** * Resolves optional custom {@code javax.validation.ValidationProviderResolver} to be used by the component. By * default component tries to use resolver instance bound to the Camel registry under name * {@code validationProviderResolver} . If there is no such resolver instance in the registry and component is * running in the OSGi environment, {@link HibernateValidationProviderResolver} will be used. In all the other * cases this method will return null. * * @param osgi specifies if validator factory should be OSGi-aware * @param validationProviderResolver predefined provider resolver. This parameter overrides the results of the * resolution. * @return {@code javax.validation.ValidationProviderResolver} instance or null if no custom resolver should * be used by the component */ private static ValidationProviderResolver resolveValidationProviderResolver( boolean osgi, ValidationProviderResolver validationProviderResolver) { if (validationProviderResolver != null) { return validationProviderResolver; } if (osgi) { return new HibernateValidationProviderResolver(); } return null; }
/** * Specify a JSR-303 {@link ValidationProviderResolver} for bootstrapping the * provider of choice, as an alternative to {@code META-INF} driven resolution. * @since 4.3 */ public void setValidationProviderResolver(ValidationProviderResolver validationProviderResolver) { this.validationProviderResolver = validationProviderResolver; }