cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 17623] - Incorrect caching behaviour
Date Thu, 01 May 2003 15:23:07 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17623>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17623

Incorrect caching behaviour





------- Additional Comments From bhtek@yahoo.com  2003-05-01 15:23 -------
This is one of the ways I can think of, a hacky ugly way
to make FileGenerator return a cache key that looks at more than
just the inputURI.
But I still think there is
already some other easier way to make the caching depend on more
than just the inputURI. Any ideas, others?


    <map:generators default="file">
      <map:generator 
              label="content,data" 
              logger="sitemap.generator.requestParamDependentFile" 
              name="requestParamDependentFile" 
              pool-grow="4" pool-max="32" pool-min="8" 
             
src="org.apache.cocoon.generation.RequestParamDependentFileGenerator"/>
    </map:generators>

      <map:match pattern="test.portlet">
        <map:generate src="cocoon:/test.resource"
type="requestParamDependentFile"/> 
        <map:serialize type="xml"/> 
      </map:match>

<!-- Start org.apache.cocoon.generation.RequestParamDependentFileGenerator -->
package org.apache.cocoon.generation;

import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.xml.sax.SAXException;

import java.io.IOException;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Map;

public class RequestParamDependentFileGenerator extends FileGenerator {
    protected Request request;


    public void setup(
            SourceResolver resolver,
            Map objectModel,
            String src,
            Parameters par )
        throws ProcessingException, SAXException, IOException {
        super.setup( resolver, objectModel, src, par );

        this.request = ObjectModelHelper.getRequest( objectModel );
    }


    public Serializable getKey() {
        StringBuffer nameValuePairConcatenated = new StringBuffer()
                .append( this.inputSource.getURI() );

        Enumeration enum = request.getParameterNames();
        while ( enum.hasMoreElements() ) {
            String name = (String) enum.nextElement();
            String value = request.getParameter( name );

            nameValuePairConcatenated.append( "__" )
                    .append( name )
                    .append( "_" )
                    .append( value );
        }

        return nameValuePairConcatenated.toString();
    }


    public void recycle() {
        super.recycle();

        if ( null == this.request ) {
            this.request = null;
        }
    }
}
<!-- End org.apache.cocoon.generation.RequestParamDependentFileGenerator -->

Mime
View raw message