You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2002/06/28 03:08:39 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/util PropertyMessageResources.java
craigmcc 2002/06/27 18:08:39
Modified: src/share/org/apache/struts/util
PropertyMessageResources.java
Log:
Add some debug logging to make sure that the appropriate resource bundles
and message keys are actually getting loaded.
Revision Changes Path
1.4 +35 -4 jakarta-struts/src/share/org/apache/struts/util/PropertyMessageResources.java
Index: PropertyMessageResources.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/PropertyMessageResources.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PropertyMessageResources.java 12 Feb 2001 00:32:14 -0000 1.3
+++ PropertyMessageResources.java 28 Jun 2002 01:08:39 -0000 1.4
@@ -68,6 +68,8 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
@@ -105,6 +107,7 @@
String config) {
super(factory, config);
+ log.info("Initializing, config='" + config + "'");
}
@@ -121,6 +124,8 @@
String config, boolean returnNull) {
super(factory, config, returnNull);
+ log.info("Initializing, config='" + config +
+ "', returnNull=" + returnNull);
}
@@ -136,6 +141,13 @@
/**
+ * The <code>Log</code> instance for this class.
+ */
+ protected static final Log log =
+ LogFactory.getLog(PropertyMessageResources.class);
+
+
+ /**
* The cache of messages we have accumulated over time, keyed by the
* value calculated in <code>messageKey()</code>.
*/
@@ -160,6 +172,10 @@
*/
public String getMessage(Locale locale, String key) {
+ if (log.isDebugEnabled()) {
+ log.debug("getMessage(" + locale + "," + key + ")");
+ }
+
// Initialize variables we will require
String localeKey = localeKey(locale);
String originalKey = messageKey(localeKey, key);
@@ -247,6 +263,10 @@
*/
protected void loadLocale(String localeKey) {
+ if (log.isTraceEnabled()) {
+ log.trace("loadLocale(" + localeKey + ")");
+ }
+
// Have we already attempted to load messages for this locale?
synchronized (locales) {
if (locales.get(localeKey) != null)
@@ -264,12 +284,19 @@
// Load the specified property resource
try {
+ if (log.isTraceEnabled()) {
+ log.trace(" Loading resource '" + name + "'");
+ }
is = this.getClass().getClassLoader().getResourceAsStream(name);
if (is != null) {
props.load(is);
is.close();
}
+ if (log.isTraceEnabled()) {
+ log.trace(" Loading resource completed");
+ }
} catch (Throwable t) {
+ log.error("loadLocale()", t);
if (is != null) {
try {
is.close();
@@ -286,6 +313,10 @@
Enumeration names = props.keys();
while (names.hasMoreElements()) {
String key = (String) names.nextElement();
+ if (log.isTraceEnabled()) {
+ log.trace(" Saving message key '" +
+ messageKey(localeKey, key));
+ }
messages.put(messageKey(localeKey, key),
props.getProperty(key));
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>