[jboss-svn-commits] JBoss Portal SVN: r5495 - trunk/common/src/main/org/jboss/portal/common/util

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 23 14:47:48 EDT 2006


Author: chris.laprun at jboss.com
Date: 2006-10-23 14:47:47 -0400 (Mon, 23 Oct 2006)
New Revision: 5495

Modified:
   trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java
Log:
Added logging to LoaderResource.

Modified: trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java	2006-10-23 14:54:17 UTC (rev 5494)
+++ trunk/common/src/main/org/jboss/portal/common/util/LoaderResource.java	2006-10-23 18:47:47 UTC (rev 5495)
@@ -22,17 +22,18 @@
  ******************************************************************************/
 package org.jboss.portal.common.util;
 
+import org.jboss.logging.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.InputStream;
-import java.io.IOException;
-import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
 import java.util.Properties;
-import java.util.Iterator;
 
 /**
  * Represent a resource that may or not exist.
@@ -45,6 +46,8 @@
 
    protected final String location;
 
+   private final Logger log = Logger.getLogger(getClass());
+
    public LoaderResource(String location)
    {
       if (location == null)
@@ -105,6 +108,9 @@
          throw new IllegalStateException("Resource " + location + " does not exist");
       }
       InputStream in = null;
+
+      log.debug("Loading resource: " + location);
+
       try
       {
          in = Tools.safeBufferedWrapper(asInputStream());
@@ -114,7 +120,7 @@
             DocumentBuilder builder = XML.getDocumentBuilderFactory().newDocumentBuilder();
             Document doc = asDocument(builder);
             Element propertiesElt = doc.getDocumentElement();
-            for (Iterator i = XML.getChildren(propertiesElt, "entry").iterator();i.hasNext();)
+            for (Iterator i = XML.getChildren(propertiesElt, "entry").iterator(); i.hasNext();)
             {
                Element entryElt = (Element)i.next();
                String key = entryElt.getAttribute("key");
@@ -126,6 +132,7 @@
          {
             props.load(in);
          }
+         log.debug("Finished loading resource: " + location);
          return props;
       }
       catch (ParserConfigurationException e)
@@ -158,19 +165,26 @@
          throw new IllegalStateException("Resource " + location + " does not exist");
       }
       InputStream in = null;
+
+      log.debug("Loading resource: " + location);
+
       try
       {
          in = Tools.safeBufferedWrapper(asInputStream());
          ByteArrayOutputStream out = new ByteArrayOutputStream(in.available());
          Tools.copy(in, out);
+         String result;
          if (enc == null)
          {
-            return out.toString();
+            result = out.toString();
          }
          else
          {
-            return out.toString(enc);
+            result = out.toString(enc);
          }
+
+         log.debug("Finished loading resource: " + location);
+         return result;
       }
       catch (IOException e)
       {




More information about the jboss-svn-commits mailing list