[dna-commits] DNA SVN: r456 - in trunk: dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml and 2 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed Aug 20 12:57:23 EDT 2008


Author: rhauch
Date: 2008-08-20 12:57:23 -0400 (Wed, 20 Aug 2008)
New Revision: 456

Modified:
   trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java
   trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
   trunk/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerContext.java
   trunk/extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java
Log:
DNA-209 - Change existing sequencers to use the ExecutionContext's logger
http://jira.jboss.com/jira/browse/DNA-209

Changed the SequencerNodeContext to expose the new "getLogger(...)" methods on the ExecutionContext (and JcrExecutionContext), and changed the sequencers that use a logger to get the logger using these methods.

Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java	2008-08-20 16:09:15 UTC (rev 455)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerNodeContext.java	2008-08-20 16:57:23 UTC (rev 456)
@@ -33,6 +33,7 @@
 import javax.jcr.Value;
 import net.jcip.annotations.Immutable;
 import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.repository.RepositoryI18n;
 import org.jboss.dna.repository.mimetype.MimeType;
 import org.jboss.dna.repository.util.JcrExecutionContext;
@@ -57,6 +58,7 @@
     private final ValueFactories factories;
     private final Path path;
     private final Set<Property> props;
+    private final JcrExecutionContext context;
 
     SequencerNodeContext( Node input,
                           javax.jcr.Property sequencedProperty,
@@ -64,6 +66,7 @@
         assert input != null;
         assert sequencedProperty != null;
         assert context != null;
+        this.context = context;
         this.sequencedProperty = sequencedProperty;
         this.factories = context.getValueFactories();
         // Translate JCR path and property values to DNA constructs and cache them to improve performance and prevent
@@ -207,4 +210,22 @@
     public NamespaceRegistry getNamespaceRegistry() {
         return factories.getNameFactory().getNamespaceRegistry();
     }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.spi.sequencers.SequencerContext#getLogger(java.lang.Class)
+     */
+    public Logger getLogger( Class<?> clazz ) {
+        return context.getLogger(clazz);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.spi.sequencers.SequencerContext#getLogger(java.lang.String)
+     */
+    public Logger getLogger( String name ) {
+        return context.getLogger(name);
+    }
 }

Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java	2008-08-20 16:09:15 UTC (rev 455)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/xml/XmlSequencer.java	2008-08-20 16:57:23 UTC (rev 456)
@@ -105,7 +105,7 @@
             // Parse XML document
             reader.parse(new InputSource(stream));
         } catch (Exception error) {
-            LOGGER.error(error, RepositoryI18n.fatalErrorSequencingXmlDocument, error);
+            context.getLogger(getClass()).error(error, RepositoryI18n.fatalErrorSequencingXmlDocument, error);
             monitor.getProblems().addError(error, RepositoryI18n.fatalErrorSequencingXmlDocument, error);
         } finally {
             monitor.done();

Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerContext.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerContext.java	2008-08-20 16:09:15 UTC (rev 455)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerContext.java	2008-08-20 16:57:23 UTC (rev 456)
@@ -22,6 +22,7 @@
 package org.jboss.dna.spi.sequencers;
 
 import java.util.Set;
+import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.spi.graph.Name;
 import org.jboss.dna.spi.graph.NamespaceRegistry;
 import org.jboss.dna.spi.graph.Path;
@@ -75,4 +76,27 @@
      * @return the namespace registry; never <code>null</code>.
      */
     NamespaceRegistry getNamespaceRegistry();
+
+    /**
+     * Return a logger associated with this context. This logger records only those activities within the context and provide a
+     * way to capture the context-specific activities. All log messages are also sent to the system logger, so classes that log
+     * via this mechanism should <i>not</i> also {@link Logger#getLogger(Class) obtain a system logger}.
+     * 
+     * @param clazz the class that is doing the logging
+     * @return the logger, named after <code>clazz</code>; never null
+     * @see #getLogger(String)
+     */
+    Logger getLogger( Class<?> clazz );
+
+    /**
+     * Return a logger associated with this context. This logger records only those activities within the context and provide a
+     * way to capture the context-specific activities. All log messages are also sent to the system logger, so classes that log
+     * via this mechanism should <i>not</i> also {@link Logger#getLogger(Class) obtain a system logger}.
+     * 
+     * @param name the name for the logger
+     * @return the logger, named after <code>clazz</code>; never null
+     * @see #getLogger(Class)
+     */
+    Logger getLogger( String name );
+
 }

Modified: trunk/extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java	2008-08-20 16:09:15 UTC (rev 455)
+++ trunk/extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java	2008-08-20 16:57:23 UTC (rev 456)
@@ -25,7 +25,6 @@
 import java.io.InputStream;
 import java.util.List;
 import org.jboss.dna.common.monitor.ProgressMonitor;
-import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.sequencer.msoffice.excel.ExcelMetadata;
 import org.jboss.dna.sequencer.msoffice.excel.ExcelMetadataReader;
 import org.jboss.dna.sequencer.msoffice.powerpoint.PowerPointMetadataReader;
@@ -163,7 +162,7 @@
                 }
             } catch (IOException e) {
                 // There was an error reading, so log and continue ...
-                Logger.getLogger(this.getClass()).debug(e, "Error while extracting the PowerPoint metadata");
+                context.getLogger(this.getClass()).debug(e, "Error while extracting the PowerPoint metadata");
             }
         }
         progressMonitor.worked(2);
@@ -174,7 +173,7 @@
                 /*WordMetadata wordMetadata =*/WordMetadataReader.invoke(stream);
             } catch (IOException e) {
                 // There was an error reading, so log and continue ...
-                Logger.getLogger(this.getClass()).debug(e, "Error while extracting the Word document metadata");
+                context.getLogger(this.getClass()).debug(e, "Error while extracting the Word document metadata");
             }
 
         }
@@ -191,7 +190,7 @@
                 }
             } catch (IOException e) {
                 // There was an error reading, so log and continue ...
-                Logger.getLogger(this.getClass()).debug(e, "Error while extracting the Excel metadata");
+                context.getLogger(this.getClass()).debug(e, "Error while extracting the Excel metadata");
             }
         }
         progressMonitor.worked(2);




More information about the dna-commits mailing list