You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/02/20 21:04:03 UTC

svn commit: r379216 - in /cocoon/trunk: cocoon-core/src/main/java/org/apache/cocoon/core/logging/ cocoon-core/src/main/java/org/apache/cocoon/util/ cocoon-core/src/main/java/org/apache/cocoon/util/log/ cocoon-portal/cocoon-portal-impl/src/main/java/org...

Author: cziegeler
Date: Mon Feb 20 12:04:00 2006
New Revision: 379216

URL: http://svn.apache.org/viewcvs?rev=379216&view=rev
Log:
Remove dependencies to LogKit

Removed:
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/logging/CocoonLogKitLoggerManager.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/logging/PerRequestLoggerManager.java
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/util/log/
Modified:
    cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/util/IOUtils.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java

Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/util/IOUtils.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/util/IOUtils.java?rev=379216&r1=379215&r2=379216&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/util/IOUtils.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/util/IOUtils.java Mon Feb 20 12:04:00 2006
@@ -33,7 +33,6 @@
 import java.util.Locale;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.log.Hierarchy;
 
 /**
  * A collection of <code>File</code>, <code>URL</code> and filename
@@ -148,241 +147,246 @@
         return object;
     }
 
-  /**
-   * These are java keywords as specified at the following URL (sorted alphabetically).
-   * http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#229308
-   */
-  static final String keywords[] =
-  {
-      "abstract",  "boolean",     "break",    "byte",         "case",
-      "catch",     "char",        "class",    "const",        "continue",
-      "default",   "do",          "double",   "else",         "extends",
-      "final",     "finally",     "float",    "for",          "goto",
-      "if",        "implements",  "import",   "instanceof",   "int",
-      "interface", "long",        "native",   "new",          "package",
-      "private",   "protected",   "public",   "return",       "short",
-      "static",    "strictfp",    "super",    "switch",       "synchronized",
-      "this",      "throw",       "throws",   "transient",    "try",
-      "void",      "volatile",    "while"
-  };
-
-  /** Collator for comparing the strings */
-  static final Collator englishCollator = Collator.getInstance(Locale.ENGLISH);
-
-  /** Use this character as suffix */
-  static final char keywordSuffix = '_';
-
-  /**
-   * checks if the input string is a valid java keyword.
-   * @return boolean true/false
-   */
-  private static boolean isJavaKeyword(String keyword) {
-    return (Arrays.binarySearch(keywords, keyword, englishCollator) >= 0);
-  }
-
-  // **********************
-  // File Methods
-  // **********************
-
-  /**
-   * Return a modified filename suitable for replicating directory
-   * structures below the store's base directory. The following
-   * conversions are performed:
-   * <ul>
-   * <li>Path separators are converted to regular directory names</li>
-   * <li>File path components are transliterated to make them valid (?)
-   *     programming language identifiers. This transformation may well
-   *     generate collisions for unusual filenames.</li>
-   * </ul>
-   * @return The transformed filename
-   */
-  public static String normalizedFilename(String filename) {
-    if ("".equals(filename)) {
-        return "";
-    }
-    filename = (File.separatorChar == '\\') ? filename.replace('/','\\') : filename.replace('\\','/');
-    String[] path = StringUtils.split(filename, File.separator);
-    int start = (path[0].length() == 0) ? 1 : 0;
-
-    StringBuffer buffer = new StringBuffer();
-    for (int i = start; i < path.length; i++) {
-
-      if (i > start) {
-        buffer.append(File.separator);
-      }
-
-      if (path[i].equals("..")) {
-        int lio;
-        for (lio = buffer.length() - 2; lio >= 0; lio--) {
-          if (buffer.substring(lio).startsWith(File.separator)) {
-            break;
-          }
+    /**
+     * These are java keywords as specified at the following URL (sorted alphabetically).
+     * http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#229308
+     */
+    static final String keywords[] =
+    {
+        "abstract",  "boolean",     "break",    "byte",         "case",
+        "catch",     "char",        "class",    "const",        "continue",
+        "default",   "do",          "double",   "else",         "extends",
+        "final",     "finally",     "float",    "for",          "goto",
+        "if",        "implements",  "import",   "instanceof",   "int",
+        "interface", "long",        "native",   "new",          "package",
+        "private",   "protected",   "public",   "return",       "short",
+        "static",    "strictfp",    "super",    "switch",       "synchronized",
+        "this",      "throw",       "throws",   "transient",    "try",
+        "void",      "volatile",    "while"
+    };
+
+    /** Collator for comparing the strings */
+    static final Collator englishCollator = Collator.getInstance(Locale.ENGLISH);
+
+    /** Use this character as suffix */
+    static final char keywordSuffix = '_';
+
+    /**
+     * checks if the input string is a valid java keyword.
+     * @return boolean true/false
+     */
+    private static boolean isJavaKeyword(String keyword) {
+        return (Arrays.binarySearch(keywords, keyword, englishCollator) >= 0);
+    }
+
+    // **********************
+    // File Methods
+    // **********************
+
+    /**
+     * Return a modified filename suitable for replicating directory structures
+     * below the store's base directory. The following conversions are
+     * performed:
+     * <ul>
+     * <li>Path separators are converted to regular directory names</li>
+     * <li>File path components are transliterated to make them valid (?)
+     * programming language identifiers. This transformation may well generate
+     * collisions for unusual filenames.</li>
+     * </ul>
+     * 
+     * @return The transformed filename
+     */
+    public static String normalizedFilename(String filename) {
+        if ("".equals(filename)) {
+            return "";
         }
-        if (lio >= 0) {
-          buffer.setLength(lio);
+        filename = (File.separatorChar == '\\') ? filename.replace('/', '\\') : filename.replace(
+                '\\', '/');
+        String[] path = StringUtils.split(filename, File.separator);
+        int start = (path[0].length() == 0) ? 1 : 0;
+
+        StringBuffer buffer = new StringBuffer();
+        for (int i = start; i < path.length; i++) {
+
+            if (i > start) {
+                buffer.append(File.separator);
+            }
+
+            if (path[i].equals("..")) {
+                int lio;
+                for (lio = buffer.length() - 2; lio >= 0; lio--) {
+                    if (buffer.substring(lio).startsWith(File.separator)) {
+                        break;
+                    }
+                }
+                if (lio >= 0) {
+                    buffer.setLength(lio);
+                }
+            } else {
+                char[] chars = path[i].toCharArray();
+
+                if (chars.length < 1 || !Character.isLetter(chars[0])) {
+                    buffer.append('_');
+                }
+
+                for (int j = 0; j < chars.length; j++) {
+                    if (org.apache.cocoon.util.StringUtils.isAlphaNumeric(chars[j])) {
+                        buffer.append(chars[j]);
+                    } else {
+                        buffer.append('_');
+                    }
+                }
+
+                // Append the suffix if necessary.
+                if (isJavaKeyword(path[i]))
+                    buffer.append(keywordSuffix);
+            }
+
         }
-      } else {
-        char[] chars = path[i].toCharArray();
+        return buffer.toString();
+    }
+
+    /**
+     * Remove file information from a filename returning only its path component
+     * 
+     * @param filename
+     *            The filename
+     * @return The path information
+     * @deprecated To be removed in cocoon 2.3
+     */
+    public static String pathComponent(String filename) {
+        int i = filename.lastIndexOf(File.separator);
+        return (i > -1) ? filename.substring(0, i) : filename;
+    }
+
+    /**
+     * Remove path information from a filename returning only its file component
+     * 
+     * @param filename
+     *            The filename
+     * @return The filename sans path information
+     * @deprecated To be removed in cocoon 2.3
+     */
+    public static String fileComponent(String filename) {
+        int i = filename.lastIndexOf(File.separator);
+        return (i > -1) ? filename.substring(i + 1) : filename;
+    }
+
+    /**
+     * Strip a filename of its <i>last</i> extension (the portion immediately
+     * following the last dot character, if any)
+     * 
+     * @param filename
+     *            The filename
+     * @return The filename sans extension
+     * @deprecated To be removed in cocoon 2.3
+     */
+    public static String baseName(String filename) {
+        int i = filename.lastIndexOf('.');
+        return (i > -1) ? filename.substring(0, i) : filename;
+    }
 
-        if (chars.length < 1 || !Character.isLetter(chars[0])) {
-          buffer.append('_');
+    /**
+     * Get the complete filename corresponding to a (typically relative)
+     * <code>File</code>. This method accounts for the possibility of an
+     * error in getting the filename's <i>canonical</i> path, returning the
+     * io/error-safe <i>absolute</i> form instead
+     * 
+     * @param file
+     *            The file
+     * @return The file's absolute filename
+     */
+    public static String getFullFilename(File file) {
+        try {
+            return file.getCanonicalPath();
+        } catch (Exception e) {
+            return file.getAbsolutePath();
         }
+    }
+
+    /**
+     * Return the path within a base directory
+     */
+    public static String getContextFilePath(String directoryPath, String filePath) {
+        try {
+            File directory = new File(directoryPath);
+            File file = new File(filePath);
+
+            directoryPath = directory.getCanonicalPath();
+            filePath = file.getCanonicalPath();
+
+            // If the context directory does not have a File.separator
+            // at the end then add one explicitly
+            if(!directoryPath.endsWith(File.separator)){
+                directoryPath += File.separator;
+            }
+
+            // If the context dir contains both kinds of separator
+            // then standardize on using the File.separator
+            if ((directoryPath.indexOf('/') !=-1) && (directoryPath.indexOf('\\') !=-1)) {
+                directoryPath = directoryPath.replace('\\', File.separator.charAt(0));
+                directoryPath = directoryPath.replace('/', File.separator.charAt(0));
+            }
+
+            // If the file path contains both kinds of separator
+            // then standardize on using the File.separator
+            if ((filePath.indexOf('/') !=-1) && (filePath.indexOf('\\') !=-1)) {
+                filePath = filePath.replace('\\', File.separator.charAt(0));
+                filePath = filePath.replace('/', File.separator.charAt(0));
+            }
 
-        for (int j = 0; j < chars.length; j++) {
-          if (org.apache.cocoon.util.StringUtils.isAlphaNumeric(chars[j])) {
-            buffer.append(chars[j]);
-          } else {
-            buffer.append('_');
-          }
+            if (filePath.startsWith(directoryPath)) {
+                filePath = filePath.substring(directoryPath.length());
+            }
+        } catch (Exception e){
+            // ignore
         }
 
-        // Append the suffix if necessary.
-        if(isJavaKeyword(path[i]))
-          buffer.append(keywordSuffix);
-      }
-
-    }
-    return buffer.toString();
-  }
-
-  /**
-   * Remove file information from a filename returning only its path
-   * component
-   *
-   * @param filename The filename
-   * @return The path information
-   * @deprecated To be removed in cocoon 2.3
-   */
-  public static String pathComponent(String filename) {
-    int i = filename.lastIndexOf(File.separator);
-    return (i > -1) ? filename.substring(0, i) : filename;
-  }
-
-  /**
-   * Remove path information from a filename returning only its file
-   * component
-   *
-   * @param filename The filename
-   * @return The filename sans path information
-   * @deprecated To be removed in cocoon 2.3
-   */
-  public static String fileComponent(String filename) {
-    int i = filename.lastIndexOf(File.separator);
-    return (i > -1) ? filename.substring(i + 1) : filename;
-  }
-
-  /**
-   * Strip a filename of its <i>last</i> extension (the portion
-   * immediately following the last dot character, if any)
-   *
-   * @param filename The filename
-   * @return The filename sans extension
-   * @deprecated To be removed in cocoon 2.3
-   */
-  public static String baseName(String filename) {
-    int i = filename.lastIndexOf('.');
-    return (i > -1) ? filename.substring(0, i) : filename;
-  }
-
-  /**
-   * Get the complete filename corresponding to a (typically relative)
-   * <code>File</code>.
-   * This method accounts for the possibility of an error in getting
-   * the filename's <i>canonical</i> path, returning the io/error-safe
-   * <i>absolute</i> form instead
-   *
-   * @param file The file
-   * @return The file's absolute filename
-   */
-  public static String getFullFilename(File file) {
-    try {
-      return file.getCanonicalPath();
-    } catch (Exception e) {
-      Hierarchy.getDefaultHierarchy().getLoggerFor("cocoon").debug("IOUtils.getFullFilename", e);
-      return file.getAbsolutePath();
-    }
-  }
-
-  /**
-   * Return the path within a base directory
-   */
-  public static String getContextFilePath(String directoryPath, String filePath) {
-      try
-      {
-          File directory = new File(directoryPath);
-          File file = new File(filePath);
-
-          directoryPath = directory.getCanonicalPath();
-          filePath = file.getCanonicalPath();
-
-          // If the context directory does not have a File.separator
-          // at the end then add one explicitly
-          if(!directoryPath.endsWith(File.separator)){
-            directoryPath += File.separator;
-          }
-
-          // If the context dir contains both kinds of separator
-          // then standardize on using the File.separator
-          if ((directoryPath.indexOf('/') !=-1) && (directoryPath.indexOf('\\') !=-1)) {
-            directoryPath = directoryPath.replace('\\', File.separator.charAt(0));
-            directoryPath = directoryPath.replace('/', File.separator.charAt(0));
-          }
-
-          // If the file path contains both kinds of separator
-          // then standardize on using the File.separator
-          if ((filePath.indexOf('/') !=-1) && (filePath.indexOf('\\') !=-1)) {
-            filePath = filePath.replace('\\', File.separator.charAt(0));
-            filePath = filePath.replace('/', File.separator.charAt(0));
-          }
-
-          if (filePath.startsWith(directoryPath)) {
-              filePath = filePath.substring(directoryPath.length());
-          }
-      } catch (Exception e){
-          Hierarchy.getDefaultHierarchy().getLoggerFor("cocoon").debug("IOUtils.getContextFilePath", e);
-      }
-
-      return filePath;
-  }
-
-  /**
-   * Return a file with the given filename creating the necessary
-   * directories if not present.
-   *
-   * @param filename The file
-   * @return The created File instance
-   */
-  public static File createFile(File destDir, String filename) {
-    File file = new File(destDir, filename);
-    File parent = file.getParentFile();
-    if (parent != null) parent.mkdirs();
-    return file;
-  }
-
-  /**
-   * Returns a byte array from the given object.
-   *
-   * @param object to convert
-   * @return byte array from the object
-   * @deprecated To be removed in cocoon 2.3
-   */
-  public static byte[] objectToBytes(Object object) throws IOException {
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    ObjectOutputStream os = new ObjectOutputStream(baos);
-    os.writeObject(object);
-    return baos.toByteArray();
-  }
-
-  /**
-   * Returns a object from the given byte array.
-   *
-   * @param bytes array to convert
-   * @return object
-   * @deprecated To be removed in cocoon 2.3
-   */
-  public static Object bytesToObject(byte[] bytes) throws IOException, ClassNotFoundException {
-    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
-    ObjectInputStream is = new ObjectInputStream(bais);
-    return is.readObject();
-  }
+        return filePath;
+    }
+
+    /**
+     * Return a file with the given filename creating the necessary directories
+     * if not present.
+     * 
+     * @param filename
+     *            The file
+     * @return The created File instance
+     */
+    public static File createFile(File destDir, String filename) {
+        File file = new File(destDir, filename);
+        File parent = file.getParentFile();
+        if (parent != null)
+            parent.mkdirs();
+        return file;
+    }
+
+    /**
+     * Returns a byte array from the given object.
+     * 
+     * @param object
+     *            to convert
+     * @return byte array from the object
+     * @deprecated To be removed in cocoon 2.3
+     */
+    public static byte[] objectToBytes(Object object) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream os = new ObjectOutputStream(baos);
+        os.writeObject(object);
+        return baos.toByteArray();
+    }
+
+    /**
+     * Returns a object from the given byte array.
+     * 
+     * @param bytes
+     *            array to convert
+     * @return object
+     * @deprecated To be removed in cocoon 2.3
+     */
+    public static Object bytesToObject(byte[] bytes) throws IOException, ClassNotFoundException {
+        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+        ObjectInputStream is = new ObjectInputStream(bais);
+        return is.readObject();
+    }
 }

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java?rev=379216&r1=379215&r2=379216&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/CocoonPortlet.java Mon Feb 20 12:04:00 2006
@@ -63,7 +63,6 @@
 import org.apache.cocoon.portlet.multipart.RequestFactory;
 import org.apache.cocoon.util.IOUtils;
 import org.apache.commons.lang.SystemUtils;
-import org.apache.log.ContextMap;
 
 /**
  * This is the entry point for Cocoon execution as an JSR-168 Portlet.
@@ -342,8 +341,6 @@
             uri += pathInfo;
         }
 
-        ContextMap ctxMap = null;
-
         Environment env;
         try {
             if (uri.charAt(0) == '/') {
@@ -362,17 +359,6 @@
 
         try {
             try {
-                // Initialize a fresh log context containing the object model: it
-                // will be used by the CocoonLogFormatter
-                ctxMap = ContextMap.getCurrentContext();
-                // Add thread name (default content for empty context)
-                String threadName = Thread.currentThread().getName();
-                ctxMap.set("threadName", threadName);
-                // Add the object model
-                ctxMap.set("objectModel", env.getObjectModel());
-                // Add a unique request id (threadName + currentTime
-                ctxMap.set("request-id", threadName + System.currentTimeMillis());
-
                 if (!this.cocoon.process(env)) {
                     // We reach this when there is nothing in the processing change that matches
                     // the request. For example, no matcher matches.
@@ -430,10 +416,6 @@
             }
             res.setProperty("X-Cocoon-Time", timeString);
         } finally {
-            if (ctxMap != null) {
-                ctxMap.clear();
-            }
-
             if (request instanceof MultipartActionRequest) {
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Deleting uploaded file(s).");
@@ -489,7 +471,6 @@
         }
 
         String contentType = null;
-        ContextMap ctxMap = null;
 
         Environment env;
         try {
@@ -509,17 +490,6 @@
 
         try {
             try {
-                // Initialize a fresh log context containing the object model: it
-                // will be used by the CocoonLogFormatter
-                ctxMap = ContextMap.getCurrentContext();
-                // Add thread name (default content for empty context)
-                String threadName = Thread.currentThread().getName();
-                ctxMap.set("threadName", threadName);
-                // Add the object model
-                ctxMap.set("objectModel", env.getObjectModel());
-                // Add a unique request id (threadName + currentTime
-                ctxMap.set("request-id", threadName + System.currentTimeMillis());
-
                 if (this.cocoon.process(env)) {
                     contentType = env.getContentType();
                 } else {
@@ -595,10 +565,6 @@
                 }
             }
         } finally {
-            if (ctxMap != null) {
-                ctxMap.clear();
-            }
-
             if (request instanceof MultipartActionRequest) {
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Deleting uploaded file(s).");

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java?rev=379216&r1=379215&r2=379216&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java Mon Feb 20 12:04:00 2006
@@ -15,18 +15,22 @@
  */
 package org.apache.cocoon.portlet;
 
-import org.apache.avalon.excalibur.logger.Log4JConfLoggerManager;
-import org.apache.avalon.excalibur.logger.Log4JLoggerManager;
-import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
-import org.apache.avalon.excalibur.logger.LoggerManager;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.LogKitLogger;
-import org.apache.avalon.framework.logger.Logger;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.HashMap;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
 
+import org.apache.avalon.framework.logger.Logger;
 import org.apache.cocoon.Cocoon;
 import org.apache.cocoon.CocoonAccess;
 import org.apache.cocoon.ConnectionResetException;
@@ -35,34 +39,13 @@
 import org.apache.cocoon.components.notification.DefaultNotifyingBuilder;
 import org.apache.cocoon.components.notification.Notifier;
 import org.apache.cocoon.components.notification.Notifying;
-import org.apache.cocoon.core.logging.CocoonLogKitLoggerManager;
+import org.apache.cocoon.core.container.spring.ApplicationContextFactory;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.portlet.PortletContext;
 import org.apache.cocoon.environment.portlet.PortletEnvironment;
 import org.apache.cocoon.portlet.multipart.MultipartActionRequest;
 import org.apache.cocoon.portlet.multipart.RequestFactory;
-
 import org.apache.commons.lang.BooleanUtils;
-import org.apache.log.ContextMap;
-import org.apache.log.Hierarchy;
-import org.apache.pluto.core.impl.PortletContextImpl;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.GenericPortlet;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletException;
-import javax.portlet.PortletSession;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.portlet.PortletRequest;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.net.URL;
-import java.util.HashMap;
 
 /**
  * This is the entry point for Cocoon execution as an JSR-168 Portlet.
@@ -230,7 +213,7 @@
         this.workDir.mkdirs();
 
         // Init logger
-        initLogger();
+        this.log = ApplicationContextFactory.createRootLogger(this.envPortletContext, "cocoon");
 
         final String uploadDirParam = conf.getInitParameter("upload-directory");
         if (uploadDirParam != null) {
@@ -369,8 +352,6 @@
             uri += pathInfo;
         }
 
-        ContextMap ctxMap = null;
-
         Environment env;
         try {
             if (uri.charAt(0) == '/') {
@@ -389,17 +370,6 @@
 
         try {
             try {
-                // Initialize a fresh log context containing the object model: it
-                // will be used by the CocoonLogFormatter
-                ctxMap = ContextMap.getCurrentContext();
-                // Add thread name (default content for empty context)
-                String threadName = Thread.currentThread().getName();
-                ctxMap.set("threadName", threadName);
-                // Add the object model
-                ctxMap.set("objectModel", env.getObjectModel());
-                // Add a unique request id (threadName + currentTime
-                ctxMap.set("request-id", threadName + System.currentTimeMillis());
-
                 if (!cocoon.process(env)) {
                     // We reach this when there is nothing in the processing change that matches
                     // the request. For example, no matcher matches.
@@ -457,10 +427,6 @@
             }
             res.setProperty("X-Cocoon-Time", timeString);
         } finally {
-            if (ctxMap != null) {
-                ctxMap.clear();
-            }
-
             if (request instanceof MultipartActionRequest) {
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Deleting uploaded file(s).");
@@ -512,7 +478,6 @@
         }
 
         String contentType = null;
-        ContextMap ctxMap = null;
 
         Environment env;
         try {
@@ -532,17 +497,6 @@
 
         try {
             try {
-                // Initialize a fresh log context containing the object model: it
-                // will be used by the CocoonLogFormatter
-                ctxMap = ContextMap.getCurrentContext();
-                // Add thread name (default content for empty context)
-                String threadName = Thread.currentThread().getName();
-                ctxMap.set("threadName", threadName);
-                // Add the object model
-                ctxMap.set("objectModel", env.getObjectModel());
-                // Add a unique request id (threadName + currentTime
-                ctxMap.set("request-id", threadName + System.currentTimeMillis());
-
                 if (!cocoon.process(env)) {
                     // We reach this when there is nothing in the processing change that matches
                     // the request. For example, no matcher matches.
@@ -616,10 +570,6 @@
                 }
             }
         } finally {
-            if (ctxMap != null) {
-                ctxMap.clear();
-            }
-
             /*
              * Portlet Specification 1.0, PLT.12.3.2 Output Stream and Writer Objects:
              *   The termination of the render method of the portlet indicates
@@ -844,85 +794,6 @@
             return defaultValue;
         }
         return Integer.parseInt(value);
-    }
-
-    protected void initLogger() {
-        final String accesslogger = getInitParameter("portlet-logger", "cocoon");
-
-        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();
-
-        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
-        final String loggerManagerClass =
-            this.getInitParameter("logger-class", CocoonLogKitLoggerManager.class.getName());
-
-        // the log4j support requires currently that the log4j system is already configured elsewhere
-
-        final LoggerManager loggerManager =
-                newLoggerManager(loggerManagerClass, defaultHierarchy);
-        ContainerUtil.enableLogging(loggerManager, logger);
-
-        final DefaultContext subcontext = new DefaultContext();
-        subcontext.put(Constants.CONTEXT_WORK_DIR, workDir);
-        subcontext.put("portlet-context", this.portletContext);
-        if (this.portletContextPath == null) {
-            File logSCDir = new File(this.workDir, "log");
-            logSCDir.mkdirs();
-            if (getLogger().isWarnEnabled()) {
-                getLogger().warn("Setting context-root for LogKit to " + logSCDir);
-            }
-            subcontext.put("context-root", logSCDir.toString());
-        } else {
-            subcontext.put("context-root", this.portletContextPath);
-        }
-        if ( this.portletContext instanceof PortletContextImpl ) {
-            subcontext.put("servlet-context", ((PortletContextImpl)this.portletContext).getServletContext());
-        }
-
-        try {
-            ContainerUtil.contextualize(loggerManager, subcontext);
-
-            if (loggerManager instanceof Configurable) {
-                //Configure the logkit management
-                String logkitConfig = getInitParameter("logkit-config", "/WEB-INF/logkit.xconf");
-
-                // test if this is a qualified url
-                InputStream is = null;
-                if (logkitConfig.indexOf(':') == -1) {
-                    is = this.portletContext.getResourceAsStream(logkitConfig);
-                    if (is == null) is = new FileInputStream(logkitConfig);
-                } else {
-                    URL logkitURL = new URL(logkitConfig);
-                    is = logkitURL.openStream();
-                }
-                final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
-                final Configuration conf = builder.build(is);
-                ContainerUtil.configure(loggerManager, conf);
-            }
-
-            ContainerUtil.initialize(loggerManager);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        this.log = loggerManager.getLoggerForCategory(accesslogger);
-    }
-
-    private LoggerManager newLoggerManager(String loggerManagerClass, Hierarchy hierarchy) {
-        if (loggerManagerClass.equals(LogKitLoggerManager.class.getName())) {
-            return new CocoonLogKitLoggerManager();
-        } else if (loggerManagerClass.equals(CocoonLogKitLoggerManager.class.getName())) {
-                return new CocoonLogKitLoggerManager();
-        } else if (loggerManagerClass.equals(Log4JLoggerManager.class.getName()) ||
-                   loggerManagerClass.equalsIgnoreCase("LOG4J")) {
-            return new Log4JConfLoggerManager();
-        } else {
-            try {
-                Class clazz = Class.forName(loggerManagerClass);
-                return (LoggerManager)clazz.newInstance();
-            } catch (Exception e) {
-                return new LogKitLoggerManager(hierarchy);
-            }
-        }
     }
 
     protected Logger getLogger() {