cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: rev 55733 - in cocoon/trunk/src: blocks/portal/java/org/apache/cocoon/portlet blocks/scratchpad/java/org/apache/cocoon/ant java/org/apache/cocoon/bean java/org/apache/cocoon/servlet
Date Wed, 27 Oct 2004 20:35:29 GMT
Author: vgritsenko
Date: Wed Oct 27 13:35:28 2004
New Revision: 55733

Modified:
   cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java
   cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
   cocoon/trunk/src/blocks/scratchpad/java/org/apache/cocoon/ant/CocoonTask.java
   cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonWrapper.java
   cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
Log:
Make sure work directory present in context before initializing logger.


Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java	(original)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java	Wed Oct
27 13:35:28 2004
@@ -316,8 +316,11 @@
             this.workDir = new File(workDir, "cocoon-files");
         }
         this.workDir.mkdirs();
+        this.appContext.put(Constants.CONTEXT_WORK_DIR, workDir);
 
+        // Init logger
         initLogger();
+
         String path = this.portletContextPath;
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("getRealPath for /: " + path);
@@ -354,25 +357,19 @@
                 throw new PortletException("Unable to determine portlet context URL.", me);
             }
         }
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("URL for Root: " + this.portletContextURL);
-        }
 
         this.forceLoadParameter = getInitParameter("load-class", null);
-
         this.forceSystemProperty = getInitParameter("force-property", null);
 
-        // add work directory
-        if (workDirParam != null) {
-            if (getLogger().isDebugEnabled()) {
+        // Output some debug info
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Portlet Context URL: " + this.portletContextURL);
+            if (workDirParam != null) {
                 getLogger().debug("Using work-directory " + this.workDir);
-            }
-        } else {
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("work-directory was not set - defaulting to " + this.workDir);
+            } else {
+                getLogger().debug("Using default work-directory " + this.workDir);
             }
         }
-        this.appContext.put(Constants.CONTEXT_WORK_DIR, workDir);
         this.appContext.put(ContextHelper.CONTEXT_ROOT_URL, this.portletContextURL);
 
         final String uploadDirParam = conf.getInitParameter("upload-directory");
@@ -396,7 +393,7 @@
         } else {
             this.uploadDir = new File(workDir, "upload-dir" + File.separator);
             if (getLogger().isDebugEnabled()) {
-                getLogger().debug("upload-directory was not set - defaulting to " + this.uploadDir);
+                getLogger().debug("Using default upload-directory " + this.uploadDir);
             }
         }
         this.uploadDir.mkdirs();
@@ -820,8 +817,8 @@
         if (this.portletContextPath == null) {
             File logSCDir = new File(this.workDir, "log");
             logSCDir.mkdirs();
-            if (logger.isWarnEnabled()) {
-                logger.warn("Setting servlet-context for LogKit to " + logSCDir);
+            if (getLogger().isWarnEnabled()) {
+                getLogger().warn("Setting context-root for LogKit to " + logSCDir);
             }
             subcontext.put("context-root", logSCDir.toString());
         } else {

Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
(original)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
Wed Oct 27 13:35:28 2004
@@ -200,8 +200,6 @@
         this.envPortletContext = new PortletContext(this.portletContext);
         this.portletContextPath = this.portletContext.getRealPath("/");
 
-        initLogger();
-
         // first init the work-directory for the logger.
         // this is required if we are running inside a war file!
         final String workDirParam = getInitParameter("work-directory");
@@ -230,6 +228,9 @@
         }
         this.workDir.mkdirs();
 
+        // Init logger
+        initLogger();
+
         final String uploadDirParam = conf.getInitParameter("upload-directory");
         if (uploadDirParam != null) {
             if (this.portletContextPath == null) {
@@ -866,12 +867,13 @@
         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 servlet-context for LogKit to " + logSCDir);
+                getLogger().warn("Setting context-root for LogKit to " + logSCDir);
             }
             subcontext.put("context-root", logSCDir.toString());
         } else {

Modified: cocoon/trunk/src/blocks/scratchpad/java/org/apache/cocoon/ant/CocoonTask.java
==============================================================================
--- cocoon/trunk/src/blocks/scratchpad/java/org/apache/cocoon/ant/CocoonTask.java	(original)
+++ cocoon/trunk/src/blocks/scratchpad/java/org/apache/cocoon/ant/CocoonTask.java	Wed Oct
27 13:35:28 2004
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 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.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -62,7 +62,7 @@
  * Ant task for running Cocoon.
  *
  * @author    huber@apache.org
- * @version CVS $Id: CocoonTask.java,v 1.9 2004/06/24 13:52:49 cziegeler Exp $
+ * @version CVS $Id$
  */
 public class CocoonTask extends Task {
 
@@ -620,8 +620,6 @@
                         this.logKitLoggerManager = new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());
 
                         final DefaultContext subcontext = new DefaultContext(this.ctx);
-                        File contextDir = (File) this.ctx.get("context-root");
-                        subcontext.put("context-root", contextDir);
                         this.logKitLoggerManager.contextualize(subcontext);
                         this.logKitLoggerManager.configure(logKitConf);
                         logger = this.logKitLoggerManager.getLoggerForCategory(logKitLogCategory);

Modified: cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonWrapper.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonWrapper.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/bean/CocoonWrapper.java	Wed Oct 27 13:35:28 2004
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 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.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -56,7 +56,7 @@
 import org.apache.log.Priority;
 
 /**
- * The Cocoon Wrapper simplifies usage of the Cocoon object. Allows to create, 
+ * The Cocoon Wrapper simplifies usage of the Cocoon object. Allows to create,
  * configure Cocoon instance and process single requests.
  *
  * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
@@ -80,7 +80,7 @@
     private String userAgent = DEFAULT_USER_AGENT;
     private String accept = DEFAULT_ACCEPT;
     private List classList = new ArrayList();
- 
+
     // Objects used alongside User Supplied Parameters
     private File context;
     private File work;
@@ -110,12 +110,13 @@
 
         try {
             DefaultContext appContext = new DefaultContext();
-            appContext.put(
-                Constants.CONTEXT_CLASS_LOADER,
-                CocoonWrapper.class.getClassLoader());
+            appContext.put(Constants.CONTEXT_CLASS_LOADER,
+                           CocoonWrapper.class.getClassLoader());
             cliContext = new CommandLineContext(contextDir);
             cliContext.enableLogging(log);
             appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, cliContext);
+            appContext.put(Constants.CONTEXT_WORK_DIR, work);
+
             LogKitLoggerManager logKitLoggerManager =
                     new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());
             logKitLoggerManager.enableLogging(log);
@@ -126,7 +127,7 @@
                     new DefaultConfigurationBuilder();
                 final Configuration logKitConf = builder.build(fis);
                 final DefaultContext subcontext = new DefaultContext(appContext);
-                subcontext.put("context-root", contextDir);
+                subcontext.put("context-root", this.contextDir);
                 logKitLoggerManager.contextualize(subcontext);
                 logKitLoggerManager.configure(logKitConf);
                 if (logger != null) {
@@ -137,14 +138,13 @@
             }
 
             appContext.put(Constants.CONTEXT_CLASSPATH, getClassPath(contextDir));
-            appContext.put(Constants.CONTEXT_WORK_DIR, work);
             appContext.put(Constants.CONTEXT_UPLOAD_DIR, contextDir + "upload-dir");
             File cacheDir = getDir(workDir + File.separator + "cache-dir", "cache");
             appContext.put(Constants.CONTEXT_CACHE_DIR, cacheDir);
             appContext.put(Constants.CONTEXT_CONFIG_URL, conf.toURL());
             appContext.put(Constants.CONTEXT_DEFAULT_ENCODING, "ISO-8859-1");
             appContext.put(ContextHelper.CONTEXT_ROOT_URL, this.context.toURL().toExternalForm());
-            
+
             loadClasses(classList);
 
             cocoon = new Cocoon();
@@ -159,7 +159,7 @@
         }
         initialized = true;
     }
-    
+
     protected ServiceManager getServiceManager() {
         return cocoon.getServiceManager();
     }
@@ -314,7 +314,7 @@
     public String getLoggerName() {
         return logger;
     }
-    
+
     /**
      * Set context directory
      * @param contextDir context directory
@@ -468,7 +468,7 @@
      */
     protected String getType(String deparameterizedURI, Map parameters)
         throws Exception {
-        
+
         parameters.put("user-agent", userAgent);
         parameters.put("accept", accept);
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java	(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/servlet/CocoonServlet.java	Wed Oct 27 13:35:28
2004
@@ -289,8 +289,11 @@
             this.workDir = new File(workDir, "cocoon-files");
         }
         this.workDir.mkdirs();
+        this.appContext.put(Constants.CONTEXT_WORK_DIR, workDir);
 
+        // Init logger
         initLogger();
+
         String path = this.servletContextPath;
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("getRealPath for /: " + path);
@@ -327,25 +330,19 @@
                 throw new ServletException("Unable to determine servlet context URL.", me);
             }
         }
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("URL for Root: " + this.servletContextURL);
-        }
 
         this.forceLoadParameter = getInitParameter("load-class", null);
-
         this.forceSystemProperty = getInitParameter("force-property", null);
 
-        // add work directory
-        if (workDirParam != null) {
-            if (getLogger().isDebugEnabled()) {
+        // Output some debug info
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Servlet Context URL: " + this.servletContextURL);
+            if (workDirParam != null) {
                 getLogger().debug("Using work-directory " + this.workDir);
-            }
-        } else {
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("work-directory was not set - defaulting to " + this.workDir);
+            } else {
+                getLogger().debug("Using default work-directory " + this.workDir);
             }
         }
-        this.appContext.put(Constants.CONTEXT_WORK_DIR, workDir);
         this.appContext.put(ContextHelper.CONTEXT_ROOT_URL, this.servletContextURL);
 
         final String uploadDirParam = conf.getInitParameter("upload-directory");
@@ -369,7 +366,7 @@
         } else {
             this.uploadDir = new File(workDir, "upload-dir" + File.separator);
             if (getLogger().isDebugEnabled()) {
-                getLogger().debug("upload-directory was not set - defaulting to " + this.uploadDir);
+                getLogger().debug("Using default upload-directory " + this.uploadDir);
             }
         }
         this.uploadDir.mkdirs();
@@ -772,11 +769,12 @@
 
         final DefaultContext subcontext = new DefaultContext(this.appContext);
         subcontext.put("servlet-context", this.servletContext);
+        subcontext.put("context-work", this.workDir);
         if (this.servletContextPath == null) {
             File logSCDir = new File(this.workDir, "log");
             logSCDir.mkdirs();
             if (logger.isWarnEnabled()) {
-                logger.warn("Setting servlet-context for LogKit to " + logSCDir);
+                logger.warn("Setting context-root for LogKit to " + logSCDir);
             }
             subcontext.put("context-root", logSCDir.toString());
         } else {

Mime
View raw message