removed unnecessary logging

This commit is contained in:
Juergen Hoeller 2009-12-09 14:59:44 +00:00
parent 74022861c5
commit 8b0a4921d9
2 changed files with 24 additions and 31 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2009 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -86,11 +86,10 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
* without attempts to check further codes. * without attempts to check further codes.
* <p>To be able to work with "useCodeAsDefaultMessage" turned on in the parent, * <p>To be able to work with "useCodeAsDefaultMessage" turned on in the parent,
* AbstractMessageSource and AbstractApplicationContext contain special checks * AbstractMessageSource and AbstractApplicationContext contain special checks
* to delegate to the internal <code>getMessageInternal</code> method if available. * to delegate to the internal {@link #getMessageInternal} method if available.
* In general, it is recommended to just use "useCodeAsDefaultMessage" during * In general, it is recommended to just use "useCodeAsDefaultMessage" during
* development and not rely on it in production in the first place, though. * development and not rely on it in production in the first place, though.
* @see #getMessage(String, Object[], Locale) * @see #getMessage(String, Object[], Locale)
* @see #getMessageInternal
* @see org.springframework.validation.FieldError * @see org.springframework.validation.FieldError
*/ */
public void setUseCodeAsDefaultMessage(boolean useCodeAsDefaultMessage) { public void setUseCodeAsDefaultMessage(boolean useCodeAsDefaultMessage) {
@ -101,7 +100,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
* Return whether to use the message code as default message instead of * Return whether to use the message code as default message instead of
* throwing a NoSuchMessageException. Useful for development and debugging. * throwing a NoSuchMessageException. Useful for development and debugging.
* Default is "false". * Default is "false".
* <p>Alternatively, consider overriding the <code>getDefaultMessage</code> * <p>Alternatively, consider overriding the {@link #getDefaultMessage}
* method to return a custom fallback message for an unresolvable code. * method to return a custom fallback message for an unresolvable code.
* @see #getDefaultMessage(String) * @see #getDefaultMessage(String)
*/ */
@ -242,10 +241,9 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
/** /**
* Return a fallback default message for the given code, if any. * Return a fallback default message for the given code, if any.
* <p>Default is to return the code itself if "useCodeAsDefaultMessage" * <p>Default is to return the code itself if "useCodeAsDefaultMessage" is activated,
* is activated, or return no fallback else. In case of no fallback, * or return no fallback else. In case of no fallback, the caller will usually
* the caller will usually receive a NoSuchMessageException from * receive a NoSuchMessageException from <code>getMessage</code>.
* <code>getMessage</code>.
* @param code the message code that we couldn't resolve * @param code the message code that we couldn't resolve
* and that we didn't receive an explicit default message for * and that we didn't receive an explicit default message for
* @return the default message to use, or <code>null</code> if none * @return the default message to use, or <code>null</code> if none
@ -259,10 +257,10 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
} }
/** /**
* Render the given default message String. The default message is * Render the given default message String. The default message is passed in
* passed in as specified by the caller and can be rendered into * as specified by the caller and can be rendered into a fully formatted
* a fully formatted default message shown to the user. * default message shown to the user.
* <p>The default implementation passes the String to <code>formatMessage</code>, * <p>The default implementation passes the String to {@link #formatMessage},
* resolving any argument placeholders found in them. Subclasses may override * resolving any argument placeholders found in them. Subclasses may override
* this method to plug in custom processing of default messages. * this method to plug in custom processing of default messages.
* @param defaultMessage the passed-in default message String * @param defaultMessage the passed-in default message String
@ -279,8 +277,8 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
/** /**
* Searches through the given array of objects, find any * Searches through the given array of objects, finds any MessageSourceResolvable
* MessageSourceResolvable objects and resolve them. * objects and resolves them.
* <p>Allows for messages to have MessageSourceResolvables as arguments. * <p>Allows for messages to have MessageSourceResolvables as arguments.
* @param args array of arguments for a message * @param args array of arguments for a message
* @param locale the locale to resolve through * @param locale the locale to resolve through
@ -304,17 +302,15 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
} }
/** /**
* Subclasses can override this method to resolve a message without * Subclasses can override this method to resolve a message without arguments
* arguments in an optimized fashion, that is, to resolve a message * in an optimized fashion, i.e. to resolve without involving a MessageFormat.
* without involving a MessageFormat. * <p>The default implementation <i>does</i> use MessageFormat, through
* <p>The default implementation <i>does</i> use MessageFormat, * delegating to the {@link #resolveCode} method. Subclasses are encouraged
* through delegating to the <code>resolveCode</code> method. * to replace this with optimized resolution.
* Subclasses are encouraged to replace this with optimized resolution. * <p>Unfortunately, <code>java.text.MessageFormat</code> is not implemented
* <p>Unfortunately, <code>java.text.MessageFormat</code> is not * in an efficient fashion. In particular, it does not detect that a message
* implemented in an efficient fashion. In particular, it does not * pattern doesn't contain argument placeholders in the first place. Therefore,
* detect that a message pattern doesn't contain argument placeholders * it is advisable to circumvent MessageFormat for messages without arguments.
* in the first place. Therefore, it's advisable to circumvent
* MessageFormat completely for messages without arguments.
* @param code the code of the message to resolve * @param code the code of the message to resolve
* @param locale the Locale to resolve the code for * @param locale the Locale to resolve the code for
* (subclasses are encouraged to support internationalization) * (subclasses are encouraged to support internationalization)
@ -338,7 +334,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
* to allow for appropriate caching of MessageFormats in subclasses. * to allow for appropriate caching of MessageFormats in subclasses.
* <p><b>Subclasses are encouraged to provide optimized resolution * <p><b>Subclasses are encouraged to provide optimized resolution
* for messages without arguments, not involving MessageFormat.</b> * for messages without arguments, not involving MessageFormat.</b>
* See <code>resolveCodeWithoutArguments</code> javadoc for details. * See the {@link #resolveCodeWithoutArguments} javadoc for details.
* @param code the code of the message to resolve * @param code the code of the message to resolve
* @param locale the Locale to resolve the code for * @param locale the Locale to resolve the code for
* (subclasses are encouraged to support internationalization) * (subclasses are encouraged to support internationalization)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2009 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -92,7 +92,7 @@ public abstract class MessageSourceSupport {
if (msg == null || (!this.alwaysUseMessageFormat && (args == null || args.length == 0))) { if (msg == null || (!this.alwaysUseMessageFormat && (args == null || args.length == 0))) {
return msg; return msg;
} }
MessageFormat messageFormat = null; MessageFormat messageFormat;
synchronized (this.cachedMessageFormats) { synchronized (this.cachedMessageFormats) {
messageFormat = this.cachedMessageFormats.get(msg); messageFormat = this.cachedMessageFormats.get(msg);
if (messageFormat == null) { if (messageFormat == null) {
@ -112,9 +112,6 @@ public abstract class MessageSourceSupport {
* @return the MessageFormat instance * @return the MessageFormat instance
*/ */
protected MessageFormat createMessageFormat(String msg, Locale locale) { protected MessageFormat createMessageFormat(String msg, Locale locale) {
if (logger.isDebugEnabled()) {
logger.debug("Creating MessageFormat for pattern [" + msg + "] and locale '" + locale + "'");
}
return new MessageFormat((msg != null ? msg : ""), locale); return new MessageFormat((msg != null ? msg : ""), locale);
} }