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 2001/07/17 12:10:40 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon Cocoon.java

cziegeler    01/07/17 03:10:40

  Modified:    src/org/apache/cocoon Tag: cocoon_20_branch Cocoon.java
  Log:
  Added the code from the submitted DebugAction to the core, so the
  information is always logged.
  Submitted by: Marcus Crafter (Marcus.Crafter@osa.de)
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.9.2.11  +71 -1     xml-cocoon2/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.9.2.10
  retrieving revision 1.9.2.11
  diff -u -r1.9.2.10 -r1.9.2.11
  --- Cocoon.java	2001/07/09 13:22:18	1.9.2.10
  +++ Cocoon.java	2001/07/17 10:10:39	1.9.2.11
  @@ -17,6 +17,7 @@
   import java.util.Enumeration;
   import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.Map;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.Component;
  @@ -41,6 +42,8 @@
   import org.apache.cocoon.components.source.SourceHandler;
   import org.apache.cocoon.components.source.URLSource;
   import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.Request;
  +import org.apache.cocoon.environment.Session;
   import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.serialization.Serializer;
   import org.apache.cocoon.sitemap.Manager;
  @@ -57,7 +60,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a> (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.9.2.10 $ $Date: 2001/07/09 13:22:18 $
  + * @version CVS $Revision: 1.9.2.11 $ $Date: 2001/07/17 10:10:39 $
    */
   public class Cocoon extends AbstractLoggable implements ThreadSafe, Component, Initializable, Disposable, Modifiable, Processor, Contextualizable {
       /** The application context */
  @@ -346,11 +349,77 @@
       }
   
       /**
  +     * Log debug information about the current environment
  +     */
  +    protected void debug(Environment environment,
  +                         StreamPipeline pipeline,
  +                         EventPipeline eventPipeline) {
  +        if (this.getLogger().isDebugEnabled() == true) {
  +            String lineSeparator = System.getProperty("line.separator");
  +            Map objectModel = environment.getObjectModel();
  +            Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
  +            Session session = request.getSession(false);
  +            StringBuffer msg = new StringBuffer();
  +            msg.append("DEBUGGING INFORMATION:").append(lineSeparator);
  +            if (pipeline != null && eventPipeline != null) {
  +                msg.append("INTERNAL ");
  +            }
  +            msg.append("REQUEST: ").append(request.getRequestURI()).append(lineSeparator).append(lineSeparator);
  +            msg.append("CONTEXT PATH: ").append(request.getContextPath()).append(lineSeparator);
  +            msg.append("SERVLET PATH: ").append(request.getServletPath()).append(lineSeparator);
  +            msg.append("PATH INFO: ").append(request.getPathInfo()).append(lineSeparator).append(lineSeparator);
  +
  +            msg.append("REMOTE HOST: ").append(request.getRemoteHost()).append(lineSeparator);
  +            msg.append("REMOTE ADDRESS: ").append(request.getRemoteAddr()).append(lineSeparator);
  +            msg.append("REMOTE USER: ").append(request.getRemoteUser()).append(lineSeparator);
  +            msg.append("REQUEST SESSION ID: ").append(request.getRequestedSessionId()).append(lineSeparator);
  +            msg.append("REQUEST PREFERRED LOCALE: ").append(request.getLocale().toString()).append(lineSeparator);
  +            msg.append("SERVER HOST: ").append(request.getServerName()).append(lineSeparator);
  +            msg.append("SERVER PORT: ").append(request.getServerPort()).append(lineSeparator).append(lineSeparator);
  +
  +            msg.append("METHOD: ").append(request.getMethod()).append(lineSeparator);
  +            msg.append("CONTENT LENGTH: ").append(request.getContentLength()).append(lineSeparator);
  +            msg.append("PROTOCOL: ").append(request.getProtocol()).append(lineSeparator);
  +            msg.append("SCHEME: ").append(request.getScheme()).append(lineSeparator);
  +            msg.append("AUTH TYPE: ").append(request.getAuthType()).append(lineSeparator).append(lineSeparator);
  +
  +            // log all of the request parameters
  +            Enumeration e = request.getParameterNames();
  +
  +            msg.append("REQUEST PARAMETERS:").append(lineSeparator).append(lineSeparator);
  +
  +            while (e.hasMoreElements()) {
  +                String p = (String) e.nextElement();
  +
  +                 msg.append("PARAM: '").append(p).append("' ")
  +                    .append("VALUE: '").append(request.getParameter(p)).append("'").append(lineSeparator);
  +            }
  +
  +            msg.append(lineSeparator).append("SESSION ATTRIBUTES:").append(lineSeparator).append(lineSeparator);
  +
  +            // log all of the session attributes
  +            if (session != null) {
  +                 e = session.getAttributeNames();
  +
  +                while (e.hasMoreElements()) {
  +                    String p = (String) e.nextElement();
  +
  +                    msg.append("PARAM: '").append(p).append("' ")
  +                       .append("VALUE: '").append(session.getAttribute(p)).append("'").append(lineSeparator);
  +                }
  +            }
  +
  +            getLogger().debug(msg.toString());
  +        }
  +    }
  +
  +    /**
        * Process the given <code>Environment</code> to produce the output.
        */
       public boolean process(Environment environment)
       throws Exception {
           if (disposed) throw new IllegalStateException("You cannot process a Disposed Cocoon engine.");
  +        this.debug(environment, null, null);
           return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName,
                    this.checkSitemapReload, this.reloadSitemapAsynchron);
       }
  @@ -362,6 +431,7 @@
       public boolean process(Environment environment, StreamPipeline pipeline, EventPipeline eventPipeline)
       throws Exception {
           if (disposed) throw new IllegalStateException("You cannot process a Disposed Cocoon engine.");
  +        this.debug(environment, pipeline, eventPipeline);
           return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName,
                 this.checkSitemapReload, this.reloadSitemapAsynchron,
                 pipeline, eventPipeline);
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org