下面列出了org.hibernate.validator.spi.resourceloading.ResourceBundleLocator#org.jboss.resteasy.spi.validation.GeneralValidator 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public GeneralValidator getContext(final Class<?> type) {
final ResourceBundleLocator resourceBundleLocator = new PlatformResourceBundleLocator("messages");
final MessageInterpolator messageInterpolator = new ResourceBundleMessageInterpolator(resourceBundleLocator);
final Configuration<?> config = Validation.byDefaultProvider().configure()
.messageInterpolator(messageInterpolator);
final BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
final boolean isExecutableValidationEnabled = bootstrapConfiguration.isExecutableValidationEnabled();
final Set<ExecutableType> defaultValidatedExecutableTypes = bootstrapConfiguration
.getDefaultValidatedExecutableTypes();
return new GeneralValidatorImpl(validatorFactory, isExecutableValidationEnabled,
defaultValidatedExecutableTypes);
}
/**
* 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());
}
KrazoGeneralValidator(GeneralValidator delegate) {
this.delegate = delegate;
}
OzarkGeneralValidator(GeneralValidator delegate) {
this.delegate = delegate;
}
public GeneralValidator getContext(Class<?> aClass) {
// get the real RESTEasy validator
GeneralValidator wrapped = new ValidatorContextResolver().getContext(aClass);
// only delegate to wrapped validator for regular JAX-RS requests
return new KrazoGeneralValidator(wrapped);
}
public GeneralValidator getContext(Class<?> aClass) {
// get the real RESTEasy validator
GeneralValidator wrapped = new ValidatorContextResolver().getContext(aClass);
// only delegate to wrapped validator for regular JAX-RS requests
return new OzarkGeneralValidator(wrapped);
}