You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by jw...@apache.org on 2005/05/10 11:24:56 UTC

svn commit: r169444 - in /lenya/trunk/src: java/org/apache/lenya/cms/authoring/ java/org/apache/lenya/cms/publication/ webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/

Author: jwkaltz
Date: Tue May 10 02:24:54 2005
New Revision: 169444

URL: http://svn.apache.org/viewcvs?rev=169444&view=rev
Log:
replace log4j with Avalon logger

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java
    lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java
    lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java?rev=169444&r1=169443&r2=169444&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/authoring/DefaultCreator.java Tue May 10 02:24:54 2005
@@ -15,8 +15,6 @@
  *
  */
 
-/* $Id$  */
-
 package org.apache.lenya.cms.authoring;
 
 import java.io.File;
@@ -24,31 +22,25 @@
 import java.util.Map;
 
 import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
 import org.apache.lenya.xml.DocumentHelper;
-import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 
 /**
  * The default creator for documents
+ * @version $Id$
  */
-public class DefaultCreator implements ParentChildCreatorInterface  {
-
-    // FIXME: remove direct reference to log4j. A logger could be passed
-    // to init(), as DocumentTypeBuilder is a service. However, whoever
-    // creates blog entries is not yet a service, so that would need
-    // to be switched as well at the same time.
-    private Logger log = Logger.getLogger(DefaultCreator.class);
-    
-    public Logger getLogger() {
-        return log;
-    }
+public class DefaultCreator extends AbstractLogEnabled implements ParentChildCreatorInterface  {
 
     private String sampleResourceName = null;
 
     /**
-     * @see org.apache.lenya.cms.authoring.ParentChildCreatorInterface#init(Configuration)
+     * @see org.apache.lenya.cms.authoring.ParentChildCreatorInterface#init(Configuration, Logger)
      */
-    public void init(Configuration conf) {
+    public void init(Configuration conf, Logger _logger) {
+        ContainerUtil.enableLogging(this, _logger);
         // nothing to configure in current implementation
     }
 

Modified: lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java?rev=169444&r1=169443&r2=169444&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/authoring/ParentChildCreatorInterface.java Tue May 10 02:24:54 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright  1999-2004 The Apache Software Foundation
+ * Copyright  1999-2005 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -15,17 +15,17 @@
  *
  */
 
-/* $Id$  */
-
 package org.apache.lenya.cms.authoring;
 
 import java.io.File;
 import java.util.Map;
 
 import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.logger.Logger;
 
 /**
  * Interface for creation of hierarchical documents
+ * @version $Id$
  */
 public interface ParentChildCreatorInterface {
     /**
@@ -48,8 +48,9 @@
      * Configures the Creator, based on a configuration file.
      * 
      * @param doctypeConf A configuration.
+     * @param logger A logger
      */
-    void init(Configuration doctypeConf);
+    void init(Configuration doctypeConf, Logger logger);
 
     /**
      * Return the type of node this creator will create. It can be

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java?rev=169444&r1=169443&r2=169444&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentTypeBuilderImpl.java Tue May 10 02:24:54 2005
@@ -182,7 +182,7 @@
                     String creatorClassName = creatorConf.getAttribute(SRC_ATTRIBUTE);
                     Class creatorClass = Class.forName(creatorClassName);
                     creator = (ParentChildCreatorInterface) creatorClass.newInstance();
-                    creator.init(creatorConf);
+                    creator.init(creatorConf, getLogger());
                 } else {
                     creator = new DefaultBranchCreator();
                 }

Modified: lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java?rev=169444&r1=169443&r2=169444&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java Tue May 10 02:24:54 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright  1999-2004 The Apache Software Foundation
+ * Copyright  1999-2005 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -15,13 +15,10 @@
  *
  */
 
-/* $Id$  */
-
 package org.apache.lenya.cms.authoring;
 
-import org.apache.log4j.Logger;
-
 import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.logger.Logger;
 
 import org.apache.xpath.XPathAPI;
 import org.w3c.dom.Document;
@@ -36,8 +33,11 @@
 import java.util.Map;
 import java.util.Date;
 
+/**
+ * Creator a blog entry
+ * @version $Id$
+ */
 public class NewBlogEntryCreator extends DefaultBranchCreator {
-    private static Logger log = Logger.getLogger(NewBlogEntryCreator.class);
 
     private String year;
     private String month;
@@ -47,8 +47,8 @@
     /**
      *
      */
-    public void init(Configuration conf) {
-        super.init(conf);
+    public void init(Configuration conf, Logger _logger) {
+        super.init(conf, _logger);
 
         DateFormat fmtyyyy = new SimpleDateFormat("yyyy");
         DateFormat fmtMM = new SimpleDateFormat("MM");
@@ -59,7 +59,8 @@
         month = fmtMM.format(date);
         day = fmtdd.format(date);
 
-        log.debug(".init(): Initialize Creator: " + year + "/" + month + "/" + day);
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("NewBlogEntryCreator.init(): Initialize Creator: " + year + "/" + month + "/" + day);
     }
 
     /**
@@ -67,7 +68,10 @@
      */
     protected String getChildFileName(File parentDir, String childId, String language) {
         String newFilename = parentDir + File.separator + "entries" + File.separator + year + File.separator + month + File.separator + day + File.separator + childId + File.separator + "index.xml";
-        log.debug(".getChildFileName(): " + newFilename);
+
+        if (getLogger().isDebugEnabled())
+            getLogger().debug("NewBlogEntryCreator.getChildFileName(): " + newFilename);
+
         return newFilename;
     }
 
@@ -76,7 +80,9 @@
      */
     protected void transformXML(Document doc, String childId, short childType, String childName, Map parameters) throws Exception {
        Element parent = doc.getDocumentElement();
-       log.debug(".transformXML(): " + childId);
+
+       if (getLogger().isDebugEnabled())
+           getLogger().debug("NewBlogEntryCreator.transformXML(): " + childId);
 
        // Replace id
         Element element = (Element) XPathAPI.selectSingleNode(parent, "/*[local-name() = 'entry']/*[local-name() = 'id']");



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org