Author: hardy.ferentschik
Date: 2009-08-19 06:20:42 -0400 (Wed, 19 Aug 2009)
New Revision: 17357
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
Log:
made sure that if xml configuration is ignored the right default values are used
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java 2009-08-19
10:20:17 UTC (rev 17356)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConfigurationImpl.java 2009-08-19
10:20:42 UTC (rev 17357)
@@ -34,10 +34,10 @@
import org.slf4j.Logger;
import org.hibernate.validation.engine.resolver.DefaultTraversableResolver;
+import org.hibernate.validation.util.LoggerFactory;
+import org.hibernate.validation.util.Version;
import org.hibernate.validation.xml.ValidationBootstrapParameters;
import org.hibernate.validation.xml.ValidationXmlParser;
-import org.hibernate.validation.util.LoggerFactory;
-import org.hibernate.validation.util.Version;
/**
* Hibernate specific <code>Configuration</code> implementation.
@@ -181,11 +181,21 @@
private void parseValidationXml() {
if ( ignoreXmlConfiguration ) {
log.info( "Ignoring XML configuration." );
- return;
+ // make sure we use the defaults in case they haven't been provided yet
+ if ( validationBootstrapParameters.messageInterpolator == null ) {
+ validationBootstrapParameters.messageInterpolator = defaultMessageInterpolator;
+ }
+ if ( validationBootstrapParameters.traversableResolver == null ) {
+ validationBootstrapParameters.traversableResolver = defaultTraversableResolver;
+ }
+ if ( validationBootstrapParameters.constraintValidatorFactory == null ) {
+ validationBootstrapParameters.constraintValidatorFactory = defaultValidatorFactory;
+ }
}
-
- ValidationBootstrapParameters xmlParameters = new
ValidationXmlParser().parseValidationXml();
- applyXmlSettings( xmlParameters );
+ else {
+ ValidationBootstrapParameters xmlParameters = new
ValidationXmlParser().parseValidationXml();
+ applyXmlSettings( xmlParameters );
+ }
}
private void applyXmlSettings(ValidationBootstrapParameters xmlParameters) {
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-19
10:20:17 UTC (rev 17356)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/xml/XmlMappingParser.java 2009-08-19
10:20:42 UTC (rev 17357)
@@ -225,7 +225,7 @@
for ( FieldType fieldType : fields ) {
String fieldName = fieldType.getName();
if ( fieldNames.contains( fieldName ) ) {
- throw new ValidationException( fieldName + "is defined twice in mapping
xml." );
+ throw new ValidationException( fieldName + " is defined twice in mapping xml for
bean " + beanClass.getName() );
}
else {
fieldNames.add( fieldName );
@@ -276,7 +276,7 @@
for ( GetterType getterType : getters ) {
String getterName = getterType.getName();
if ( getterNames.contains( getterName ) ) {
- throw new ValidationException( getterName + "is defined twice in mapping
xml." );
+ throw new ValidationException( getterName + " is defined twice in mapping xml
for bean " + beanClass.getName() );
}
else {
getterNames.add( getterName );
Show replies by date