Apache » Cocoon »

  Cocoon 3
   homepage

Cocoon 3

Student project idea: Cocoon Profiling

Collect profiling data on a per-request basis and expose it via a RESTful web service

Description

A Cocoon request goes through many components

While performing a Cocoon request, servlets, sitemaps and pipeline components are being executed. It is also quite common that Cocoon requests are cascaded which makes it sometimes difficult to understand what exactly was happening.

The goal of this project is to collect data on a per-request basis about the involved

  • servlets
  • sitemaps and their nodes
  • pipeline components (input parameters, configuration, the content before and after their invocation, execution times)

and expose this data via RESTful web services:

  GET /cocoon-profiling/request/1
  ........................................................
  <request uri="app/videos/comedy/1" type="external">
    <servlet class="org.apache.cocoon.servlet.XMLSitemapServlet" bean-name="org.mycompany.rest.servlet">
      <sitemap>
        <node type="map:match" pattern="videos/**">
          <node type="map:match" pattern="comedy/{id}">
            <node type="controller:call" controller="rest-controller" select="org.apache.cocoon.sample.controller.DemoRESTController">
              <request type="servlet-service">
                <servlet class="org.apache.cocoon.servlet.XMLSitemapServlet" bean-name="org.mycompany.view.servlet">
                  <sitemap>
                    <node type="map:match" pattern="screen/video/{id}.html">
                       <pipeline>
                         <generate type="generator:file" content="./data/1" duration="5ms">
                           <parameter name="id" value="1"/>
                         </generate>
                         <transform type="transformer:cleaning"  content="./data/2" duration="1ms"/>
                         <map:serialize type="serializer:xhtml"  content="./data/3" duration="3ms"/>
                       </pipeline>
                    </node>
                  </sitemap>
                </servlet>
              </reqest>
            </node>
          </node>
        </node>
      </sitemap>
    </servlet>
  </reqest>


  GET /cocoon-profiling/request/1/data/1
  ........................................................
  <html>
    <body>
      <h1>Video 1<h1>
    <body>
  </html>

Additionally an XHTML representation of the profiling data should be provided so that the data becomes more readable.

Implementation ideas

It is important that the profiling module doesn't affect any existing code. That can be achieved by using aspect-oriented programming.

Cocoon 3 web applications make use of following modules:

  • cocoon-pipeline
  • cocoon-sitemap
  • cocoon-servlet
  • cocoon-controller
  • cocoon-rest

and builds upon the

  • cocoon-servlet-service framework

Except the stand-alone cocoon-pipeline module all other modules make use of Spring. Since Spring comes with great AOP support, it's our idea to collect all the necessary information about servlets, invoked sitemaps and their nodes and pipeline components by using Spring AOP. The collected data can be stored by using ThreadLocals and kept in memory.

When profiling is turned on, the header parameter X-Cocoon-Profiling-URL is added to the response header and contains the relative link to the profiling data webservice, e.g. ../../cocoon-profiling/request/1. Again, this can be achieved by AOP interception mechanisms applied on servlets.

The RESTful webservices can be implemented by using the cocoon-rest module.

Profiling can be turned on and off by using JMX or by configuration parameters.

Deliverables

  • cocoon-profiling module integrated into the Cocoon 3 build process
  • usage documentation
  • Javadocs

Technologies

Cocoon 3, Spring AOP, Java, RESTful webservices

Related ideas

There is an additional project idea (Cocoon 3 Profiling UI) of creating a Firebug plugin that shows the data of the request in a user-friendly way.