From: Juergen H. <jho...@us...> - 2006-04-21 00:14:22
|
Update of /cvsroot/springframework/spring/src/org/springframework/context/support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19629/src/org/springframework/context/support Modified Files: Tag: mbranch-1-2 AbstractMessageSource.java Log Message: backported fixes and enhancements from 2.0 M4 (HEAD) Index: AbstractMessageSource.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/context/support/AbstractMessageSource.java,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -C2 -d -r1.19 -r1.19.2.1 *** AbstractMessageSource.java 6 Nov 2005 16:02:23 -0000 1.19 --- AbstractMessageSource.java 21 Apr 2006 00:13:48 -0000 1.19.2.1 *************** *** 1,4 **** /* ! * Copyright 2002-2005 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,4 ---- /* ! * Copyright 2002-2006 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); *************** *** 68,71 **** --- 68,72 ---- public abstract class AbstractMessageSource implements HierarchicalMessageSource { + /** Logger available to subclasses */ protected final Log logger = LogFactory.getLog(getClass()); *************** *** 226,229 **** --- 227,231 ---- locale = Locale.getDefault(); } + Object[] argsToUse = args; if (!isAlwaysUseMessageFormat() && ObjectUtils.isEmpty(args)) { *************** *** 237,245 **** } } else { MessageFormat messageFormat = resolveCode(code, locale); if (messageFormat != null) { synchronized (messageFormat) { ! return messageFormat.format(resolveArguments(args, locale)); } } --- 239,253 ---- } } + else { + // Resolve arguments eagerly, for the case where the message + // is defined in a parent MessageSource but resolvable arguments + // are defined in the child MessageSource. + argsToUse = resolveArguments(args, locale); + MessageFormat messageFormat = resolveCode(code, locale); if (messageFormat != null) { synchronized (messageFormat) { ! return messageFormat.format(argsToUse); } } *************** *** 247,251 **** // Not found -> check parent, if any. ! return getMessageFromParent(code, args, locale); } --- 255,259 ---- // Not found -> check parent, if any. ! return getMessageFromParent(code, argsToUse, locale); } *************** *** 388,392 **** /** * Subclasses can override this method to resolve a message without ! * arguments in an optimized fashion, i.e. to resolve a message * without involving a MessageFormat. * <p>The default implementation <i>does</i> use MessageFormat, --- 396,400 ---- /** * Subclasses can override this method to resolve a message without ! * arguments in an optimized fashion, that is, to resolve a message * without involving a MessageFormat. * <p>The default implementation <i>does</i> use MessageFormat, |