Author: niallp
Date: Tue Nov 22 20:56:51 2005
New Revision: 348371
URL: http://svn.apache.org/viewcvs?rev=348371&view=rev
Log:
Change Log variables from static to instance and make transient
Modified:
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/JDBCResources.java
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/PropertyResources.java
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/ResourceBundleResources.java
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappPropertyResources.java
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappXMLResources.java
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/XMLResources.java
Modified:
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java?rev=348371&r1=348370&r2=348371&view=diff
==============================================================================
---
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
(original)
+++
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
Tue Nov 22 20:56:51 2005
@@ -47,11 +47,6 @@
* returned.</p>
*/
public class Messages implements Serializable {
-
- /**
- * Commons Logging instance.
- */
- private static final Log log = LogFactory.getLog(Messages.class);
// ----------------------------------------------------------- Constructors
@@ -240,7 +235,10 @@
try {
message = resources.getString(key, locale, null);
} catch (ResourcesException e) {
- log.debug("Failed retrieving message for key: '" + key + "'.", e);
+ Log log = LogFactory.getLog(Messages.class);
+ if (log.isDebugEnabled()) {
+ log.debug("Failed retrieving message for key: '" + key + "'.",
e);
+ }
}
if (message == null && !resources.isReturnNull()) {
Modified:
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/JDBCResources.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/JDBCResources.java?rev=348371&r1=348370&r2=348371&view=diff
==============================================================================
---
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/JDBCResources.java
(original)
+++
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/JDBCResources.java
Tue Nov 22 20:56:51 2005
@@ -83,7 +83,7 @@
/**
* <p>The <code>Log</code> instance for this class.</p>
*/
- private static final Log log = LogFactory.getLog(JDBCResources.class);
+ private transient Log log = LogFactory.getLog(JDBCResources.class);
private Connection con = null;
@@ -130,8 +130,8 @@
*/
protected Map getLocaleMap(String baseUrl, Locale locale) {
- if (log.isDebugEnabled()) {
- log.debug("Loading database configuration'" + locale + "'
resources from base '" +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Loading database configuration'" + locale + "'
resources from base '" +
baseUrl + "'");
}
@@ -143,30 +143,30 @@
try {
// Open an input stream to the URL for this locale (if any)
- if (log.isTraceEnabled()) {
- log.trace("Absolute URL is '" + name + "'");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Absolute URL is '" + name + "'");
}
URL url = new URL(name);
stream = url.openStream();
// Parse the input stream and populate the name-value mappings map
- if (log.isTraceEnabled()) {
- log.trace("Parsing input resource");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Parsing input resource");
}
props.load(stream);
} catch (FileNotFoundException e) {
// Log and swallow this exception
- if (log.isDebugEnabled()) {
- log.debug("No resources for locale '" + locale +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("No resources for locale '" + locale +
"' from base '" + baseUrl + "'");
}
props.clear();
} catch (IOException e) {
- log.warn("IOException loading locale '" + locale +
+ getLog().warn("IOException loading locale '" + locale +
"' from base '" + baseUrl + "'", e);
props.clear();
@@ -177,7 +177,7 @@
try {
stream.close();
} catch (IOException e) {
- log.error("Error closing stream.", e);
+ getLog().error("Error closing stream.", e);
}
stream = null;
}
@@ -190,17 +190,17 @@
properties = loadData(locale, props);
} catch (InstantiationException e) {
- log.warn("InstantiationException: locale= '" + locale +
+ getLog().warn("InstantiationException: locale= '" + locale +
"' base= '" + baseUrl + "'", e);
} catch (IllegalAccessException e) {
- log.warn("IllegalAccessException: locale= '" + locale +
+ getLog().warn("IllegalAccessException: locale= '" + locale +
"' base= '" + baseUrl + "'", e);
} catch (ClassNotFoundException e) {
- log.warn("Specified Driver not found, make sure it is on " +
+ getLog().warn("Specified Driver not found, make sure it is on " +
"the classpath: locale= '" + locale +
"' base= '" + baseUrl + "'", e);
} catch (SQLException e) {
- log.warn("SQLException: locale= '" + locale +
+ getLog().warn("SQLException: locale= '" + locale +
"' base= '" + baseUrl + "'", e);
}
return properties;
@@ -251,5 +251,22 @@
*/
public void init() throws ResourcesException {
super.init();
+ }
+
+ /**
+ * Accessor method for Log instance.
+ *
+ * The Log instance variable is transient and
+ * accessing it through this method ensures it
+ * is re-initialized when this instance is
+ * de-serialized.
+ *
+ * @return The Log instance.
+ */
+ private Log getLog() {
+ if (log == null) {
+ log = LogFactory.getLog(JDBCResources.class);
+ }
+ return log;
}
}
Modified:
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/PropertyResources.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/PropertyResources.java?rev=348371&r1=348370&r2=348371&view=diff
==============================================================================
---
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/PropertyResources.java
(original)
+++
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/PropertyResources.java
Tue Nov 22 20:56:51 2005
@@ -57,7 +57,7 @@
/**
* <p>The <code>Log</code> instance for this class.</p>
*/
- private static final Log log = LogFactory.getLog(PropertyResources.class);
+ private transient Log log = LogFactory.getLog(PropertyResources.class);
// ----------------------------------------------------------- Constructors
@@ -103,8 +103,8 @@
*/
protected Map getLocaleMap(String baseUrl, Locale locale) {
- if (log.isDebugEnabled()) {
- log.debug("Loading locale '" + locale + "' resources from base '" +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Loading locale '" + locale + "' resources from
base '" +
baseUrl + "'");
}
@@ -115,30 +115,30 @@
try {
// Open an input stream to the URL for this locale (if any)
- if (log.isTraceEnabled()) {
- log.trace("Absolute URL is '" + name + "'");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Absolute URL is '" + name + "'");
}
URL url = new URL(name);
stream = url.openStream();
// Parse the input stream and populate the name-value mappings map
- if (log.isTraceEnabled()) {
- log.trace("Parsing input resource");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Parsing input resource");
}
props.load(stream);
} catch (FileNotFoundException e) {
// Log and swallow this exception
- if (log.isDebugEnabled()) {
- log.debug("No resources for locale '" + locale +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("No resources for locale '" + locale +
"' from base '" + baseUrl + "'");
}
props.clear();
} catch (IOException e) {
- log.warn("IOException loading locale '" + locale +
+ getLog().warn("IOException loading locale '" + locale +
"' from base '" + baseUrl + "'", e);
props.clear();
@@ -149,7 +149,7 @@
try {
stream.close();
} catch (IOException e) {
- log.error("Error closing stream.", e);
+ getLog().error("Error closing stream.", e);
}
stream = null;
}
@@ -161,5 +161,22 @@
}
+
+ /**
+ * Accessor method for Log instance.
+ *
+ * The Log instance variable is transient and
+ * accessing it through this method ensures it
+ * is re-initialized when this instance is
+ * de-serialized.
+ *
+ * @return The Log instance.
+ */
+ private Log getLog() {
+ if (log == null) {
+ log = LogFactory.getLog(PropertyResources.class);
+ }
+ return log;
+ }
}
Modified:
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/ResourceBundleResources.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/ResourceBundleResources.java?rev=348371&r1=348370&r2=348371&view=diff
==============================================================================
---
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/ResourceBundleResources.java
(original)
+++
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/ResourceBundleResources.java
Tue Nov 22 20:56:51 2005
@@ -54,7 +54,7 @@
/**
* <p>The logging instance for this class.</p>
*/
- private static final Log log =
+ private transient Log log =
LogFactory.getLog(ResourceBundleResources.class);
// ----------------------------------------------------------- Constructors
@@ -110,8 +110,8 @@
*/
public void init() throws ResourcesException {
- if (log.isDebugEnabled()) {
- log.debug("Initializing for base name '" + base + "'");
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Initializing for base name '" + base + "'");
}
}
@@ -127,8 +127,8 @@
*/
public void destroy() throws ResourcesException {
- if (log.isDebugEnabled()) {
- log.debug("Finalizing for base name '" + base + "'");
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Finalizing for base name '" + base + "'");
}
synchronized (bundles) {
@@ -325,16 +325,16 @@
*/
public String getString(String key, Locale locale, TimeZone timeZone) {
- if (log.isTraceEnabled()) {
- log.trace("Retrieving message for key '" + key + "' for locale '"
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Retrieving message for key '" + key + "' for
locale '"
+ locale + "'");
}
try {
ResourceBundle bundle = getBundle(locale, timeZone);
String message = bundle.getString(key);
- if (log.isTraceEnabled()) {
- log.trace("Retrieved message is '" + message + "'");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Retrieved message is '" + message + "'");
}
return (message);
@@ -342,8 +342,8 @@
throw new ResourcesException(e);
} catch (MissingResourceException e) {
- if (log.isTraceEnabled()) {
- log.trace("No message found");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("No message found");
}
if (isReturnNull()) {
return (null);
@@ -426,5 +426,21 @@
}
+ /**
+ * Accessor method for Log instance.
+ *
+ * The Log instance variable is transient and
+ * accessing it through this method ensures it
+ * is re-initialized when this instance is
+ * de-serialized.
+ *
+ * @return The Log instance.
+ */
+ private Log getLog() {
+ if (log == null) {
+ log = LogFactory.getLog(ResourceBundleResources.class);
+ }
+ return log;
+ }
}
Modified:
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappPropertyResources.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappPropertyResources.java?rev=348371&r1=348370&r2=348371&view=diff
==============================================================================
---
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappPropertyResources.java
(original)
+++
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappPropertyResources.java
Tue Nov 22 20:56:51 2005
@@ -58,7 +58,7 @@
/**
* <p>The <code>Log</code> instance for this class.</p>
*/
- private static final Log log =
+ private transient Log log =
LogFactory.getLog(WebappPropertyResources.class);
// ----------------------------------------------------------- Constructors
@@ -121,8 +121,8 @@
*/
protected Map getLocaleMap(String baseUrl, Locale locale) {
- if (log.isDebugEnabled()) {
- log.debug("Loading locale '" + locale + "' resources from base '" +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Loading locale '" + locale + "' resources from
base '" +
baseUrl + "'");
}
@@ -135,8 +135,8 @@
try {
// Open an input stream to the URL for this locale (if any)
- if (log.isTraceEnabled()) {
- log.trace("Complete path is '" + name + "'");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Complete path is '" + name + "'");
}
try{
stream = servletContext.getResourceAsStream(name);
@@ -156,8 +156,8 @@
// Parse the input stream and populate the name-value mappings map
if (stream != null) {
- if (log.isTraceEnabled()) {
- log.trace("Parsing input resource");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Parsing input resource");
}
props.load(stream);
}
@@ -165,15 +165,15 @@
} catch (FileNotFoundException e) {
// Log and swallow this exception
- if (log.isDebugEnabled()) {
- log.debug("No resources for locale '" + locale +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("No resources for locale '" + locale +
"' from base '" + baseUrl + "'");
}
props.clear();
} catch (IOException e) {
- log.warn("IOException loading locale '" + locale +
+ getLog().warn("IOException loading locale '" + locale +
"' from base '" + baseUrl + "'", e);
props.clear();
@@ -184,7 +184,7 @@
try {
stream.close();
} catch (IOException e) {
- log.error("Error closing stream.", e);
+ getLog().error("Error closing stream.", e);
}
stream = null;
}
@@ -196,5 +196,21 @@
}
+ /**
+ * Accessor method for Log instance.
+ *
+ * The Log instance variable is transient and
+ * accessing it through this method ensures it
+ * is re-initialized when this instance is
+ * de-serialized.
+ *
+ * @return The Log instance.
+ */
+ private Log getLog() {
+ if (log == null) {
+ log = LogFactory.getLog(WebappPropertyResources.class);
+ }
+ return log;
+ }
}
Modified:
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappXMLResources.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappXMLResources.java?rev=348371&r1=348370&r2=348371&view=diff
==============================================================================
---
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappXMLResources.java
(original)
+++
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/WebappXMLResources.java
Tue Nov 22 20:56:51 2005
@@ -61,7 +61,7 @@
/**
* <p>The <code>Log</code> instance for this class.</p>
*/
- private static final Log log = LogFactory.getLog(WebappXMLResources.class);
+ private transient Log log = LogFactory.getLog(WebappXMLResources.class);
/**
* <p>Create a new [EMAIL PROTECTED]
org.apache.commons.resources.Resources} instance with the specified
@@ -119,8 +119,8 @@
*/
protected Map getLocaleMap(String baseUrl, Locale locale) {
- if (log.isDebugEnabled()) {
- log.debug("Loading locale '" + locale + "' resources from base '" +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Loading locale '" + locale + "' resources from
base '" +
baseUrl + "'");
}
@@ -131,16 +131,16 @@
try {
// Open an input stream to the URL for this locale (if any)
- if (log.isTraceEnabled()) {
- log.trace("Complete path is '" + name + "'");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Complete path is '" + name + "'");
}
stream = servletContext.getResourceAsStream(name);
// Create and configure a new Digester instance
if (stream != null) {
- if (log.isTraceEnabled()) {
- log.trace("Creating Digester instance");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Creating Digester instance");
}
Digester digester = new Digester();
digester.setNamespaceAware(false);
@@ -153,8 +153,8 @@
digester.addCallParam("resources/resource", 1);
// Parse the input stream and populate the name-value mappings
- if (log.isTraceEnabled()) {
- log.trace("Parsing input resource");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Parsing input resource");
}
digester.parse(stream);
@@ -163,8 +163,8 @@
} catch (FileNotFoundException e) {
// Log and swallow this exception
- if (log.isDebugEnabled()) {
- log.debug("No resources for locale '" + locale +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("No resources for locale '" + locale +
"' from base '" + baseUrl + "'");
}
map.clear();
@@ -172,14 +172,14 @@
} catch (IOException e) {
// Log and swallow this exception
- log.warn("IOException loading locale '" + locale +
+ getLog().warn("IOException loading locale '" + locale +
"' from base '" + baseUrl + "'", e);
map.clear();
} catch (SAXException e) {
// Log and swallow this exception
- log.warn("SAXException loading locale '" + locale +
+ getLog().warn("SAXException loading locale '" + locale +
"' from base '" + baseUrl + "'", e);
map.clear();
@@ -203,5 +203,21 @@
}
+ /**
+ * Accessor method for Log instance.
+ *
+ * The Log instance variable is transient and
+ * accessing it through this method ensures it
+ * is re-initialized when this instance is
+ * de-serialized.
+ *
+ * @return The Log instance.
+ */
+ private Log getLog() {
+ if (log == null) {
+ log = LogFactory.getLog(WebappXMLResources.class);
+ }
+ return log;
+ }
}
Modified:
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/XMLResources.java
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/XMLResources.java?rev=348371&r1=348370&r2=348371&view=diff
==============================================================================
---
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/XMLResources.java
(original)
+++
jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/XMLResources.java
Tue Nov 22 20:56:51 2005
@@ -69,7 +69,7 @@
/**
* <p>The <code>Log</code> instance for this class.</p>
*/
- private static final Log log = LogFactory.getLog(XMLResources.class);
+ private transient Log log = LogFactory.getLog(XMLResources.class);
// ----------------------------------------------------------- Constructors
@@ -115,8 +115,8 @@
*/
protected Map getLocaleMap(String baseUrl, Locale locale) {
- if (log.isDebugEnabled()) {
- log.debug("Loading locale '" + locale + "' resources from base '" +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Loading locale '" + locale + "' resources from
base '" +
baseUrl + "'");
}
@@ -127,15 +127,15 @@
try {
// Open an input stream to the URL for this locale (if any)
- if (log.isTraceEnabled()) {
- log.trace("Absolute URL is '" + name + "'");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Absolute URL is '" + name + "'");
}
URL url = new URL(name);
stream = url.openStream();
// Create and configure a new Digester instance
- if (log.isTraceEnabled()) {
- log.trace("Creating Digester instance");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Creating Digester instance");
}
Digester digester = new Digester();
digester.setNamespaceAware(false);
@@ -148,16 +148,16 @@
digester.addCallParam("resources/resource", 1);
// Parse the input stream and populate the name-value mappings map
- if (log.isTraceEnabled()) {
- log.trace("Parsing input resource");
+ if (getLog().isTraceEnabled()) {
+ getLog().trace("Parsing input resource");
}
digester.parse(stream);
} catch (FileNotFoundException e) {
// Log and swallow this exception
- if (log.isDebugEnabled()) {
- log.debug("No resources for locale '" + locale +
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("No resources for locale '" + locale +
"' from base '" + baseUrl + "'");
}
map.clear();
@@ -165,14 +165,14 @@
} catch (IOException e) {
// Log and swallow this exception
- log.warn("IOException loading locale '" + locale +
+ getLog().warn("IOException loading locale '" + locale +
"' from base '" + baseUrl + "'", e);
map.clear();
} catch (SAXException e) {
// Log and swallow this exception
- log.warn("SAXException loading locale '" + locale +
+ getLog().warn("SAXException loading locale '" + locale +
"' from base '" + baseUrl + "'", e);
map.clear();
@@ -183,7 +183,7 @@
try {
stream.close();
} catch (IOException e) {
- log.error("Error closing stream.", e);
+ getLog().error("Error closing stream.", e);
}
stream = null;
}
@@ -195,5 +195,21 @@
}
+ /**
+ * Accessor method for Log instance.
+ *
+ * The Log instance variable is transient and
+ * accessing it through this method ensures it
+ * is re-initialized when this instance is
+ * de-serialized.
+ *
+ * @return The Log instance.
+ */
+ private Log getLog() {
+ if (log == null) {
+ log = LogFactory.getLog(XMLResources.class);
+ }
+ return log;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]