cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Romano Trampus" <tram...@univ.trieste.it>
Subject CachingPointProcessingPipeline problem
Date Wed, 20 Apr 2005 09:16:11 GMT
Hi,

I've spent a week on this problem, trying to debug
AbstractCachingProcessingPipeline, CachingPointProcessingPipeline and a few
other classes (cocoon 2.1.7, jdk 1.5, tomcat 5).

The problem is about caching-point. My situation is the following (it seems
the same described in the sitemap.xconf):

G --- (T1) --- (S)XML
|
+ --- (T2) --- (S)SVG

The generator G makes a lot of query on a db. T1 is a simple trasformer
(XSLT) and T2 is a XSLT trasformer that trasform the data in XML/SVG.

Because the SVG serializer takes a long to process the data I want the
output from the generator G to be cached AND the output of the two complete
pipeline to be cached. 

OK, it does not run as I want. So I began debugging. First I made a
generator (called "mio", source code is at the end of this mail). My
generator does nothing but prints "generato" and the key and validity
values, just to understand what is going on.
In the sitemap I have:

....
    <!-- define my new simple generator -->
    <map:generator label="content" name="mio" src="mio"/>
....

Below in the pipeline section I use:

....
    <map:match pattern="mio">
	  <map:act type="request">
          <map:generate type="mio" src="{requestQuery}"
pipeline-hints="caching-point" /> 
      </map:act>
    </map:match>     
....

And I use the default defined view of the sitemap:

  <map:views>
    <map:view from-label="content" name="xml">
      <map:serialize type="xml" />
    </map:view>

    <map:view from-label="content" name="html">
      <map:transform src="stylesheets/system/xml2html.xslt"/>
      <map:serialize type="html"/>
    </map:view>
  </map:views>

My generator uses the source message as a key (stripping out the
"cocoon-view=...." substring).

Well, if I request

http://localhost:8080/sba/mio?cocoon-view=html&pippo=5
and
http://localhost:8080/sba/mio?cocoon-view=xml&pippo=5

The generator (the generate method in the generator) is invoked twice. It's
the same if I set autoCachingPoint to on or off.
Looking to the cocoon source I've found the method 

connectCachingPipeline(Environment   environment)

in class CachingPointProcessingPipeline. First I thought the problem was the
system didn't check if the generator is cached so I inserted a empty xslt
trasformer just after the generator (i.e. in the match section). But nothing
changed.

Where I'm wrong?

Thank's a lot,

Romano

This is the generator source I use:
---

import org.apache.cocoon.*;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.generation.*;
import org.apache.cocoon.xml.AttributesImpl;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.TimeStampValidity;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.Composable;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.Serializable;

public class mio extends AbstractGenerator implements Composable,
CacheableProcessingComponent {
    
    public void generate() throws SAXException, IOException, 
        ProcessingException {
        String message=this.source;
        String[] previousSearch=null;
        String c="";
        
        System.out.println("generato");
     
        contentHandler.startDocument();
        contentHandler.startElement("","root","root",new AttributesImpl());

    	contentHandler.startElement("","query","query",new
AttributesImpl());
        contentHandler.characters(message.toCharArray(), 0,
message.length());
        contentHandler.endElement("","query","query");

        contentHandler.endElement("","root","root");
        contentHandler.endDocument();
    }
    
    public void compose(ComponentManager manager) throws ComponentException
{
    }

	public Serializable getKey() {
		
		String message=this.source;
		if(message==null)return null;
		
		if(message.startsWith("?cocoon-view=")) {
        	try {message="?"+message.substring(message.indexOf("&"));}
        	catch (Exception e) {}
        }

		System.out.println("getKey: "+message);
		return message;
	}

	public SourceValidity getValidity() {
		long t=System.currentTimeMillis()/1000000;
		System.out.println("getValidity: "+t);
		System.out.println("------------------");
		if(t>0) {return new TimeStampValidity(t);}
		else {return null;}
	}
}


Mime
View raw message