cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vadim Gritsenko" <vadim.gritse...@verizon.net>
Subject RE: Pipeline caching...
Date Tue, 25 Sep 2001 13:58:50 GMT
Key must identify your generated page, and it does not necessary mean that
one XSP file must have just one key - because one XSP file may generate lots of pages depending
on environment parameters. Consider following example: XSP generates a catalogue page and
takes a
parameter CategoryID.
Then, good example of key method would be:

   public long generateKey(){
       // Unique ID of your page
       String CategoryID = request.getParameter(ID); // Get CategoryID parameter used to generate
XSP
       return HashUtil.hash(getClass().getName() + CategoryID);
   }


> About caching... another question: the caching validity is
> application-relative, session-relative or page-relative?

Then, answering on your question, validity must be generated in scope of this key - in our
example, in
scope of catalogue category:

   public CacheValidity generateValidity(){
       String CategoryID = request.getParameter(ID); // Get CategoryID parameter used to generate
XSP
       return new TimeStampValidity( MyCatalogue.getCategory(CategoryID).modificationTime()
);
   }

Then XSP page representing CategoryID=XXX would be regenrated ONLY when this category has
been changed.


> Is there any way to define application-scope variables within cocoon?

Can't suggest you anything right now...


Vadim


> -----Original Message-----
> From: Paolo [mailto:lavoro@arsenio.net]
> Sent: Tuesday, September 25, 2001 9:17 AM
> To: cocoon-users@xml.apache.org
> Subject: R: Pipeline caching...
>
>
> Hi Vadim...
> Thank you for your precious reply!
>
> About caching... another question: the caching validity is
> application-relative, session-relative or page-relative?
>
> Is there any way to define application-scope variables within cocoon?
>
> Thank you,
> Paolo Scaffardi
> AIRVENT SAM S.p.A.
>
> -----Messaggio originale-----
> Da: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
> Inviato: lunedì 24 settembre 2001 17.06
> A: cocoon-users@xml.apache.org
> Oggetto: RE: Pipeline caching...
>
> By default XSP generated by Cocoon are not cached, and executed on every
> request.
> To change this behaviour, you need to add these two methods:
>
> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp">
> <xsp:logic>
>   public long generateKey(){
>       // Unique ID of your page
>       return HashUtil.hash(getClass().getName());
>   }
>   public CacheValidity generateValidity(){
>       // Modify according to your needs
>       return new NOPCacheValidity();
>   }
> </xsp:logic>
>
> If you add snippet shown above, your XSP would be executed ONLY ONCE and
> cached FOREVER by Cocoon.
> Another example of validity method is:
>
>   public CacheValidity generateValidity(){
>       if(changed) return null;
>       return new NOPCacheValidity();
>   }
>
> This would invalidate cache entry every time you decide (using if()
> statement) to re-generate XSP.
>
> Vadim
>
> > -----Original Message-----
> > From: Paolo [mailto:lavoro@arsenio.net]
> > Sent: Monday, September 24, 2001 10:42 AM
> > To: Cocoon-Users; cocoon-dev@xml.apache.org
> > Subject: Pipeline caching...
> >
> >
> > I am working on a web application bases on Cocoon 2. Every page of my
> > application has to be created by applying a stylesheet to many
> > aggregated pipelines. Some of these are generated by XSP and querying
> > databases.
> >
> > Some of these XML components don't change into a session, then I can
> > generate them the first time only, store somewhere and reload them
> fast
> > without reprocess every pipeline during the session.
> >
> > I trying using the WriteDOM/ReadDOM transformers but I really don't
> know
> > how to use that because of their transformer-nature (how can use a
> > stored DOM tree as generator?).
> >
> > What I am asking is simple: is there any way to cache a pipeline in
> this
> > way, simply by adding a parameter to the pipeline definition instead
> of
> > many selectors/transformers to do that?
> >
> > Is there anyone that is working on a feature like that?
> >
> > This is my sitemap:
> >
> > <!-- HOME PAGE -->
> > <map:match pattern="home_*">
> >   <map:aggregate element="gportal">
> >     <map:part src="cocoon:/dbhotel"/>		<!-- fixed in session
> > -->
> >     <map:part src="cocoon:/dbroom"/>		<!-- fixed in session
> > -->
> >     <map:part src="cocoon:/dbcustomer"/>		<!-- fixed in
> > session -->
> >     <map:part src="cocoon:/dbdays"/>		<!-- fixed in session
> > -->
> >     <map:part src="cocoon:/otherpipelines"/> 	<!-- changes in session
> > -->
> >   </map:aggregate>
> >   <map:transform src="documents/{1}/home.xsl"/>
> >   <map:serialize/>
> > </map:match>
> >
> > Where dbhotel, dbroom and dbcustomer are something like:
> >
> > <map:match pattern="dbroom">
> >   <map:generate src="documents/shared/xsp/dbroom.xsp"
> > type="serverpages"/>
> >   <map:serialize type="xml"/>
> > </map:match>
> >
> > What do you think about that?
> >
> > Thanx,
> > Paolo Scaffardi
> > AIRVENT SAM S.p.A.
> >
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> >
> > To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> > For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> >
> >
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
>
>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message