Support for Hibernate Validator 5.2

Issue: SPR-12758
This commit is contained in:
Juergen Hoeller
2015-02-26 18:33:53 +01:00
parent 626748d718
commit 09fde31732
2 changed files with 51 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -222,6 +222,17 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter
Validation.byProvider(this.providerClass).configure() :
Validation.byDefaultProvider().configure());
// Try Hibernate Validator 5.2's externalClassLoader(ClassLoader) method
if (this.applicationContext != null) {
try {
Method eclMethod = configuration.getClass().getMethod("externalClassLoader", ClassLoader.class);
ReflectionUtils.invokeMethod(eclMethod, configuration, this.applicationContext.getClassLoader());
}
catch (NoSuchMethodException ex) {
// Ignore - no Hibernate Validator 5.2+ or similar provider
}
}
MessageInterpolator targetInterpolator = this.messageInterpolator;
if (targetInterpolator == null) {
targetInterpolator = configuration.getDefaultMessageInterpolator();