[hibernate-commits] Hibernate SVN: r19738 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Jun 15 06:29:41 EDT 2010


Author: hardy.ferentschik
Date: 2010-06-15 06:29:41 -0400 (Tue, 15 Jun 2010)
New Revision: 19738

Modified:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/ResourceBundleMessageInterpolator.java
Log:
HV-332 REmoved the default usage of the caching resource bundle locator. If you want to use bundle caching you have to wrap your bundle locator manually.

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/ResourceBundleMessageInterpolator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/ResourceBundleMessageInterpolator.java	2010-06-15 10:26:04 UTC (rev 19737)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/messageinterpolation/ResourceBundleMessageInterpolator.java	2010-06-15 10:29:41 UTC (rev 19738)
@@ -26,7 +26,6 @@
 import java.util.regex.Pattern;
 import javax.validation.MessageInterpolator;
 
-import org.hibernate.validator.resourceloading.CachingResourceBundleLocator;
 import org.hibernate.validator.resourceloading.PlatformResourceBundleLocator;
 import org.hibernate.validator.resourceloading.ResourceBundleLocator;
 
@@ -52,7 +51,7 @@
 	/**
 	 * Regular expression used to do message interpolation.
 	 */
-	private static final Pattern messageParameterPattern = Pattern.compile( "(\\{[^\\}]+?\\})" );
+	private static final Pattern MESSAGE_PARAMETER_PATTERN = Pattern.compile( "(\\{[^\\}]+?\\})" );
 
 	/**
 	 * The default locale for the current user.
@@ -108,21 +107,13 @@
 		defaultLocale = Locale.getDefault();
 
 		if ( userResourceBundleLocator == null ) {
-			this.userResourceBundleLocator = new CachingResourceBundleLocator(
-					new PlatformResourceBundleLocator(
-							USER_VALIDATION_MESSAGES
-					)
-			);
+			this.userResourceBundleLocator = new PlatformResourceBundleLocator( USER_VALIDATION_MESSAGES );
 		}
 		else {
-			this.userResourceBundleLocator = new CachingResourceBundleLocator( userResourceBundleLocator );
+			this.userResourceBundleLocator = userResourceBundleLocator;
 		}
 
-		this.defaultResourceBundleLocator =
-				new CachingResourceBundleLocator(
-						new PlatformResourceBundleLocator( DEFAULT_VALIDATION_MESSAGES )
-				);
-
+		this.defaultResourceBundleLocator = new PlatformResourceBundleLocator( DEFAULT_VALIDATION_MESSAGES );
 		this.cacheMessages = cacheMessages;
 	}
 
@@ -204,7 +195,7 @@
 	}
 
 	private String replaceVariables(String message, ResourceBundle bundle, Locale locale, boolean recurse) {
-		Matcher matcher = messageParameterPattern.matcher( message );
+		Matcher matcher = MESSAGE_PARAMETER_PATTERN.matcher( message );
 		StringBuffer sb = new StringBuffer();
 		String resolvedParameterValue;
 		while ( matcher.find() ) {
@@ -220,7 +211,7 @@
 	}
 
 	private String replaceAnnotationAttributes(String message, Map<String, Object> annotationParameters) {
-		Matcher matcher = messageParameterPattern.matcher( message );
+		Matcher matcher = MESSAGE_PARAMETER_PATTERN.matcher( message );
 		StringBuffer sb = new StringBuffer();
 		while ( matcher.find() ) {
 			String resolvedParameterValue;



More information about the hibernate-commits mailing list